@@ -292,11 +292,22 @@ func formatNewBaseline(
292292}
293293
294294func (f commandLineSubScenario ) assertBuildParseResult (t * testing.T ) {
295+ t .Helper ()
296+ f .assertBuildParseResultWithTsBaseline (t , func () * TestCommandLineParserBuild {
297+ originalBaseline := f .baseline .ReadFile (t )
298+ return parseExistingCompilerBaselineBuild (t , originalBaseline )
299+ })
300+ }
301+
302+ func (f commandLineSubScenario ) assertBuildParseResultWithTsBaseline (t * testing.T , getTsBaseline func () * TestCommandLineParserBuild ) {
295303 t .Helper ()
296304 t .Run (f .testName , func (t * testing.T ) {
297305 t .Parallel ()
298- originalBaseline := f .baseline .ReadFile (t )
299- tsBaseline := parseExistingCompilerBaselineBuild (t , originalBaseline )
306+
307+ var tsBaseline * TestCommandLineParserBuild
308+ if getTsBaseline != nil {
309+ tsBaseline = getTsBaseline ()
310+ }
300311
301312 // f.workerDiagnostic is either defined or set to default pointer in `createSubScenario`
302313 parsed := tsoptions .ParseBuildCommandLine (f .commandLine , & tsoptionstest.VfsParseConfigHost {
@@ -305,19 +316,25 @@ func (f commandLineSubScenario) assertBuildParseResult(t *testing.T) {
305316 })
306317
307318 newBaselineProjects := strings .Join (parsed .Projects , "," )
308- assert .Equal (t , tsBaseline .projects , newBaselineProjects )
319+ if getTsBaseline != nil {
320+ assert .Equal (t , tsBaseline .projects , newBaselineProjects )
321+ }
309322
310323 o , _ := json .Marshal (parsed .BuildOptions )
311324 newParsedBuildOptions := & core.BuildOptions {}
312325 e := json .Unmarshal (o , newParsedBuildOptions )
313326 assert .NilError (t , e )
314- assert .DeepEqual (t , tsBaseline .options , newParsedBuildOptions , cmpopts .IgnoreUnexported (core.BuildOptions {}))
327+ if getTsBaseline != nil {
328+ assert .DeepEqual (t , tsBaseline .options , newParsedBuildOptions , cmpopts .IgnoreUnexported (core.BuildOptions {}))
329+ }
315330
316331 compilerOpts , _ := json .Marshal (parsed .CompilerOptions )
317332 newParsedCompilerOptions := & core.CompilerOptions {}
318333 e = json .Unmarshal (compilerOpts , newParsedCompilerOptions )
319334 assert .NilError (t , e )
320- assert .DeepEqual (t , tsBaseline .compilerOptions , newParsedCompilerOptions , cmpopts .IgnoreUnexported (core.CompilerOptions {}))
335+ if getTsBaseline != nil {
336+ assert .DeepEqual (t , tsBaseline .compilerOptions , newParsedCompilerOptions , cmpopts .IgnoreUnexported (core.CompilerOptions {}))
337+ }
321338
322339 newParsedWatchOptions := core.WatchOptions {}
323340 e = json .Unmarshal (o , & newParsedWatchOptions )
@@ -478,6 +495,18 @@ func TestParseBuildCommandLine(t *testing.T) {
478495 for _ , testCase := range parseCommandLineSubScenarios {
479496 testCase .createSubScenario ("parseBuildOptions" ).assertBuildParseResult (t )
480497 }
498+
499+ extraScenarios := []* subScenarioInput {
500+ {`parse --builders` , []string {"--builders" , "2" }},
501+ {`--singleThreaded and --builders together` , []string {"--singleThreaded" , "--builders" , "2" }},
502+ {`reports error when --builders is 0` , []string {"--builders" , "0" }},
503+ {`reports error when --builders is negative` , []string {"--builders" , "-1" }},
504+ {`reports error when --builders is invalid type` , []string {"--builders" , "invalid" }},
505+ }
506+
507+ for _ , testCase := range extraScenarios {
508+ testCase .createSubScenario ("parseBuildOptions" ).assertBuildParseResultWithTsBaseline (t , nil )
509+ }
481510}
482511
483512func TestAffectsBuildInfo (t * testing.T ) {
0 commit comments