-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It means that the test runs twice, but it runs fine under msim.
- Loading branch information
Showing
1 changed file
with
57 additions
and
64 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 |
---|---|---|
@@ -1,87 +1,80 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#[cfg(not(msim))] | ||
mod test { | ||
use std::path::Path; | ||
use std::path::Path; | ||
|
||
use move_cli::base::test::UnitTestResult; | ||
use move_package::LintFlag; | ||
use move_unit_test::UnitTestingConfig; | ||
use sui_move::unit_test::run_move_unit_tests; | ||
use sui_move_build::BuildConfig; | ||
use move_cli::base::test::UnitTestResult; | ||
use move_package::LintFlag; | ||
use move_unit_test::UnitTestingConfig; | ||
use sui_move::unit_test::run_move_unit_tests; | ||
use sui_move_build::BuildConfig; | ||
|
||
pub(crate) const EXAMPLES: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../examples"); | ||
pub(crate) const FRAMEWORK: &str = concat!( | ||
env!("CARGO_MANIFEST_DIR"), | ||
"/../../crates/sui-framework/packages" | ||
); | ||
pub(crate) const EXAMPLES: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../examples"); | ||
pub(crate) const FRAMEWORK: &str = concat!( | ||
env!("CARGO_MANIFEST_DIR"), | ||
"/../../crates/sui-framework/packages" | ||
); | ||
|
||
/// Ensure packages build outside of test mode. | ||
pub(crate) fn build(path: &Path) -> datatest_stable::Result<()> { | ||
let Some(path) = path.parent() else { | ||
panic!("No parent for Move.toml file at: {}", path.display()); | ||
}; | ||
/// Ensure packages build outside of test mode. | ||
pub(crate) fn build(path: &Path) -> datatest_stable::Result<()> { | ||
let Some(path) = path.parent() else { | ||
panic!("No parent for Move.toml file at: {}", path.display()); | ||
}; | ||
|
||
let mut config = BuildConfig::new_for_testing(); | ||
config.config.dev_mode = true; | ||
config.run_bytecode_verifier = true; | ||
config.print_diags_to_stderr = true; | ||
config.config.warnings_are_errors = true; | ||
config.config.silence_warnings = false; | ||
config.config.lint_flag = LintFlag::LEVEL_DEFAULT; | ||
let mut config = BuildConfig::new_for_testing(); | ||
config.config.dev_mode = true; | ||
config.run_bytecode_verifier = true; | ||
config.print_diags_to_stderr = true; | ||
config.config.warnings_are_errors = true; | ||
config.config.silence_warnings = false; | ||
config.config.lint_flag = LintFlag::LEVEL_DEFAULT; | ||
|
||
config | ||
.build(path) | ||
.unwrap_or_else(|e| panic!("Building package {}.\nWith error {e}", path.display())); | ||
config | ||
.build(path) | ||
.unwrap_or_else(|e| panic!("Building package {}.\nWith error {e}", path.display())); | ||
|
||
Ok(()) | ||
} | ||
Ok(()) | ||
} | ||
|
||
/// Ensure package sbuild under test mode and all the tests pass. | ||
pub(crate) fn tests(path: &Path) -> datatest_stable::Result<()> { | ||
let Some(path) = path.parent() else { | ||
panic!("No parent for Move.toml file at: {}", path.display()); | ||
}; | ||
/// Ensure package sbuild under test mode and all the tests pass. | ||
pub(crate) fn tests(path: &Path) -> datatest_stable::Result<()> { | ||
let Some(path) = path.parent() else { | ||
panic!("No parent for Move.toml file at: {}", path.display()); | ||
}; | ||
|
||
let mut config = BuildConfig::new_for_testing(); | ||
let mut config = BuildConfig::new_for_testing(); | ||
|
||
config.config.dev_mode = true; | ||
config.config.test_mode = true; | ||
config.run_bytecode_verifier = true; | ||
config.print_diags_to_stderr = true; | ||
config.config.warnings_are_errors = true; | ||
config.config.silence_warnings = false; | ||
config.config.lint_flag = LintFlag::LEVEL_DEFAULT; | ||
config.config.dev_mode = true; | ||
config.config.test_mode = true; | ||
config.run_bytecode_verifier = true; | ||
config.print_diags_to_stderr = true; | ||
config.config.warnings_are_errors = true; | ||
config.config.silence_warnings = false; | ||
config.config.lint_flag = LintFlag::LEVEL_DEFAULT; | ||
|
||
let move_config = config.config.clone(); | ||
let mut testing_config = UnitTestingConfig::default_with_bound(Some(3_000_000)); | ||
testing_config.filter = std::env::var("FILTER").ok().map(|s| s.to_string()); | ||
let move_config = config.config.clone(); | ||
let mut testing_config = UnitTestingConfig::default_with_bound(Some(3_000_000)); | ||
testing_config.filter = std::env::var("FILTER").ok().map(|s| s.to_string()); | ||
|
||
assert_eq!( | ||
run_move_unit_tests(path, move_config, Some(testing_config), false).unwrap(), | ||
UnitTestResult::Success | ||
); | ||
assert_eq!( | ||
run_move_unit_tests(path, move_config, Some(testing_config), false).unwrap(), | ||
UnitTestResult::Success | ||
); | ||
|
||
Ok(()) | ||
} | ||
Ok(()) | ||
} | ||
|
||
#[cfg(not(msim))] | ||
datatest_stable::harness!( | ||
test::build, | ||
test::EXAMPLES, | ||
build, | ||
EXAMPLES, | ||
r".*/Move.toml$", | ||
test::tests, | ||
test::EXAMPLES, | ||
tests, | ||
EXAMPLES, | ||
r".*/Move.toml$", | ||
test::build, | ||
test::FRAMEWORK, | ||
build, | ||
FRAMEWORK, | ||
r".*/Move.toml$", | ||
test::tests, | ||
test::FRAMEWORK, | ||
tests, | ||
FRAMEWORK, | ||
r".*/Move.toml$", | ||
); | ||
|
||
#[cfg(msim)] | ||
fn main() {} |