Skip to content

Commit 15233c6

Browse files
authored
chore: simplify, skip fast fail test if cpus < 2 (#11336)
* chore: simplify, skip fast fail test if cpus < 2 * use std
1 parent ead9577 commit 15233c6

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

crates/forge/tests/cli/config.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use std::{
2626
fs,
2727
path::{Path, PathBuf},
2828
str::FromStr,
29+
thread,
2930
};
3031

3132
// tests all config values that are in use
@@ -1881,41 +1882,29 @@ forgetest_init!(test_exclude_lints_config, |prj, cmd| {
18811882

18821883
// <https://github.com/foundry-rs/foundry/issues/6529>
18831884
forgetest_init!(test_fail_fast_config, |prj, cmd| {
1885+
// Skip if we don't have at least 2 CPUs to run both tests in parallel.
1886+
if thread::available_parallelism().map_or(1, |n| n.get()) < 2 {
1887+
return;
1888+
}
1889+
1890+
prj.wipe_contracts();
18841891
prj.update_config(|config| {
18851892
// Set large timeout for fuzzed tests so test campaign won't stop if fail fast not passed.
18861893
config.fuzz.timeout = Some(3600);
1887-
config.invariant.timeout = Some(3600);
18881894
});
18891895
prj.add_test(
18901896
"AnotherCounterTest.sol",
18911897
r#"
18921898
import {Test} from "forge-std/Test.sol";
18931899
1894-
contract InvariantHandler is Test {
1895-
function fuzz_selector(uint256 x) public {
1896-
}
1897-
}
1898-
18991900
contract AnotherCounterTest is Test {
1900-
uint256[] public fixtureAmount = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
1901-
1902-
function setUp() public {
1903-
new InvariantHandler();
1904-
}
19051901
// This failure should stop all other tests.
19061902
function test_Failure() public pure {
19071903
require(false);
19081904
}
19091905
19101906
function testFuzz_SetNumber(uint256 x) public {
19111907
}
1912-
1913-
function invariant_SetNumber() public {
1914-
}
1915-
1916-
function table_SetNumber(uint256 amount) public {
1917-
require(amount < 100);
1918-
}
19191908
}
19201909
"#,
19211910
)

0 commit comments

Comments
 (0)