-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add datatest_stable to
mutation-test
Added the first integration tests that are executed on these projects: - `move-mutator/tests/move-assets/breakcontinue` - `move-mutator/tests/move-assets/simple` The expectation for the integration test is that the generated report by the `move-mutation-test` will match the pre-generated reports in those projects that end with `the .exp` suffix.
- Loading branch information
Showing
11 changed files
with
995 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[test-groups] | ||
serial-integration = { max-threads = 1 } | ||
|
||
[[profile.default.overrides]] | ||
filter = 'test(test_run_mutation_test::)' | ||
test-group = 'serial-integration' | ||
slow-timeout = { period = "120s" } | ||
threads-required = "num-cpus" | ||
|
||
[profile.ci] | ||
# Do not cancel the test run on the first failure. | ||
fail-fast = false | ||
retries = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Basic test run | ||
|
||
on: | ||
push: | ||
branches: [ main, develop-m3, develop-m4 ] | ||
paths: | ||
- Cargo.toml | ||
- Cargo.lock | ||
- move-mutator/** | ||
- move-spec-test/** | ||
- move-mutation-test/** | ||
- .github/workflows/run-tests.yml | ||
pull_request: | ||
branches: [ main, develop-m3, develop-m4 ] | ||
paths: | ||
- Cargo.toml | ||
- Cargo.lock | ||
- move-mutator/** | ||
- move-spec-test/** | ||
- move-mutation-test/** | ||
- .github/workflows/run-tests.yml | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
basic-lint-and-check: | ||
runs-on: self-hosted | ||
name: Basic ci-check for tests | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install required deps | ||
run: sudo apt-get install libudev-dev libdw-dev lld | ||
|
||
- name: Setup Rust toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: default | ||
toolchain: stable | ||
|
||
- name: Install nextest | ||
uses: taiki-e/install-action@nextest | ||
|
||
- name: Run integration tests in the release mode (due to test duration) | ||
run: cargo nextest run -r --profile ci test_run_mutation_test | ||
|
||
- name: Run normal tests in the debug mode | ||
run: cargo nextest run --profile ci -E 'not test(test_run_mutation_test)' | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
use aptos::common::types::MovePackageDir; | ||
use log::info; | ||
use move_mutation_test::cli::CLIOptions; | ||
use move_mutation_test::cli::TestBuildConfig; | ||
use move_mutation_test::run_mutation_test; | ||
use mutator_common::report::Report; | ||
use std::fs; | ||
use std::path::{Path, PathBuf}; | ||
|
||
const RED_ZONE: usize = 128 * 1024; // 128 KiB | ||
const STACK_SIZE: usize = 32 * RED_ZONE; // 4 MiB | ||
|
||
fn test_run_mutation_test(path: &Path, expected_report: String) -> datatest_stable::Result<()> { | ||
let expected_report = | ||
Report::load_from_str(expected_report).expect("failed to load the report"); | ||
let package_path = path.parent().expect("package path not found"); | ||
|
||
let mut move_pkg = MovePackageDir::new(); | ||
move_pkg.package_dir = Some(PathBuf::from(package_path)); | ||
let test_build_cfg = TestBuildConfig { | ||
move_pkg, | ||
dump_state: false, | ||
filter: None, | ||
ignore_compile_warnings: false, | ||
apply_coverage: true, | ||
gas_limit: 1_000, | ||
}; | ||
|
||
let report_file = PathBuf::from("report.txt"); | ||
let cli_opts = CLIOptions { | ||
output: Some(report_file.clone()), | ||
..Default::default() | ||
}; | ||
|
||
stacker::maybe_grow(RED_ZONE, STACK_SIZE, || { | ||
run_mutation_test(&cli_opts, &test_build_cfg).expect("running the mutation test failed"); | ||
info!( | ||
"remaining stack size is {}", | ||
stacker::remaining_stack().expect("failed to get the remaining stack size") | ||
); | ||
}); | ||
|
||
let generated_report = Report::load_from_json_file(&report_file).expect("report not found"); | ||
|
||
// Let's make sure the reports are equal. | ||
let Report { | ||
files: mut expected_entries, | ||
.. | ||
} = expected_report; | ||
let Report { | ||
files: generated_report_files, | ||
.. | ||
} = generated_report; | ||
|
||
// Unfortunately, we cannot compare the files directly since the `package_path` is an absolute | ||
// path and would differ on different machines depending on the package location. | ||
for (file, mutant_stats) in generated_report_files { | ||
let (expected_file, expected_mutant_stats) = expected_entries | ||
.pop_first() | ||
.expect("reports are not the same"); | ||
assert_eq!(file, expected_file); | ||
assert_eq!(mutant_stats, expected_mutant_stats); | ||
} | ||
assert!(expected_entries.is_empty()); | ||
|
||
// Make sure we remove the file since these tests are executed serially - it makes no sense to | ||
// run these tests in parallel since every test spawns the maximum number of threads. | ||
fs::remove_file(report_file).unwrap(); | ||
|
||
Ok(()) | ||
} | ||
|
||
const MOVE_ASSETS: &str = "../move-mutator/tests/move-assets"; | ||
|
||
datatest_stable::harness!(test_run_mutation_test, MOVE_ASSETS, r".*\.exp",); |
Oops, something went wrong.