@@ -23,53 +23,36 @@ void main() {
2323  setUpAll (precompileTestExecutable);
2424
2525  group ('browser tests' , () {
26-     setUp (() async  {
27-       await  d.file ('to_precompile.dart' , ''' 
28-         import "package:test/bootstrap/browser.dart"; 
29-         import "package:test/test.dart"; 
30- 
31-         main(_) { 
32-           internalBootstrapBrowserTest(() => () => test("success", () {})); 
33-         } 
34-       ''' ).create ();
35- 
36-       await  d.dir ('precompiled' , [
37-         d.file ('test.html' , ''' 
38-           <!DOCTYPE html> 
39-           <html> 
40-           <head> 
41-             <title>test Test</title> 
42-             <script src="test.dart.browser_test.dart.js"></script> 
43-           </head> 
44-           </html> 
45-         ''' )
46-       ]).create ();
47- 
48-       var  dart2js =  await  TestProcess .start (
49-           Platform .resolvedExecutable,
50-           [
51-             'compile' ,
52-             'js' ,
53-             ...Platform .executableArguments,
54-             '--packages=${(await  Isolate .packageConfig )!.toFilePath ()}' ,
55-             'to_precompile.dart' ,
56-             '--out=precompiled/test.dart.browser_test.dart.js' 
57-           ],
58-           workingDirectory:  d.sandbox);
59-       await  dart2js.shouldExit (0 );
60- 
61-       await  d.file ('test.dart' , 'invalid dart}' ).create ();
26+     setUpAll (() async  {
27+       await  _precompileBrowserTest ('test.dart' );
6228    });
6329
6430    test ('run a precompiled version of a test rather than recompiling' ,
6531        () async  {
66-       var  test =  await  runTest (
67-           ['-p' , 'chrome' , '--precompiled=precompiled/' , 'test.dart' ]);
32+       var  test =  await  runTest ([
33+         '-p' ,
34+         'chrome' ,
35+         '--precompiled=precompiled/' ,
36+         'test.dart' ,
37+       ]);
6838      expect (test.stdout,
6939          containsInOrder (['+0: success' , '+1: All tests passed!' ]));
7040      await  test.shouldExit (0 );
7141    });
7242
43+     test ('run two precompiled tests' , () async  {
44+       await  _precompileBrowserTest ('test_2.dart' );
45+       var  test =  await  runTest ([
46+         '-p' ,
47+         'chrome' ,
48+         '--precompiled=precompiled/' ,
49+         'test.dart' ,
50+         'test_2.dart' ,
51+       ]);
52+       expect (test.stdout, containsInOrder (['+2: All tests passed!' ]));
53+       await  test.shouldExit (0 );
54+     });
55+ 
7356    test ('can use the json reporter' , () async  {
7457      var  test =  await  runTest ([
7558        '-p' ,
@@ -239,3 +222,43 @@ Future<void> _writePackagesFile() async {
239222  await  d.dir ('.dart_tool' ).create ();
240223  await  savePackageConfig (config, Directory (d.sandbox));
241224}
225+ 
226+ Future <void > _precompileBrowserTest (String  testPath) async  {
227+   var  tmpDir =  await  Directory .systemTemp.createTemp ('browser_test' );
228+   var  file =  File .fromUri (tmpDir.uri.resolve ('precompiled.dart' ));
229+   await  file.writeAsString (''' 
230+         import "package:test/bootstrap/browser.dart"; 
231+         import "package:test/test.dart"; 
232+ 
233+         main(_) { 
234+           internalBootstrapBrowserTest(() => () => test("success", () {})); 
235+         } 
236+       ''' );
237+ 
238+   await  d.dir ('precompiled' , [
239+     d.file (p.setExtension (testPath, 'html' ), ''' 
240+           <!DOCTYPE html> 
241+           <html> 
242+           <head> 
243+             <title>test Test</title> 
244+             <script src="$testPath .browser_test.dart.js"></script> 
245+           </head> 
246+           </html> 
247+         ''' )
248+   ]).create ();
249+ 
250+   var  dart2js =  await  TestProcess .start (
251+       Platform .resolvedExecutable,
252+       [
253+         'compile' ,
254+         'js' ,
255+         ...Platform .executableArguments,
256+         '--packages=${(await  Isolate .packageConfig )!.toFilePath ()}' ,
257+         file.path,
258+         '--out=precompiled/$testPath .browser_test.dart.js' 
259+       ],
260+       workingDirectory:  d.sandbox);
261+   await  dart2js.shouldExit (0 );
262+ 
263+   await  d.file (testPath, 'invalid dart}' ).create ();
264+ }
0 commit comments