@@ -352,3 +352,61 @@ fn parse_rust_std_features_empty() {
352352fn parse_rust_std_features_invalid ( ) {
353353 parse ( "rust.std-features = \" backtrace\" " ) ;
354354}
355+
356+ #[ test]
357+ fn parse_jobs ( ) {
358+ assert_eq ! ( parse( "build.jobs = 1" ) . jobs, Some ( 1 ) ) ;
359+ }
360+
361+ #[ test]
362+ fn jobs_precedence ( ) {
363+ // `--jobs` should take precedence over using `--set build.jobs`.
364+
365+ let config = Config :: parse_inner (
366+ Flags :: parse ( & [
367+ "check" . to_owned ( ) ,
368+ "--config=/does/not/exist" . to_owned ( ) ,
369+ "--jobs=67890" . to_owned ( ) ,
370+ "--set=build.jobs=12345" . to_owned ( ) ,
371+ ] ) ,
372+ |& _| toml:: from_str ( "" ) ,
373+ ) ;
374+ assert_eq ! ( config. jobs, Some ( 67890 ) ) ;
375+
376+ // `--set build.jobs` should take precedence over `config.toml`.
377+ let config = Config :: parse_inner (
378+ Flags :: parse ( & [
379+ "check" . to_owned ( ) ,
380+ "--config=/does/not/exist" . to_owned ( ) ,
381+ "--set=build.jobs=12345" . to_owned ( ) ,
382+ ] ) ,
383+ |& _| {
384+ toml:: from_str (
385+ r#"
386+ [build]
387+ jobs = 67890
388+ "# ,
389+ )
390+ } ,
391+ ) ;
392+ assert_eq ! ( config. jobs, Some ( 12345 ) ) ;
393+
394+ // `--jobs` > `--set build.jobs` > `config.toml`
395+ let config = Config :: parse_inner (
396+ Flags :: parse ( & [
397+ "check" . to_owned ( ) ,
398+ "--jobs=123" . to_owned ( ) ,
399+ "--config=/does/not/exist" . to_owned ( ) ,
400+ "--set=build.jobs=456" . to_owned ( ) ,
401+ ] ) ,
402+ |& _| {
403+ toml:: from_str (
404+ r#"
405+ [build]
406+ jobs = 789
407+ "# ,
408+ )
409+ } ,
410+ ) ;
411+ assert_eq ! ( config. jobs, Some ( 123 ) ) ;
412+ }
0 commit comments