Skip to content

Commit 499f83e

Browse files
authored
Split forge tests, so they can be filtered out (#232)
<!-- Reference any GitHub issues resolved by this PR --> ## Introduced changes <!-- A brief description of the changes --> - split e2e and integration tests, so they can now be invoked separately: ``` cargo test integration --manifest-path ./starknet-foundry/Cargo.toml -p forge cargo test e2e --manifest-path ./starknet-foundry/Cargo.toml -p forge ``` of course running all tests is still possible using the same command as prviously - Run e2e tests on separate runner, to decrease overall forge tests execution time ## Breaking changes None ## Checklist <!-- Make sure all of these are complete --> - [X] Linked relevant issue - [X] Updated relevant documentation - [X] Added relevant tests - [X] Performed self-review of the code
1 parent 14040a6 commit 499f83e

File tree

10 files changed

+53
-13
lines changed

10 files changed

+53
-13
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ on:
88
- master
99

1010
jobs:
11-
test-forge:
12-
name: Test Forge
11+
test-forge-unit-and-integration:
12+
name: Test Forge / Unit and Integration Tests
1313
env:
1414
SCARB_VERSION: 0.5.2
1515
runs-on: ubuntu-latest
@@ -26,7 +26,28 @@ jobs:
2626
- uses: software-mansion/[email protected]
2727
with:
2828
scarb-version: ${{ env.SCARB_VERSION }}
29-
- run: cargo test --manifest-path ./starknet-foundry/Cargo.toml -p forge
29+
- run: cargo test --lib --manifest-path ./starknet-foundry/Cargo.toml -p forge
30+
- run: cargo test integration --manifest-path ./starknet-foundry/Cargo.toml -p forge
31+
32+
test-forge-e2e:
33+
name: Test Forge / E2E Tests
34+
env:
35+
SCARB_VERSION: 0.5.1
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v3
39+
with:
40+
submodules: true
41+
- uses: dtolnay/rust-toolchain@stable
42+
- uses: Swatinem/rust-cache@dd05243424bd5c0e585e4b55eb2d7615cdd32f1f
43+
with:
44+
workspaces: |
45+
starknet-foundry
46+
cairo
47+
- uses: software-mansion/[email protected]
48+
with:
49+
scarb-version: ${{ env.SCARB_VERSION }}
50+
- run: cargo test e2e --manifest-path ./starknet-foundry/Cargo.toml -p forge
3051

3152
test-cast:
3253
name: Test Cast
@@ -89,7 +110,7 @@ jobs:
89110
clippy:
90111
runs-on: ubuntu-latest
91112
env:
92-
# Make sure CI fails on all warnings, including Clippy lints.
113+
# Make sure CI fails on all warnings - including Clippy lints.
93114
RUSTFLAGS: "-Dwarnings"
94115
steps:
95116
- uses: actions/checkout@v3

CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,23 @@ cargo lint
3434

3535
Otherwise, it won't be possible to merge your contribution.
3636

37+
You can also run specific set of tests, by directly running `cargo test`.
38+
39+
For forge tests, make sure you are in `starkent-foundry/crates/forge` directory:
40+
```shell
41+
forge $ cargo test --lib # runs all unit tests
42+
forge $ cargo test integration # runs all integration tests
43+
forge $ cargo test e2e # runs all e2e tests
44+
```
45+
46+
Similarly, to run cast tests make sure you are in `starkent-foundry/crates/cast` directory:
47+
```shell
48+
cast $ cargo test --lib # runs lib unit tests
49+
cast $ cargo test helpers # runs helpers unit tests
50+
cast $ cargo test integration # runs all integration tests
51+
cast $ cargo test e2e # runs all e2e tests
52+
```
53+
3754
## Contributing
3855

3956
Before you open a pull request, it is always a good idea to search

starknet-foundry/crates/forge/tests/e2e/running.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use assert_fs::fixture::{FileWriteStr, PathChild, PathCopy};
22
use indoc::indoc;
33

4-
use crate::common::runner::runner;
4+
use crate::e2e::common::runner::runner;
55

66
#[test]
77
fn simple_package() {

starknet-foundry/crates/forge/tests/integration/common/runner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ impl<'a> TestCase {
126126
#[macro_export]
127127
macro_rules! test_case {
128128
( $test_code:expr ) => ({
129-
use $crate::common::runner::TestCase;
129+
use $crate::integration::common::runner::TestCase;
130130
TestCase::from($test_code, vec![]).unwrap()
131131
});
132132
( $test_code:expr, $( $contract:expr ),*) => ({
133-
use $crate::common::runner::TestCase;
133+
use $crate::integration::common::runner::TestCase;
134134

135135
let contracts = vec![$($contract,)*];
136136
TestCase::from($test_code, contracts).unwrap()

starknet-foundry/crates/forge/tests/integration/declare.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::common::corelib::{corelib, predeployed_contracts};
2-
use crate::common::runner::Contract;
1+
use crate::integration::common::corelib::{corelib, predeployed_contracts};
2+
use crate::integration::common::runner::Contract;
33
use crate::{assert_failed, assert_passed, test_case};
44
use camino::Utf8PathBuf;
55
use forge::run;

starknet-foundry/crates/forge/tests/integration/deploy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::common::corelib::{corelib, predeployed_contracts};
2-
use crate::common::runner::Contract;
1+
use crate::integration::common::corelib::{corelib, predeployed_contracts};
2+
use crate::integration::common::runner::Contract;
33
use crate::{assert_case_output_contains, assert_failed, assert_passed, test_case};
44
use camino::Utf8PathBuf;
55
use forge::run;

starknet-foundry/crates/forge/tests/integration/dispatchers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use crate::common::runner::Contract;
1+
use crate::integration::common::runner::Contract;
22
use crate::{assert_passed, test_case};
33
use camino::Utf8PathBuf;
44
use std::path::Path;
55
use std::string::ToString;
66

7-
use crate::common::corelib::{corelib, predeployed_contracts};
7+
use crate::integration::common::corelib::{corelib, predeployed_contracts};
88
use forge::run;
99
use indoc::indoc;
1010

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mod e2e;
2+
mod integration;

0 commit comments

Comments
 (0)