Stop using pkg/scheduled_test (#651)
Closes https://github.com/dart-lang/dart_style/issues/637
diff --git a/analysis_options.yaml b/analysis_options.yaml
index a10d4c5..574efd1 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -1,2 +1,5 @@
analyzer:
strong-mode: true
+linter:
+ rules:
+ - unawaited_futures
diff --git a/pubspec.lock b/pubspec.lock
index be4d455..538ba6c 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -211,12 +211,6 @@
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.2"
- scheduled_test:
- description:
- name: scheduled_test
- url: "https://pub.dartlang.org"
- source: hosted
- version: "0.12.11+1"
shelf:
description:
name: shelf
@@ -295,6 +289,18 @@
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.20+13"
+ test_descriptor:
+ description:
+ name: test_descriptor
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.0.2"
+ test_process:
+ description:
+ name: test_process
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.0.1"
typed_data:
description:
name: typed_data
@@ -332,4 +338,4 @@
source: hosted
version: "2.1.12"
sdks:
- dart: ">=1.23.0-dev.0.0 <2.0.0"
+ dart: ">=1.23.0-dev.0.0 <=2.0.0-dev.2.0"
diff --git a/pubspec.yaml b/pubspec.yaml
index dfba024..ceaa10b 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: dart_style
# Note: See tool/grind.dart for how to bump the version.
-version: 1.0.8
+version: 1.0.9-dev
author: Dart Team <misc@dartlang.org>
description: Opinionated, automatic Dart source code formatter.
homepage: https://github.com/dart-lang/dart_style
@@ -18,8 +18,9 @@
js: ^0.6.0
node_preamble: ^1.0.0
pub_semver: '^1.2.3'
- scheduled_test: '>=0.12.0 <0.13.0'
test: '>=0.12.0 <0.13.0'
+ test_descriptor: "^1.0.0"
+ test_process: "^1.0.0"
yaml: '^2.0.0'
executables:
dartfmt: format
diff --git a/test/command_line_test.dart b/test/command_line_test.dart
index e105859..d34c692 100644
--- a/test/command_line_test.dart
+++ b/test/command_line_test.dart
@@ -7,95 +7,93 @@
import 'dart:convert';
import 'package:path/path.dart' as p;
-import 'package:scheduled_test/descriptor.dart' as d;
-import 'package:scheduled_test/scheduled_test.dart';
-import 'package:scheduled_test/scheduled_stream.dart';
+import 'package:test_descriptor/test_descriptor.dart' as d;
+import 'package:test/test.dart';
import 'utils.dart';
void main() {
- setUpTestSuite();
+ test("exits with 0 on success", () async {
+ await d.dir("code", [d.file("a.dart", unformattedSource)]).create();
- test("exits with 0 on success", () {
- d.dir("code", [d.file("a.dart", unformattedSource)]).create();
-
- var process = runFormatterOnDir();
- process.shouldExit(0);
+ var process = await runFormatterOnDir();
+ await process.shouldExit(0);
});
- test("exits with 64 on a command line argument error", () {
- var process = runFormatterOnDir(["-wat"]);
- process.shouldExit(64);
+ test("exits with 64 on a command line argument error", () async {
+ var process = await runFormatterOnDir(["-wat"]);
+ await process.shouldExit(64);
});
- test("exits with 65 on a parse error", () {
- d.dir("code", [d.file("a.dart", "herp derp i are a dart")]).create();
+ test("exits with 65 on a parse error", () async {
+ await d.dir("code", [d.file("a.dart", "herp derp i are a dart")]).create();
- var process = runFormatterOnDir();
- process.shouldExit(65);
+ var process = await runFormatterOnDir();
+ await process.shouldExit(65);
});
- test("errors if --dry-run and --overwrite are both passed", () {
- d.dir("code", [d.file("a.dart", unformattedSource)]).create();
+ test("errors if --dry-run and --overwrite are both passed", () async {
+ await d.dir("code", [d.file("a.dart", unformattedSource)]).create();
- var process = runFormatterOnDir(["--dry-run", "--overwrite"]);
- process.shouldExit(64);
+ var process = await runFormatterOnDir(["--dry-run", "--overwrite"]);
+ await process.shouldExit(64);
});
- test("errors if --dry-run and --machine are both passed", () {
- d.dir("code", [d.file("a.dart", unformattedSource)]).create();
+ test("errors if --dry-run and --machine are both passed", () async {
+ await d.dir("code", [d.file("a.dart", unformattedSource)]).create();
- var process = runFormatterOnDir(["--dry-run", "--machine"]);
- process.shouldExit(64);
+ var process = await runFormatterOnDir(["--dry-run", "--machine"]);
+ await process.shouldExit(64);
});
- test("errors if --machine and --overwrite are both passed", () {
- d.dir("code", [d.file("a.dart", unformattedSource)]).create();
+ test("errors if --machine and --overwrite are both passed", () async {
+ await d.dir("code", [d.file("a.dart", unformattedSource)]).create();
- var process = runFormatterOnDir(["--machine", "--overwrite"]);
- process.shouldExit(64);
+ var process = await runFormatterOnDir(["--machine", "--overwrite"]);
+ await process.shouldExit(64);
});
- test("errors if --dry-run and --machine are both passed", () {
- d.dir("code", [d.file("a.dart", unformattedSource)]).create();
+ test("errors if --dry-run and --machine are both passed", () async {
+ await d.dir("code", [d.file("a.dart", unformattedSource)]).create();
- var process = runFormatter(["--dry-run", "--machine"]);
- process.shouldExit(64);
+ var process = await runFormatter(["--dry-run", "--machine"]);
+ await process.shouldExit(64);
});
- test("errors if --machine and --overwrite are both passed", () {
- d.dir("code", [d.file("a.dart", unformattedSource)]).create();
+ test("errors if --machine and --overwrite are both passed", () async {
+ await d.dir("code", [d.file("a.dart", unformattedSource)]).create();
- var process = runFormatter(["--machine", "--overwrite"]);
- process.shouldExit(64);
+ var process = await runFormatter(["--machine", "--overwrite"]);
+ await process.shouldExit(64);
});
- test("--version prints the version number", () {
- var process = runFormatter(["--version"]);
+ test("--version prints the version number", () async {
+ var process = await runFormatter(["--version"]);
// Match something roughly semver-like.
- process.stdout.expect(matches(r"\d+\.\d+\.\d+.*"));
- process.shouldExit(0);
+ expect(await process.stdout.next, matches(new RegExp(r"\d+\.\d+\.\d+.*")));
+ await process.shouldExit(0);
});
- test("only prints a hidden directory once", () {
- d.dir('code', [
+ test("only prints a hidden directory once", () async {
+ await d.dir('code', [
d.dir('.skip', [
d.file('a.dart', unformattedSource),
d.file('b.dart', unformattedSource)
])
]).create();
- var process = runFormatterOnDir();
+ var process = await runFormatterOnDir();
- process.stdout.expect(startsWith("Formatting directory"));
- process.stdout.expect("Skipping hidden path ${p.join("code", ".skip")}");
- process.shouldExit();
+ expect(await process.stdout.next, startsWith("Formatting directory"));
+ expect(await process.stdout.next,
+ "Skipping hidden path ${p.join("code", ".skip")}");
+ await process.shouldExit();
});
group("--dry-run", () {
- test("prints names of files that would change", () {
- d.dir("code", [
+ test("prints names of files that would change", () async {
+ await d.dir("code", [
d.file("a_bad.dart", unformattedSource),
d.file("b_good.dart", formattedSource),
d.file("c_bad.dart", unformattedSource),
@@ -105,28 +103,28 @@
var aBad = p.join("code", "a_bad.dart");
var cBad = p.join("code", "c_bad.dart");
- var process = runFormatterOnDir(["--dry-run"]);
+ var process = await runFormatterOnDir(["--dry-run"]);
// The order isn't specified.
- process.stdout.expect(either(aBad, cBad));
- process.stdout.expect(either(aBad, cBad));
- process.shouldExit();
+ expect(await process.stdout.next, anyOf(aBad, cBad));
+ expect(await process.stdout.next, anyOf(aBad, cBad));
+ await process.shouldExit();
});
- test("does not modify files", () {
- d.dir("code", [d.file("a.dart", unformattedSource)]).create();
+ test("does not modify files", () async {
+ await d.dir("code", [d.file("a.dart", unformattedSource)]).create();
- var process = runFormatterOnDir(["--dry-run"]);
- process.stdout.expect(p.join("code", "a.dart"));
- process.shouldExit();
+ var process = await runFormatterOnDir(["--dry-run"]);
+ expect(await process.stdout.next, p.join("code", "a.dart"));
+ await process.shouldExit();
- d.dir('code', [d.file('a.dart', unformattedSource)]).validate();
+ await d.dir('code', [d.file('a.dart', unformattedSource)]).validate();
});
});
group("--machine", () {
- test("writes each output as json", () {
- d.dir("code", [
+ test("writes each output as json", () async {
+ await d.dir("code", [
d.file("a.dart", unformattedSource),
d.file("b.dart", unformattedSource)
]).create();
@@ -143,38 +141,39 @@
"selection": {"offset": -1, "length": -1}
});
- var process = runFormatterOnDir(["--machine"]);
+ var process = await runFormatterOnDir(["--machine"]);
// The order isn't specified.
- process.stdout.expect(either(jsonA, jsonB));
- process.stdout.expect(either(jsonA, jsonB));
- process.shouldExit();
+
+ expect(await process.stdout.next, anyOf(jsonA, jsonB));
+ expect(await process.stdout.next, anyOf(jsonA, jsonB));
+ await process.shouldExit();
});
});
group("--preserve", () {
- test("errors if given paths", () {
- var process = runFormatter(["--preserve", "path", "another"]);
- process.shouldExit(64);
+ test("errors if given paths", () async {
+ var process = await runFormatter(["--preserve", "path", "another"]);
+ await process.shouldExit(64);
});
- test("errors on wrong number of components", () {
- var process = runFormatter(["--preserve", "1"]);
- process.shouldExit(64);
+ test("errors on wrong number of components", () async {
+ var process = await runFormatter(["--preserve", "1"]);
+ await process.shouldExit(64);
- process = runFormatter(["--preserve", "1:2:3"]);
- process.shouldExit(64);
+ process = await runFormatter(["--preserve", "1:2:3"]);
+ await process.shouldExit(64);
});
- test("errors on non-integer component", () {
- var process = runFormatter(["--preserve", "1:2.3"]);
- process.shouldExit(64);
+ test("errors on non-integer component", () async {
+ var process = await runFormatter(["--preserve", "1:2.3"]);
+ await process.shouldExit(64);
});
- test("updates selection", () {
- var process = runFormatter(["--preserve", "6:10", "-m"]);
- process.writeLine(unformattedSource);
- process.closeStdin();
+ test("updates selection", () async {
+ var process = await runFormatter(["--preserve", "6:10", "-m"]);
+ process.stdin.writeln(unformattedSource);
+ await process.stdin.close();
var json = JSON.encode({
"path": "<stdin>",
@@ -182,78 +181,79 @@
"selection": {"offset": 5, "length": 9}
});
- process.stdout.expect(json);
- process.shouldExit();
+ expect(await process.stdout.next, json);
+ await process.shouldExit();
});
});
group("--indent", () {
- test("sets the leading indentation of the output", () {
- var process = runFormatter(["--indent", "3"]);
- process.writeLine("main() {'''");
- process.writeLine("a flush left multi-line string''';}");
- process.closeStdin();
+ test("sets the leading indentation of the output", () async {
+ var process = await runFormatter(["--indent", "3"]);
+ process.stdin.writeln("main() {'''");
+ process.stdin.writeln("a flush left multi-line string''';}");
+ await process.stdin.close();
- process.stdout.expect(" main() {");
- process.stdout.expect(" '''");
- process.stdout.expect("a flush left multi-line string''';");
- process.stdout.expect(" }");
- process.shouldExit(0);
+ expect(await process.stdout.next, " main() {");
+ expect(await process.stdout.next, " '''");
+ expect(await process.stdout.next, "a flush left multi-line string''';");
+ expect(await process.stdout.next, " }");
+ await process.shouldExit(0);
});
- test("errors if the indent is not a non-negative number", () {
- var process = runFormatter(["--indent", "notanum"]);
- process.shouldExit(64);
+ test("errors if the indent is not a non-negative number", () async {
+ var process = await runFormatter(["--indent", "notanum"]);
+ await process.shouldExit(64);
- process = runFormatter(["--preserve", "-4"]);
- process.shouldExit(64);
+ process = await runFormatter(["--preserve", "-4"]);
+ await process.shouldExit(64);
});
});
group("--set-exit-if-changed", () {
- test("gives exit code 0 if there are no changes", () {
- d.dir("code", [d.file("a.dart", formattedSource)]).create();
+ test("gives exit code 0 if there are no changes", () async {
+ await d.dir("code", [d.file("a.dart", formattedSource)]).create();
- var process = runFormatterOnDir(["--set-exit-if-changed"]);
- process.shouldExit(0);
+ var process = await runFormatterOnDir(["--set-exit-if-changed"]);
+ await process.shouldExit(0);
});
- test("gives exit code 1 if there are changes", () {
- d.dir("code", [d.file("a.dart", unformattedSource)]).create();
+ test("gives exit code 1 if there are changes", () async {
+ await d.dir("code", [d.file("a.dart", unformattedSource)]).create();
- var process = runFormatterOnDir(["--set-exit-if-changed"]);
- process.shouldExit(1);
+ var process = await runFormatterOnDir(["--set-exit-if-changed"]);
+ await process.shouldExit(1);
});
- test("gives exit code 1 if there are changes even in dry run", () {
- d.dir("code", [d.file("a.dart", unformattedSource)]).create();
+ test("gives exit code 1 if there are changes even in dry run", () async {
+ await d.dir("code", [d.file("a.dart", unformattedSource)]).create();
- var process = runFormatterOnDir(["--set-exit-if-changed", "--dry-run"]);
- process.shouldExit(1);
+ var process =
+ await runFormatterOnDir(["--set-exit-if-changed", "--dry-run"]);
+ await process.shouldExit(1);
});
});
group("with no paths", () {
- test("errors on --overwrite", () {
- var process = runFormatter(["--overwrite"]);
- process.shouldExit(64);
+ test("errors on --overwrite", () async {
+ var process = await runFormatter(["--overwrite"]);
+ await process.shouldExit(64);
});
- test("exits with 65 on parse error", () {
- var process = runFormatter();
- process.writeLine("herp derp i are a dart");
- process.closeStdin();
- process.shouldExit(65);
+ test("exits with 65 on parse error", () async {
+ var process = await runFormatter();
+ process.stdin.writeln("herp derp i are a dart");
+ await process.stdin.close();
+ await process.shouldExit(65);
});
- test("reads from stdin", () {
- var process = runFormatter();
- process.writeLine(unformattedSource);
- process.closeStdin();
+ test("reads from stdin", () async {
+ var process = await runFormatter();
+ process.stdin.writeln(unformattedSource);
+ await process.stdin.close();
// No trailing newline at the end.
- process.stdout.expect(formattedSource.trimRight());
- process.shouldExit(0);
+ expect(await process.stdout.next, formattedSource.trimRight());
+ await process.shouldExit(0);
});
});
}
diff --git a/test/io_test.dart b/test/io_test.dart
index 1f8f011..acecf1b 100644
--- a/test/io_test.dart
+++ b/test/io_test.dart
@@ -9,118 +9,99 @@
import 'package:dart_style/src/io.dart';
import 'package:path/path.dart' as p;
-import 'package:scheduled_test/descriptor.dart' as d;
-import 'package:scheduled_test/scheduled_test.dart';
+import 'package:test_descriptor/test_descriptor.dart' as d;
+import 'package:test/test.dart';
import 'package:dart_style/src/formatter_options.dart';
import 'utils.dart';
void main() {
- setUpTestSuite();
-
var overwriteOptions = new FormatterOptions(OutputReporter.overwrite);
var followOptions =
new FormatterOptions(OutputReporter.overwrite, followLinks: true);
- test('handles directory ending in ".dart"', () {
- d.dir('code.dart', [
+ test('handles directory ending in ".dart"', () async {
+ await d.dir('code.dart', [
d.file('a.dart', unformattedSource),
]).create();
- schedule(() {
- var dir = new Directory(d.defaultRoot);
- processDirectory(overwriteOptions, dir);
- }, 'Run formatter.');
+ var dir = new Directory(d.sandbox);
+ processDirectory(overwriteOptions, dir);
- d.dir('code.dart', [
+ await d.dir('code.dart', [
d.file('a.dart', formattedSource),
]).validate();
});
- test("doesn't touch unchanged files", () {
- d.dir('code', [
+ test("doesn't touch unchanged files", () async {
+ await d.dir('code', [
d.file('bad.dart', unformattedSource),
d.file('good.dart', formattedSource),
]).create();
- modTime(String file) {
- return new File(p.join(d.defaultRoot, 'code', file)).statSync().modified;
- }
+ DateTime modTime(String file) =>
+ new File(p.join(d.sandbox, 'code', file)).statSync().modified;
- var badBefore;
- var goodBefore;
+ var badBefore = modTime('bad.dart');
+ var goodBefore = modTime('good.dart');
- schedule(() {
- badBefore = modTime('bad.dart');
- goodBefore = modTime('good.dart');
+ // Wait a bit so the mod time of a formatted file will be different.
+ await new Future.delayed(new Duration(seconds: 1));
- // Wait a bit so the mod time of a formatted file will be different.
- return new Future.delayed(new Duration(seconds: 1));
- });
+ var dir = new Directory(p.join(d.sandbox, 'code'));
+ processDirectory(overwriteOptions, dir);
- schedule(() {
- var dir = new Directory(p.join(d.defaultRoot, 'code'));
- processDirectory(overwriteOptions, dir);
+ // Should be touched.
+ var badAfter = modTime('bad.dart');
+ expect(badAfter, isNot(equals(badBefore)));
- // Should be touched.
- var badAfter = modTime('bad.dart');
- expect(badAfter, isNot(equals(badBefore)));
-
- // Should not be touched.
- var goodAfter = modTime('good.dart');
- expect(goodAfter, equals(goodBefore));
- });
+ // Should not be touched.
+ var goodAfter = modTime('good.dart');
+ expect(goodAfter, equals(goodBefore));
});
- test("skips subdirectories whose name starts with '.'", () {
- d.dir('code', [
+ test("skips subdirectories whose name starts with '.'", () async {
+ await d.dir('code', [
d.dir('.skip', [d.file('a.dart', unformattedSource)])
]).create();
- schedule(() {
- var dir = new Directory(d.defaultRoot);
- processDirectory(overwriteOptions, dir);
- }, 'Run formatter.');
+ var dir = new Directory(d.sandbox);
+ processDirectory(overwriteOptions, dir);
- d.dir('code', [
+ await d.dir('code', [
d.dir('.skip', [d.file('a.dart', unformattedSource)])
]).validate();
});
- test("traverses the given directory even if its name starts with '.'", () {
- d.dir('.code', [d.file('a.dart', unformattedSource)]).create();
+ test("traverses the given directory even if its name starts with '.'",
+ () async {
+ await d.dir('.code', [d.file('a.dart', unformattedSource)]).create();
- schedule(() {
- var dir = new Directory(p.join(d.defaultRoot, '.code'));
- processDirectory(overwriteOptions, dir);
- }, 'Run formatter.');
+ var dir = new Directory(p.join(d.sandbox, '.code'));
+ processDirectory(overwriteOptions, dir);
- d.dir('.code', [d.file('a.dart', formattedSource)]).validate();
+ await d.dir('.code', [d.file('a.dart', formattedSource)]).validate();
});
- test("doesn't follow directory symlinks by default", () {
- d.dir('code', [
+ test("doesn't follow directory symlinks by default", () async {
+ await d.dir('code', [
d.file('a.dart', unformattedSource),
]).create();
- d.dir('target_dir', [
+ await d.dir('target_dir', [
d.file('b.dart', unformattedSource),
]).create();
- schedule(() {
- // Create a link to the target directory in the code directory.
- new Link(p.join(d.defaultRoot, 'code', 'linked_dir'))
- .createSync(p.join(d.defaultRoot, 'target_dir'));
- }, 'Create symlinks.');
+ // Create a link to the target directory in the code directory.
+ new Link(p.join(d.sandbox, 'code', 'linked_dir'))
+ .createSync(p.join(d.sandbox, 'target_dir'));
- schedule(() {
- var dir = new Directory(p.join(d.defaultRoot, 'code'));
- processDirectory(overwriteOptions, dir);
- }, 'Run formatter.');
+ var dir = new Directory(p.join(d.sandbox, 'code'));
+ processDirectory(overwriteOptions, dir);
- d.dir('code', [
+ await d.dir('code', [
d.file('a.dart', formattedSource),
d.dir('linked_dir', [
d.file('b.dart', unformattedSource),
@@ -128,27 +109,23 @@
]).validate();
});
- test("follows directory symlinks when 'followLinks' is true", () {
- d.dir('code', [
+ test("follows directory symlinks when 'followLinks' is true", () async {
+ await d.dir('code', [
d.file('a.dart', unformattedSource),
]).create();
- d.dir('target_dir', [
+ await d.dir('target_dir', [
d.file('b.dart', unformattedSource),
]).create();
- schedule(() {
- // Create a link to the target directory in the code directory.
- new Link(p.join(d.defaultRoot, 'code', 'linked_dir'))
- .createSync(p.join(d.defaultRoot, 'target_dir'));
- });
+ // Create a link to the target directory in the code directory.
+ new Link(p.join(d.sandbox, 'code', 'linked_dir'))
+ .createSync(p.join(d.sandbox, 'target_dir'));
- schedule(() {
- var dir = new Directory(p.join(d.defaultRoot, 'code'));
- processDirectory(followOptions, dir);
- }, 'running formatter');
+ var dir = new Directory(p.join(d.sandbox, 'code'));
+ processDirectory(followOptions, dir);
- d.dir('code', [
+ await d.dir('code', [
d.file('a.dart', formattedSource),
d.dir('linked_dir', [
d.file('b.dart', formattedSource),
@@ -159,58 +136,46 @@
if (!Platform.isWindows) {
// TODO(rnystrom): Figure out Windows equivalent of chmod and get this
// test running on Windows too.
- test("reports error if file can not be written", () {
- d.file('a.dart', unformattedSource).create();
+ test("reports error if file can not be written", () async {
+ await d.file('a.dart', unformattedSource).create();
- schedule(() {
- Process.runSync("chmod", ["-w", p.join(d.defaultRoot, 'a.dart')]);
- }, 'Make file read-only.');
+ Process.runSync("chmod", ["-w", p.join(d.sandbox, 'a.dart')]);
- schedule(() {
- var file = new File(p.join(d.defaultRoot, 'a.dart'));
- processFile(overwriteOptions, file);
- }, 'Run formatter.');
+ var file = new File(p.join(d.sandbox, 'a.dart'));
+ processFile(overwriteOptions, file);
// Should not have been formatted.
- d.file('a.dart', unformattedSource).validate();
+ await d.file('a.dart', unformattedSource).validate();
});
- test("doesn't follow file symlinks by default", () {
- d.dir('code').create();
- d.file('target_file.dart', unformattedSource).create();
+ test("doesn't follow file symlinks by default", () async {
+ await d.dir('code').create();
+ await d.file('target_file.dart', unformattedSource).create();
- schedule(() {
- // Create a link to the target file in the code directory.
- new Link(p.join(d.defaultRoot, 'code', 'linked_file.dart'))
- .createSync(p.join(d.defaultRoot, 'target_file.dart'));
- }, 'Create symlinks.');
+ // Create a link to the target file in the code directory.
+ new Link(p.join(d.sandbox, 'code', 'linked_file.dart'))
+ .createSync(p.join(d.sandbox, 'target_file.dart'));
- schedule(() {
- var dir = new Directory(p.join(d.defaultRoot, 'code'));
- processDirectory(overwriteOptions, dir);
- }, 'Run formatter.');
+ var dir = new Directory(p.join(d.sandbox, 'code'));
+ processDirectory(overwriteOptions, dir);
- d.dir('code', [
+ await d.dir('code', [
d.file('linked_file.dart', unformattedSource),
]).validate();
});
- test("follows file symlinks when 'followLinks' is true", () {
- d.dir('code').create();
- d.file('target_file.dart', unformattedSource).create();
+ test("follows file symlinks when 'followLinks' is true", () async {
+ await d.dir('code').create();
+ await d.file('target_file.dart', unformattedSource).create();
- schedule(() {
- // Create a link to the target file in the code directory.
- new Link(p.join(d.defaultRoot, 'code', 'linked_file.dart'))
- .createSync(p.join(d.defaultRoot, 'target_file.dart'));
- });
+ // Create a link to the target file in the code directory.
+ new Link(p.join(d.sandbox, 'code', 'linked_file.dart'))
+ .createSync(p.join(d.sandbox, 'target_file.dart'));
- schedule(() {
- var dir = new Directory(p.join(d.defaultRoot, 'code'));
- processDirectory(followOptions, dir);
- }, 'running formatter');
+ var dir = new Directory(p.join(d.sandbox, 'code'));
+ processDirectory(followOptions, dir);
- d.dir('code', [
+ await d.dir('code', [
d.file('linked_file.dart', formattedSource),
]).validate();
});
diff --git a/test/utils.dart b/test/utils.dart
index 2ebf406..abd84ca 100644
--- a/test/utils.dart
+++ b/test/utils.dart
@@ -4,19 +4,19 @@
library dart_style.test.utils;
+import 'dart:async';
import 'dart:io';
import 'dart:mirrors';
import 'package:path/path.dart' as p;
-import 'package:scheduled_test/descriptor.dart' as d;
-import 'package:scheduled_test/scheduled_process.dart';
-import 'package:scheduled_test/scheduled_test.dart';
+import 'package:test_descriptor/test_descriptor.dart' as d;
+import 'package:test_process/test_process.dart';
const unformattedSource = 'void main() => print("hello") ;';
const formattedSource = 'void main() => print("hello");\n';
/// Runs the command line formatter, passing it [args].
-ScheduledProcess runFormatter([List<String> args]) {
+Future<TestProcess> runFormatter([List<String> args]) {
if (args == null) args = [];
// Locate the "test" directory. Use mirrors so that this works with the test
@@ -38,29 +38,12 @@
args.insert(0, "--packages=${Platform.packageConfig}");
}
- return new ScheduledProcess.start(Platform.executable, args);
+ return TestProcess.start(Platform.executable, args);
}
/// Runs the command line formatter, passing it the test directory followed by
/// [args].
-ScheduledProcess runFormatterOnDir([List<String> args]) {
+Future<TestProcess> runFormatterOnDir([List<String> args]) {
if (args == null) args = [];
- return runFormatter([d.defaultRoot]..addAll(args));
-}
-
-/// Set up the scheduled test suite.
-///
-/// Configures the unit test output and makes a sandbox directory for the
-/// scheduled tests to run in.
-void setUpTestSuite() {
- // Make a sandbox directory for the scheduled tests to run in.
- setUp(() {
- var tempDir = Directory.systemTemp.createTempSync('dart_style.test.');
- d.defaultRoot = tempDir.path;
-
- currentSchedule.onComplete.schedule(() {
- d.defaultRoot = null;
- return tempDir.delete(recursive: true);
- });
- });
+ return runFormatter([d.sandbox]..addAll(args));
}