Skip to content

Commit 35b0da6

Browse files
committed
Make panic-backtrace required in validation
1 parent 944ba07 commit 35b0da6

File tree

5 files changed

+4
-48
lines changed

5 files changed

+4
-48
lines changed

crates/forge/src/profile_validation/backtrace.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ fn check_if_native_disabled(test_args: &TestArgs) -> anyhow::Result<()> {
2929

3030
/// Checks if the runtime profile settings in the provided from [`Metadata`] contain the required entries for backtrace generation.
3131
fn check_profile(scarb_metadata: &Metadata) -> anyhow::Result<()> {
32-
// TODO(#3679): Add `panic-backtrace = true` entry when we decide to bump minimal scarb version to 2.12.
3332
const BACKTRACE_REQUIRED_ENTRIES: &[(&str, &str)] = &[
3433
("unstable-add-statements-functions-debug-info", "true"),
3534
("unstable-add-statements-code-locations-debug-info", "true"),
35+
("panic-backtrace", "true"),
3636
];
3737

3838
let manifest = get_manifest(scarb_metadata)?;
@@ -48,6 +48,7 @@ fn check_profile(scarb_metadata: &Metadata) -> anyhow::Result<()> {
4848
[profile.{profile}.cairo]
4949
unstable-add-statements-functions-debug-info = true
5050
unstable-add-statements-code-locations-debug-info = true
51+
panic-backtrace = true
5152
... other entries ...
5253
",
5354
profile = scarb_metadata.current_profile

crates/forge/src/run_tests/workspace.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::run_tests::messages::overall_summary::OverallSummaryMessage;
55
use crate::run_tests::messages::tests_failure_summary::TestsFailureSummaryMessage;
66
use crate::warn::{
77
error_if_snforge_std_deprecated_missing, error_if_snforge_std_deprecated_not_compatible,
8-
error_if_snforge_std_not_compatible, warn_if_backtrace_without_panic_hint,
8+
error_if_snforge_std_not_compatible,
99
warn_if_snforge_std_deprecated_does_not_match_package_version,
1010
};
1111
use crate::{
@@ -56,8 +56,6 @@ pub async fn run_for_workspace(args: TestArgs, ui: Arc<UI>) -> Result<ExitStatus
5656
warn_if_snforge_std_deprecated_does_not_match_package_version(&scarb_metadata, &ui)?;
5757
}
5858

59-
warn_if_backtrace_without_panic_hint(&scarb_metadata, &ui);
60-
6159
let artifacts_dir_path =
6260
target_dir_for_workspace(&scarb_metadata).join(&scarb_metadata.current_profile);
6361

crates/forge/src/warn.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use crate::{MINIMAL_SNFORGE_STD_DEPRECATED_VERSION, MINIMAL_SNFORGE_STD_VERSION};
22
use anyhow::{Result, anyhow};
3-
use forge_runner::backtrace::is_backtrace_enabled;
43
use forge_runner::package_tests::with_config_resolved::TestTargetWithResolvedConfig;
54
use foundry_ui::UI;
65
use foundry_ui::components::warning::WarningMessage;
7-
use indoc::formatdoc;
86
use scarb_api::package_matches_version_requirement;
97
use scarb_metadata::Metadata;
108
use semver::{Comparator, Op, Version, VersionReq};
@@ -162,37 +160,3 @@ pub fn warn_if_snforge_std_does_not_match_package_version(
162160
}
163161
Ok(())
164162
}
165-
166-
// TODO(#3679): Remove this function when we decide to bump minimal scarb version to 2.12.
167-
pub(crate) fn warn_if_backtrace_without_panic_hint(scarb_metadata: &Metadata, ui: &UI) {
168-
if is_backtrace_enabled() {
169-
let is_panic_backtrace_set = scarb_metadata
170-
.compilation_units
171-
.iter()
172-
.filter(|unit| {
173-
unit.target.name.contains("unittest")
174-
|| unit.target.name.contains("integrationtest")
175-
})
176-
.all(|unit| match &unit.compiler_config {
177-
serde_json::Value::Object(map) => map
178-
.get("panic_backtrace")
179-
.is_some_and(|v| v == &serde_json::Value::Bool(true)),
180-
_ => false,
181-
});
182-
183-
if !is_panic_backtrace_set {
184-
let message = formatdoc! {
185-
"Scarb version should be 2.12 or higher and `Scarb.toml` should have the following Cairo compiler configuration to get accurate backtrace results:
186-
187-
[profile.{profile}.cairo]
188-
unstable-add-statements-functions-debug-info = true
189-
unstable-add-statements-code-locations-debug-info = true
190-
panic-backtrace = true # only for scarb 2.12 or higher
191-
... other entries ...
192-
",
193-
profile = scarb_metadata.current_profile
194-
};
195-
ui.println(&WarningMessage::new(message));
196-
}
197-
}
198-
}

crates/forge/tests/data/backtrace_vm_error/Scarb.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ test = "snforge test"
2020
[profile.dev.cairo]
2121
unstable-add-statements-functions-debug-info = true
2222
unstable-add-statements-code-locations-debug-info = true
23+
panic-backtrace = true

crates/forge/tests/e2e/backtrace.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,6 @@ fn test_backtrace() {
5555
output,
5656
indoc! {
5757
"
58-
[WARNING] Scarb version should be 2.12 or higher and `Scarb.toml` should have the following Cairo compiler configuration to get accurate backtrace results:
59-
60-
[profile.dev.cairo]
61-
unstable-add-statements-functions-debug-info = true
62-
unstable-add-statements-code-locations-debug-info = true
63-
panic-backtrace = true # only for scarb 2.12 or higher
64-
... other entries ...
65-
6658
[FAIL] backtrace_vm_error::Test::test_unwrapped_call_contract_syscall
6759
6860
Failure data:

0 commit comments

Comments
 (0)