Skip to content

Commit b995d55

Browse files
authored
Cleanup and rename test features and workflows, skip test failing on older scarb in scheduled tests (#3784)
<!-- Reference any GitHub issues resolved by this PR --> Closes # ## Introduced changes <!-- A brief description of the changes --> - ## Checklist <!-- Make sure all of these are complete --> - [ ] Linked relevant issue - [ ] Updated relevant documentation - [ ] Added relevant tests - [ ] Performed self-review of the code - [ ] Added changes to `CHANGELOG.md`
1 parent 200ee25 commit b995d55

File tree

14 files changed

+107
-123
lines changed

14 files changed

+107
-123
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
with:
3838
3939
- name: Build and archive tests
40-
run: cargo nextest archive --cargo-profile ci -p forge --features skip_plugin_checks --archive-file 'nextest-archive-${{ runner.os }}.tar.zst'
40+
run: cargo nextest archive --cargo-profile ci -p forge --archive-file 'nextest-archive-${{ runner.os }}.tar.zst'
4141
- name: Upload archive to workflow
4242
uses: actions/upload-artifact@v4
4343
with:
@@ -126,9 +126,9 @@ jobs:
126126
- uses: dtolnay/rust-toolchain@stable
127127
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
128128
- uses: software-mansion/setup-universal-sierra-compiler@v1
129+
# No setup scarb action is used because we want to install multiple versions of scarb through asdf
129130
- uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
130-
- run: cargo test --profile ci --package forge e2e::plugin_versions
131-
- run: cargo test --profile ci --package forge e2e::plugin_diagnostics
131+
- run: cargo test --profile ci --package forge --features test_for_multiple_scarb_versions e2e::plugin_diagnostic
132132

133133
test-requirements-check-special-conditions:
134134
name: Test requirements check special conditions
@@ -147,20 +147,6 @@ jobs:
147147

148148
- run: cargo test --profile ci --package forge --features scarb_2_10_0 --test main e2e::requirements::test_warning_on_scarb_version_below_recommended
149149

150-
# TODO(#3212): Closures in Cairo are fully supported since version 2.11
151-
test-interact-with-state:
152-
name: Test interact with state
153-
runs-on: ubuntu-latest
154-
steps:
155-
- uses: actions/checkout@v5
156-
- uses: dtolnay/rust-toolchain@stable
157-
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
158-
- uses: software-mansion/setup-scarb@v1
159-
- uses: software-mansion/setup-universal-sierra-compiler@v1
160-
161-
- run: cargo test --profile ci --package forge --features interact-with-state --test main integration::interact_with_state
162-
- run: cargo test --profile ci --package forge --features interact-with-state --test main e2e::running::test_interact_with_state
163-
164150
test-forge-runner:
165151
name: Test Forge Runner
166152
runs-on: ubuntu-latest
@@ -192,18 +178,6 @@ jobs:
192178
- name: Run Data Transformer tests
193179
run: cargo test --profile ci -p data-transformer
194180

195-
test-forge-debugging:
196-
name: Test Forge Debugging
197-
runs-on: ubuntu-latest
198-
steps:
199-
- uses: actions/checkout@v5
200-
- uses: dtolnay/rust-toolchain@stable
201-
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
202-
- uses: software-mansion/setup-scarb@v1
203-
- uses: software-mansion/setup-universal-sierra-compiler@58146c4184fa6ec5e8aaf02309ab85e35f782ed0 # v1.0.0
204-
- name: Run Forge Debugging tests
205-
run: cargo test --profile ci -p forge --features debugging --test main e2e::debugging
206-
207181
test-forge-scarb-plugin:
208182
name: Test Forge Scarb Plugin
209183
runs-on: ubuntu-latest

.github/workflows/scheduled.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
- uses: software-mansion/setup-universal-sierra-compiler@v1
5050

5151
- run: cargo test --profile ci --lib -p forge
52-
- run: cargo test --profile ci -p forge integration --features assert_non_exact_gas
52+
- run: cargo test --profile ci -p forge integration --features non_exact_gas_assertions,skip_test_for_scarb_since_2_11
5353

5454
test-forge-e2e:
5555
if: github.event.repository.fork == false
@@ -91,7 +91,7 @@ jobs:
9191
run: |
9292
curl -L https://raw.githubusercontent.com/software-mansion/cairo-coverage/main/scripts/install.sh | sh
9393
94-
- run: cargo test --profile ci -p forge --features skip_plugin_checks e2e
94+
- run: cargo test --profile ci -p forge --features skip_test_for_only_latest_scarb,skip_test_for_scarb_since_2_11 e2e
9595

9696
test-cast:
9797
if: github.event.repository.fork == false

crates/forge/Cargo.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ edition.workspace = true
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[features]
9-
smoke = []
109
scarb_2_10_0 = []
1110
no_scarb_installed = []
12-
debugging = []
13-
assert_non_exact_gas = ["test_utils/assert_non_exact_gas"]
14-
skip_plugin_checks = []
15-
interact-with-state = []
11+
non_exact_gas_assertions = ["test_utils/non_exact_gas_assertions"]
12+
skip_test_for_only_latest_scarb = []
13+
skip_test_for_scarb_since_2_11 = []
14+
test_for_multiple_scarb_versions = []
1615

1716
[dependencies]
1817
anyhow.workspace = true

crates/forge/test_utils/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition.workspace = true
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[features]
9-
assert_non_exact_gas = []
9+
non_exact_gas_assertions = []
1010

1111
[dependencies]
1212
walkdir.workspace = true

crates/forge/test_utils/src/runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ pub fn assert_gas(result: &[TestTargetSummary], test_case_name: &str, asserted_g
321321
// and to assert gas values with a margin in scheduled tests, as values can vary for different Scarb versions
322322
// FOR LOCAL DEVELOPMENT ALWAYS USE EXACT CALCULATIONS
323323
fn assert_gas_with_margin(gas: GasVector, asserted_gas: GasVector) -> bool {
324-
if cfg!(feature = "assert_non_exact_gas") {
324+
if cfg!(feature = "non_exact_gas_assertions") {
325325
let diff = gas_vector_abs_diff(&gas, &asserted_gas);
326326
diff.l1_gas.0 <= 10 && diff.l1_data_gas.0 <= 10 && diff.l2_gas.0 <= 200_000
327327
} else {

crates/forge/tests/e2e/fuzzing.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ fn generate_arg_cheatcode() {
292292
}
293293

294294
#[test]
295+
#[cfg_attr(
296+
feature = "skip_test_for_only_latest_scarb",
297+
ignore = "Plugin checks skipped"
298+
)]
295299
fn no_fuzzer_attribute() {
296300
let temp = setup_package("fuzzing");
297301
let test_file = temp.child("tests/no_attribute.cairo");

crates/forge/tests/e2e/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ mod completions;
1010
mod components;
1111
mod contract_artifacts;
1212
mod coverage;
13-
#[cfg(feature = "debugging")]
1413
mod debugging;
1514
mod docs_snippets_validation;
1615
mod env;

crates/forge/tests/e2e/new.rs

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#[cfg(feature = "smoke")]
2-
use super::common::runner::{get_current_branch, get_remote_url};
3-
41
use super::common::runner::{runner, snforge_test_bin_path, test_runner};
52
use assert_fs::TempDir;
63
use assert_fs::fixture::{FileTouch, PathChild};
@@ -305,65 +302,6 @@ fn get_expected_output(template: &Template) -> &str {
305302
}
306303
}
307304

308-
#[test]
309-
#[cfg(feature = "smoke")]
310-
fn test_init_project_with_custom_snforge_dependency_git() {
311-
let temp = tempdir_with_tool_versions().unwrap();
312-
313-
runner(&temp)
314-
.args(["new", "test_name"])
315-
.env("DEV_DISABLE_SNFORGE_STD_DEPENDENCY", "true")
316-
.assert()
317-
.success();
318-
319-
let project_path = temp.join("test_name");
320-
let manifest_path = project_path.join("Scarb.toml");
321-
322-
let scarb_toml = std::fs::read_to_string(&manifest_path).unwrap();
323-
let mut scarb_toml = DocumentMut::from_str(&scarb_toml).unwrap();
324-
325-
let dependencies = scarb_toml
326-
.get_mut("dev-dependencies")
327-
.unwrap()
328-
.as_table_mut()
329-
.unwrap();
330-
331-
let branch = get_current_branch();
332-
let remote_url = format!("https://github.com/{}", get_remote_url());
333-
334-
let mut snforge_std = InlineTable::new();
335-
snforge_std.insert("git", Value::String(Formatted::new(remote_url.clone())));
336-
snforge_std.insert("branch", Value::String(Formatted::new(branch)));
337-
338-
dependencies.remove("snforge_std");
339-
dependencies.insert("snforge_std", Item::Value(Value::InlineTable(snforge_std)));
340-
341-
std::fs::write(&manifest_path, scarb_toml.to_string()).unwrap();
342-
343-
let output = test_runner(&temp)
344-
.current_dir(&project_path)
345-
.assert()
346-
.success();
347-
348-
let expected = formatdoc!(
349-
r"
350-
[..]Updating git repository {}
351-
[..]Compiling test_name v0.1.0[..]
352-
[..]Finished[..]
353-
354-
Collected 2 test(s) from test_name package
355-
Running 0 test(s) from src/
356-
Running 2 test(s) from tests/
357-
[PASS] test_name_integrationtest::test_contract::test_increase_balance [..]
358-
[PASS] test_name_integrationtest::test_contract::test_cannot_increase_balance_with_zero_value [..]
359-
Tests: 2 passed, 0 failed, 0 ignored, 0 filtered out
360-
",
361-
remote_url.trim_end_matches(".git")
362-
);
363-
364-
assert_stdout_contains(output, expected);
365-
}
366-
367305
#[test]
368306
fn create_new_project_and_check_gitignore() {
369307
let temp = tempdir_with_tool_versions().unwrap();

crates/forge/tests/e2e/plugin_diagnostics.rs

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ use snapbox::cmd::Command as SnapboxCommand;
77
use std::fs;
88

99
#[test]
10-
#[cfg_attr(feature = "skip_plugin_checks", ignore = "Plugin checks skipped")]
10+
#[cfg_attr(
11+
feature = "skip_test_for_only_latest_scarb",
12+
ignore = "Plugin checks skipped"
13+
)]
1114
#[allow(clippy::too_many_lines)]
1215
fn syntax() {
1316
let temp = setup_package_at_path(Utf8PathBuf::from("diagnostics/syntax"));
@@ -123,7 +126,10 @@ fn syntax() {
123126
}
124127

125128
#[test]
126-
#[cfg_attr(feature = "skip_plugin_checks", ignore = "Plugin checks skipped")]
129+
#[cfg_attr(
130+
feature = "skip_test_for_only_latest_scarb",
131+
ignore = "Plugin checks skipped"
132+
)]
127133
fn semantic() {
128134
let temp = setup_package_at_path(Utf8PathBuf::from("diagnostics/semantic"));
129135
let output = SnapboxCommand::from_std(
@@ -168,7 +174,10 @@ fn semantic() {
168174
}
169175

170176
#[test]
171-
#[cfg_attr(feature = "skip_plugin_checks", ignore = "Plugin checks skipped")]
177+
#[cfg_attr(
178+
feature = "skip_test_for_only_latest_scarb",
179+
ignore = "Plugin checks skipped"
180+
)]
172181
fn parameters() {
173182
let temp = setup_package_at_path(Utf8PathBuf::from("diagnostics/parameters"));
174183
let output = SnapboxCommand::from_std(
@@ -222,7 +231,10 @@ fn parameters() {
222231
}
223232

224233
#[test]
225-
#[cfg_attr(feature = "skip_plugin_checks", ignore = "Plugin checks skipped")]
234+
#[cfg_attr(
235+
feature = "skip_test_for_only_latest_scarb",
236+
ignore = "Plugin checks skipped"
237+
)]
226238
fn multiple() {
227239
let temp = setup_package_at_path(Utf8PathBuf::from("diagnostics/multiple"));
228240
let output = SnapboxCommand::from_std(
@@ -323,7 +335,10 @@ fn multiple() {
323335
}
324336

325337
#[test]
326-
#[cfg_attr(feature = "skip_plugin_checks", ignore = "Plugin checks skipped")]
338+
#[cfg_attr(
339+
feature = "skip_test_for_only_latest_scarb",
340+
ignore = "Plugin checks skipped"
341+
)]
327342
fn generic() {
328343
let temp = setup_package_at_path(Utf8PathBuf::from("diagnostics/generic"));
329344
let output = SnapboxCommand::from_std(
@@ -356,7 +371,10 @@ fn generic() {
356371
}
357372

358373
#[test]
359-
#[cfg_attr(feature = "skip_plugin_checks", ignore = "Plugin checks skipped")]
374+
#[cfg_attr(
375+
feature = "skip_test_for_only_latest_scarb",
376+
ignore = "Plugin checks skipped"
377+
)]
360378
fn inline_macros() {
361379
let temp = setup_package_at_path(Utf8PathBuf::from("diagnostics/inline_macros"));
362380
let output = SnapboxCommand::from_std(
@@ -389,7 +407,10 @@ fn inline_macros() {
389407
}
390408

391409
#[test]
392-
#[cfg_attr(feature = "skip_plugin_checks", ignore = "Plugin checks skipped")]
410+
#[cfg_attr(
411+
feature = "skip_test_for_only_latest_scarb",
412+
ignore = "Plugin checks skipped"
413+
)]
393414
fn different_attributes() {
394415
fn generate_attributes() -> impl Iterator<Item = String> {
395416
let attributes = vec![
@@ -438,7 +459,10 @@ fn different_attributes() {
438459
}
439460

440461
#[test]
441-
#[cfg_attr(feature = "skip_plugin_checks", ignore = "Plugin checks skipped")]
462+
#[cfg_attr(
463+
feature = "skip_test_for_only_latest_scarb",
464+
ignore = "Plugin checks skipped"
465+
)]
442466
fn test_case() {
443467
let temp = setup_package_at_path(Utf8PathBuf::from("diagnostics/test_case_attr"));
444468
let output = SnapboxCommand::from_std(

crates/forge/tests/e2e/plugin_versions.rs

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ use test_utils::tempdir_with_tool_versions;
88
use toml_edit::ImDocument;
99

1010
#[test]
11-
#[cfg_attr(feature = "skip_plugin_checks", ignore = "Plugin checks skipped")]
11+
#[cfg_attr(
12+
not(feature = "test_for_multiple_scarb_versions"),
13+
ignore = "Multiple scarb versions must be installed"
14+
)]
1215
fn new_with_new_scarb() {
1316
let temp = tempdir_with_tool_versions().unwrap();
1417
runner(&temp)
@@ -39,7 +42,10 @@ fn new_with_new_scarb() {
3942
}
4043

4144
#[test]
42-
#[cfg_attr(feature = "skip_plugin_checks", ignore = "Plugin checks skipped")]
45+
#[cfg_attr(
46+
not(feature = "test_for_multiple_scarb_versions"),
47+
ignore = "Multiple scarb versions must be installed"
48+
)]
4349
fn new_with_old_scarb() {
4450
let temp = tempdir_with_tool_versions().unwrap();
4551
Command::new("asdf")
@@ -75,7 +81,10 @@ fn new_with_old_scarb() {
7581
}
7682

7783
#[test]
78-
#[cfg_attr(feature = "skip_plugin_checks", ignore = "Plugin checks skipped")]
84+
#[cfg_attr(
85+
not(feature = "test_for_multiple_scarb_versions"),
86+
ignore = "Multiple scarb versions must be installed"
87+
)]
7988
fn new_scarb_new_macros() {
8089
let temp = tempdir_with_tool_versions().unwrap();
8190
runner(&temp)
@@ -112,7 +121,10 @@ fn new_scarb_new_macros() {
112121
}
113122

114123
#[test]
115-
#[cfg_attr(feature = "skip_plugin_checks", ignore = "Plugin checks skipped")]
124+
#[cfg_attr(
125+
not(feature = "test_for_multiple_scarb_versions"),
126+
ignore = "Multiple scarb versions must be installed"
127+
)]
116128
fn new_scarb_deprecated_macros() {
117129
let temp = tempdir_with_tool_versions().unwrap();
118130
runner(&temp)
@@ -157,7 +169,10 @@ fn new_scarb_deprecated_macros() {
157169
}
158170

159171
#[test]
160-
#[cfg_attr(feature = "skip_plugin_checks", ignore = "Plugin checks skipped")]
172+
#[cfg_attr(
173+
not(feature = "test_for_multiple_scarb_versions"),
174+
ignore = "Multiple scarb versions must be installed"
175+
)]
161176
fn new_scarb_old_macros() {
162177
let temp = tempdir_with_tool_versions().unwrap();
163178
runner(&temp)
@@ -183,7 +198,10 @@ fn new_scarb_old_macros() {
183198
}
184199

185200
#[test]
186-
#[cfg_attr(feature = "skip_plugin_checks", ignore = "Plugin checks skipped")]
201+
#[cfg_attr(
202+
not(feature = "test_for_multiple_scarb_versions"),
203+
ignore = "Multiple scarb versions must be installed"
204+
)]
187205
fn old_scarb_new_macros() {
188206
let temp = tempdir_with_tool_versions().unwrap();
189207
Command::new("asdf")
@@ -217,7 +235,10 @@ fn old_scarb_new_macros() {
217235
}
218236

219237
#[test]
220-
#[cfg_attr(feature = "skip_plugin_checks", ignore = "Plugin checks skipped")]
238+
#[cfg_attr(
239+
not(feature = "test_for_multiple_scarb_versions"),
240+
ignore = "Multiple scarb versions must be installed"
241+
)]
221242
fn old_scarb_deprecated_macros() {
222243
let temp = tempdir_with_tool_versions().unwrap();
223244
Command::new("asdf")
@@ -264,7 +285,10 @@ fn old_scarb_deprecated_macros() {
264285
}
265286

266287
#[test]
267-
#[cfg_attr(feature = "skip_plugin_checks", ignore = "Plugin checks skipped")]
288+
#[cfg_attr(
289+
not(feature = "test_for_multiple_scarb_versions"),
290+
ignore = "Multiple scarb versions must be installed"
291+
)]
268292
fn old_scarb_old_macros() {
269293
let temp = tempdir_with_tool_versions().unwrap();
270294
Command::new("asdf")

0 commit comments

Comments
 (0)