Skip to content

Commit def0113

Browse files
committed
Dynamic test linking default enabled
1 parent 0cc772c commit def0113

File tree

4 files changed

+9
-36
lines changed

4 files changed

+9
-36
lines changed

crates/cli/src/opts/build/core.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ pub struct BuildOpts {
3434
#[serde(skip)]
3535
pub no_cache: bool,
3636

37-
/// Enable preprocessed cache for tests
38-
#[arg(long, conflicts_with = "no_cache")]
37+
/// Disable dynamic test linking.
38+
#[arg(long)]
3939
#[serde(skip)]
40-
pub dynamic_test_linking: bool,
40+
pub no_dynamic_test_linking: bool,
4141

4242
/// Set pre-linked libraries.
4343
#[arg(long, help_heading = "Linker options", env = "DAPP_LIBRARIES")]
@@ -250,8 +250,8 @@ impl Provider for BuildOpts {
250250
dict.insert("cache".to_string(), false.into());
251251
}
252252

253-
if self.dynamic_test_linking || self.no_cache {
254-
dict.insert("dynamic_test_linking".to_string(), true.into());
253+
if self.no_dynamic_test_linking || self.no_cache {
254+
dict.insert("dynamic_test_linking".to_string(), false.into());
255255
}
256256

257257
if self.build_info {

crates/config/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2281,7 +2281,7 @@ impl Default for Config {
22812281
out: "out".into(),
22822282
libs: vec!["lib".into()],
22832283
cache: true,
2284-
dynamic_test_linking: false,
2284+
dynamic_test_linking: true,
22852285
cache_path: "cache".into(),
22862286
broadcast: "broadcast".into(),
22872287
snapshots: "snapshots".into(),

crates/forge/tests/cli/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ forgetest!(can_extract_config_values, |prj, cmd| {
4242
out: "out-test".into(),
4343
libs: vec!["lib-test".into()],
4444
cache: true,
45-
dynamic_test_linking: false,
45+
dynamic_test_linking: true,
4646
cache_path: "test-cache".into(),
4747
snapshots: "snapshots".into(),
4848
gas_snapshot_check: false,
@@ -972,7 +972,7 @@ remappings = ["forge-std/=lib/forge-std/src/"]
972972
auto_detect_remappings = true
973973
libraries = []
974974
cache = true
975-
dynamic_test_linking = false
975+
dynamic_test_linking = true
976976
cache_path = "cache"
977977
snapshots = "snapshots"
978978
gas_snapshot_check = false
@@ -1130,7 +1130,7 @@ exclude = []
11301130
"auto_detect_remappings": true,
11311131
"libraries": [],
11321132
"cache": true,
1133-
"dynamic_test_linking": false,
1133+
"dynamic_test_linking": true,
11341134
"cache_path": "cache",
11351135
"snapshots": "snapshots",
11361136
"gas_snapshot_check": false,

crates/forge/tests/cli/test_optimizer.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
33
// Test cache is invalidated when `forge build` if optimize test option toggled.
44
forgetest_init!(toggle_invalidate_cache_on_build, |prj, cmd| {
5-
prj.update_config(|config| {
6-
config.dynamic_test_linking = true;
7-
});
85
// All files are built with optimized tests.
96
cmd.args(["build"]).with_no_redact().assert_success().stdout_eq(str![[r#"
107
...
@@ -35,9 +32,6 @@ Compiling 22 files with [..]
3532

3633
// Test cache is invalidated when `forge test` if optimize test option toggled.
3734
forgetest_init!(toggle_invalidate_cache_on_test, |prj, cmd| {
38-
prj.update_config(|config| {
39-
config.dynamic_test_linking = true;
40-
});
4135
// All files are built with optimized tests.
4236
cmd.args(["test"]).with_no_redact().assert_success().stdout_eq(str![[r#"
4337
...
@@ -74,9 +68,6 @@ Compiling 20 files with [..]
7468
// └── Counter.t.sol
7569
forgetest_init!(preprocess_contract_with_no_interface, |prj, cmd| {
7670
prj.wipe_contracts();
77-
prj.update_config(|config| {
78-
config.dynamic_test_linking = true;
79-
});
8071

8172
prj.add_source(
8273
"Counter.sol",
@@ -201,9 +192,6 @@ Compiling 1 files with [..]
201192
// └── Counter.t.sol
202193
forgetest_init!(preprocess_contract_with_interface, |prj, cmd| {
203194
prj.wipe_contracts();
204-
prj.update_config(|config| {
205-
config.dynamic_test_linking = true;
206-
});
207195

208196
prj.add_source(
209197
"interface/CounterIf.sol",
@@ -341,9 +329,6 @@ Compiling 1 files with [..]
341329
// └── CounterMock.sol
342330
forgetest_init!(preprocess_mock_without_inheritance, |prj, cmd| {
343331
prj.wipe_contracts();
344-
prj.update_config(|config| {
345-
config.dynamic_test_linking = true;
346-
});
347332

348333
prj.add_source(
349334
"Counter.sol",
@@ -498,9 +483,6 @@ Compiling 2 files with [..]
498483
// └── CounterMock.sol
499484
forgetest_init!(preprocess_mock_with_inheritance, |prj, cmd| {
500485
prj.wipe_contracts();
501-
prj.update_config(|config| {
502-
config.dynamic_test_linking = true;
503-
});
504486

505487
prj.add_source(
506488
"Counter.sol",
@@ -637,9 +619,6 @@ Compiling 2 files with [..]
637619
// └── CounterMock.sol
638620
forgetest_init!(preprocess_mock_to_non_mock, |prj, cmd| {
639621
prj.wipe_contracts();
640-
prj.update_config(|config| {
641-
config.dynamic_test_linking = true;
642-
});
643622

644623
prj.add_source(
645624
"Counter.sol",
@@ -752,9 +731,6 @@ Compiling 2 files with [..]
752731
// └── Counter.t.sol
753732
forgetest_init!(preprocess_multiple_contracts_with_constructors, |prj, cmd| {
754733
prj.wipe_contracts();
755-
prj.update_config(|config| {
756-
config.dynamic_test_linking = true;
757-
});
758734

759735
prj.add_source(
760736
"Counter.sol",
@@ -1019,9 +995,6 @@ Compiling 1 files with [..]
1019995
// Test preprocessing contracts with payable constructor, value and salt named args.
1020996
forgetest_init!(preprocess_contracts_with_payable_constructor_and_salt, |prj, cmd| {
1021997
prj.wipe_contracts();
1022-
prj.update_config(|config| {
1023-
config.dynamic_test_linking = true;
1024-
});
1025998

1026999
prj.add_source(
10271000
"Counter.sol",

0 commit comments

Comments
 (0)