Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::path::{Path, PathBuf};
use std::str::FromStr;

use std::time::Duration;
use test::test::TestTimeOptions;
use test::ColorConfig;

#[derive(Clone, Copy, Eq, PartialEq, Debug)]
Expand Down Expand Up @@ -145,6 +146,14 @@ pub struct Config {
/// updating multiple tests. Users should still manually edit the files after to only keep
/// relevant expectations.
pub fix_expected: bool,

/// Whether we should measure and limit the time of a test.
pub time_opts: Option<TestTimeOptions>,

/// Extra arguments to be passed to Kani in this regression.
/// Note that there is no validation done whether these flags conflict with existing flags.
/// For example, one could add `--kani-flag=--only-codegen` to only compile all tests.
pub extra_args: Vec<String>,
}

#[derive(Debug, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl TestProps {
pub fn from_file(testfile: &Path, config: &Config) -> Self {
let mut props = TestProps::new();
props.load_from(testfile, config);

props.kani_flags.extend(config.extra_args.iter().cloned());
props
}

Expand Down
15 changes: 14 additions & 1 deletion tools/compiletest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use std::io::{self};
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::time::{Duration, SystemTime};
use test::test::TestTimeOptions;
use test::ColorConfig;
use tracing::*;
use walkdir::WalkDir;
Expand Down Expand Up @@ -90,6 +91,14 @@ pub fn parse_config(args: Vec<String>) -> Config {
.optflag("", "dry-run", "don't actually run the tests")
.optflag("", "fix-expected",
"override all expected files that did not match the output. Tests will NOT fail when there is a mismatch")
.optflag("", "report-time",
"report the time of each test. Configuration is done via env variables, like \
rust unit tests.")
.optmulti("", "kani-flag",
"pass extra flags to Kani. Note that this may cause spurious failures if the \
passed flag conflicts with the test configuration. Only works for `kani`, \
`cargo-kani`, and `expected` modes."
, "ARG")
;

let (argv0, args_) = args.split_first().unwrap();
Expand Down Expand Up @@ -164,6 +173,10 @@ pub fn parse_config(args: Vec<String>) -> Config {
dry_run: matches.opt_present("dry-run"),
fix_expected: matches.opt_present("fix-expected"),
timeout,
time_opts: matches
.opt_present("report-time")
.then_some(TestTimeOptions::new_from_env(false)),
extra_args: matches.opt_strs("kani-flag"),
}
}

Expand Down Expand Up @@ -292,7 +305,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
skip: vec![],
list: false,
options: test::Options::new(),
time_options: None,
time_options: config.time_opts,
fail_fast: config.fail_fast,
force_run_in_process: false,
}
Expand Down
3 changes: 2 additions & 1 deletion tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ impl<'test> TestCx<'test> {
.arg("kani")
.arg("--target-dir")
.arg(self.output_base_dir().join("target"))
.current_dir(&parent_dir);
.current_dir(&parent_dir)
.args(&self.config.extra_args);
if test {
cargo.arg("--tests");
}
Expand Down