diff --git a/pkgs/test/test/runner/precompiled_test.dart b/pkgs/test/test/runner/precompiled_test.dart
index 181d68f97..8eb135d55 100644
--- a/pkgs/test/test/runner/precompiled_test.dart
+++ b/pkgs/test/test/runner/precompiled_test.dart
@@ -23,53 +23,36 @@ void main() {
setUpAll(precompileTestExecutable);
group('browser tests', () {
- setUp(() async {
- await d.file('to_precompile.dart', '''
- import "package:test/bootstrap/browser.dart";
- import "package:test/test.dart";
-
- main(_) {
- internalBootstrapBrowserTest(() => () => test("success", () {}));
- }
- ''').create();
-
- await d.dir('precompiled', [
- d.file('test.html', '''
-
-
-
- test Test
-
-
-
- ''')
- ]).create();
-
- var dart2js = await TestProcess.start(
- Platform.resolvedExecutable,
- [
- 'compile',
- 'js',
- ...Platform.executableArguments,
- '--packages=${(await Isolate.packageConfig)!.toFilePath()}',
- 'to_precompile.dart',
- '--out=precompiled/test.dart.browser_test.dart.js'
- ],
- workingDirectory: d.sandbox);
- await dart2js.shouldExit(0);
-
- await d.file('test.dart', 'invalid dart}').create();
+ setUpAll(() async {
+ await _precompileBrowserTest('test.dart');
});
test('run a precompiled version of a test rather than recompiling',
() async {
- var test = await runTest(
- ['-p', 'chrome', '--precompiled=precompiled/', 'test.dart']);
+ var test = await runTest([
+ '-p',
+ 'chrome',
+ '--precompiled=precompiled/',
+ 'test.dart',
+ ]);
expect(test.stdout,
containsInOrder(['+0: success', '+1: All tests passed!']));
await test.shouldExit(0);
});
+ test('run two precompiled tests', () async {
+ await _precompileBrowserTest('test_2.dart');
+ var test = await runTest([
+ '-p',
+ 'chrome',
+ '--precompiled=precompiled/',
+ 'test.dart',
+ 'test_2.dart',
+ ]);
+ expect(test.stdout, containsInOrder(['+2: All tests passed!']));
+ await test.shouldExit(0);
+ });
+
test('can use the json reporter', () async {
var test = await runTest([
'-p',
@@ -239,3 +222,43 @@ Future _writePackagesFile() async {
await d.dir('.dart_tool').create();
await savePackageConfig(config, Directory(d.sandbox));
}
+
+Future _precompileBrowserTest(String testPath) async {
+ var tmpDir = await Directory.systemTemp.createTemp('browser_test');
+ var file = File.fromUri(tmpDir.uri.resolve('precompiled.dart'));
+ await file.writeAsString('''
+ import "package:test/bootstrap/browser.dart";
+ import "package:test/test.dart";
+
+ main(_) {
+ internalBootstrapBrowserTest(() => () => test("success", () {}));
+ }
+ ''');
+
+ await d.dir('precompiled', [
+ d.file(p.setExtension(testPath, 'html'), '''
+
+
+
+ test Test
+
+
+
+ ''')
+ ]).create();
+
+ var dart2js = await TestProcess.start(
+ Platform.resolvedExecutable,
+ [
+ 'compile',
+ 'js',
+ ...Platform.executableArguments,
+ '--packages=${(await Isolate.packageConfig)!.toFilePath()}',
+ file.path,
+ '--out=precompiled/$testPath.browser_test.dart.js'
+ ],
+ workingDirectory: d.sandbox);
+ await dart2js.shouldExit(0);
+
+ await d.file(testPath, 'invalid dart}').create();
+}