1- // Copyright 2024 Martin Pool
1+ // Copyright 2024-2025 Martin Pool
22
33//! Integration tests for cargo mutants calling nextest.
44
5+ use std:: fs:: { create_dir, write} ;
6+
57use predicates:: prelude:: * ;
8+ use tempfile:: TempDir ;
69
710mod util;
811use util:: { copy_of_testdata, run} ;
@@ -27,3 +30,57 @@ fn test_with_nextest_on_small_tree() {
2730 String :: from_utf8_lossy( & assert. get_output( ) . stdout)
2831 ) ;
2932}
33+
34+ #[ test]
35+ fn unexpected_nextest_error_code_causes_a_warning ( ) {
36+ let temp = TempDir :: new ( ) . unwrap ( ) ;
37+ let path = temp. path ( ) ;
38+ write (
39+ path. join ( "Cargo.toml" ) ,
40+ r#"[package]
41+ name = "cargo-mutants-test"
42+ version = "0.1.0"
43+ publish = false
44+ "# ,
45+ )
46+ . unwrap ( ) ;
47+ create_dir ( path. join ( "src" ) ) . unwrap ( ) ;
48+ write (
49+ path. join ( "src/main.rs" ) ,
50+ r#"fn main() {
51+ println!("{}", 1 + 2);
52+ }"# ,
53+ )
54+ . unwrap ( ) ;
55+ create_dir ( path. join ( ".config" ) ) . unwrap ( ) ;
56+ write (
57+ path. join ( ".config/nextest.toml" ) ,
58+ r#"nextest-version = { required = "9999.0.0" }"# ,
59+ )
60+ . unwrap ( ) ;
61+
62+ let assert = run ( )
63+ . args ( [
64+ "mutants" ,
65+ "--test-tool" ,
66+ "nextest" ,
67+ "-vV" ,
68+ "--no-shuffle" ,
69+ "-Ldebug" ,
70+ ] )
71+ . arg ( "-d" )
72+ . arg ( temp. path ( ) )
73+ . assert ( )
74+ . stderr ( predicates:: str:: contains (
75+ "nextest process exited with unexpected code (allowed: [4, 100, 101]) code=92" ,
76+ ) )
77+ . code ( 4 ) ; // CLEAN_TESTS_FAILED
78+ println ! (
79+ "stdout:\n {}" ,
80+ String :: from_utf8_lossy( & assert. get_output( ) . stdout)
81+ ) ;
82+ println ! (
83+ "stderr:\n {}" ,
84+ String :: from_utf8_lossy( & assert. get_output( ) . stderr)
85+ ) ;
86+ }
0 commit comments