@@ -2835,6 +2835,55 @@ public void testInstrumentCodeProductionArrayArgNotSet() {
2835
2835
+ "--instrument_for_coverage_option is set to Production" );
2836
2836
}
2837
2837
2838
+ @ Test
2839
+ public void testBundleOutput_bundlesGoogModule () throws IOException {
2840
+ // Create a path for the final output
2841
+ File bundledFile = temporaryFolder .newFile ("bundle.js" );
2842
+
2843
+ FlagEntry <JsSourceType > jsFile1 = createJsFile ("test1" , "var a;" );
2844
+ FlagEntry <JsSourceType > jsFile2 = createJsFile ("test2" , "goog.module('foo'); var b;" );
2845
+
2846
+ args .add ("--compilation_level=BUNDLE" );
2847
+ args .add ("--dependency_mode=NONE" );
2848
+ args .add ("--js_output_file" );
2849
+ args .add (bundledFile .getPath ());
2850
+
2851
+ compileJsFiles ("" , jsFile1 , jsFile2 );
2852
+
2853
+ String bundledJs = java .nio .file .Files .readString (bundledFile .toPath ());
2854
+ String expected =
2855
+ lines (
2856
+ "//" + jsFile1 .getValue (),
2857
+ "var a;" ,
2858
+ "//" + jsFile2 .getValue (),
2859
+ "goog.loadModule(function(exports) {'use strict';goog.module('foo'); var b;" ,
2860
+ ";return exports;});" ,
2861
+ "\n " );
2862
+ assertThat (bundledJs ).isEqualTo (expected );
2863
+ }
2864
+
2865
+ @ Test
2866
+ public void testBundleOutput_ignoresSyntaxErrors () throws IOException {
2867
+ // Verify that if bundling, the compiler doesn't run a full parse and thus doesn't report
2868
+ // syntax errors.
2869
+
2870
+ // Create a path for the final output
2871
+ File bundledFile = temporaryFolder .newFile ("bundle.js" );
2872
+
2873
+ FlagEntry <JsSourceType > jsFile = createJsFile ("test1" , "var a; syntax error!" );
2874
+
2875
+ args .add ("--compilation_level=BUNDLE" );
2876
+ args .add ("--dependency_mode=NONE" );
2877
+ args .add ("--js_output_file" );
2878
+ args .add (bundledFile .getPath ());
2879
+
2880
+ compileJsFiles ("" , jsFile );
2881
+
2882
+ String bundledJs = java .nio .file .Files .readString (bundledFile .toPath ());
2883
+ String expected = lines ("//" + jsFile .getValue (), "var a; syntax error!\n " );
2884
+ assertThat (bundledJs ).isEqualTo (expected );
2885
+ }
2886
+
2838
2887
@ Rule public TemporaryFolder folder = new TemporaryFolder ();
2839
2888
2840
2889
@ Test
@@ -3278,6 +3327,7 @@ private void compileArgs(String expectedOutput, @Nullable DiagnosticType expecte
3278
3327
assertThat (compiler .getErrors ()).hasSize (1 );
3279
3328
assertError (compiler .getErrors ().get (0 )).hasType (expectedError );
3280
3329
}
3330
+ lastCommandLineRunner = runner ;
3281
3331
}
3282
3332
3283
3333
private String compile (String inputString , List <String > args ) {
0 commit comments