File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -2031,3 +2031,46 @@ Warning (2018): Function state mutability can be restricted to pure
20312031"# ,
20322032 ) ;
20332033} ) ;
2034+
2035+ forgetest_init ! ( test_failures_file_normalization, |prj, cmd| {
2036+ // Update config with custom path containing "./" prefix
2037+ prj. update_config( |config| {
2038+ config. test_failures_file = PathBuf :: from( "./my-custom-failures" ) ;
2039+ } ) ;
2040+
2041+ prj. wipe_contracts( ) ;
2042+ prj. add_test(
2043+ "MixedTests.t.sol" ,
2044+ r#"
2045+ import {Test} from "forge-std/Test.sol";
2046+
2047+ contract MixedTests is Test {
2048+ function testPass() public pure {
2049+ require(1 == 1);
2050+ }
2051+
2052+ function testFail() public pure {
2053+ require(1 == 2, "testFail failed");
2054+ }
2055+ }
2056+ "# ,
2057+ ) ;
2058+
2059+ // Run test and verify test_failures_file is created at the correct location
2060+ cmd. args( [ "test" ] ) . assert_failure( ) ;
2061+ let failures_file = prj. root( ) . join( "my-custom-failures" ) ;
2062+ assert!( failures_file. exists( ) ) ;
2063+ assert!( fs:: read_to_string( & failures_file) . unwrap( ) . contains( "testFail" ) ) ;
2064+
2065+ // Verify --rerun works from subdirectory
2066+ let rerun_output = cmd
2067+ . forge_fuse( )
2068+ . current_dir( prj. root( ) . join( "src" ) )
2069+ . args( [ "test" , "--rerun" ] )
2070+ . assert_failure( )
2071+ . get_output( )
2072+ . stdout_lossy( ) ;
2073+ assert!( rerun_output. contains( "Ran 1 test" ) ) ;
2074+ assert!( rerun_output. contains( "testFail()" ) ) ;
2075+ assert!( !rerun_output. contains( "[PASS] testPass()" ) ) ;
2076+ } ) ;
You can’t perform that action at this time.
0 commit comments