Skip to content

Commit

Permalink
need to adapt the clap args
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Feb 3, 2025
1 parent 7dcb79e commit 72e5075
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
8 changes: 4 additions & 4 deletions ci/svd2rust-regress/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub struct TestAll {
#[clap(short = 'p', long = "svd2rust-path", default_value = default_svd2rust())]
pub current_bin_path: PathBuf,
#[clap(last = true)]
pub command: Option<String>,
pub command: Option<Vec<String>>,
// TODO: Specify smaller subset of tests? Maybe with tags?
// TODO: Compile svd2rust?
}
Expand Down Expand Up @@ -149,7 +149,7 @@ pub struct Test {
#[clap(short = 'p', long = "svd2rust-path", default_value = default_svd2rust())]
pub current_bin_path: PathBuf,
#[clap(last = true)]
pub command: Option<String>,
pub command: Option<Vec<String>>,
}

impl Test {
Expand Down Expand Up @@ -191,7 +191,7 @@ impl Test {
.ok_or_else(|| anyhow::anyhow!("no test found for chip"))?
.to_owned()
};
test.test(opts, &self.current_bin_path, self.command.as_deref())?;
test.test(opts, &self.current_bin_path, &self.command)?;
Ok(())
}
}
Expand Down Expand Up @@ -247,7 +247,7 @@ impl TestAll {
tests.par_iter().for_each(|t| {
let start = Instant::now();

match t.test(opt, &self.current_bin_path, self.command.as_deref()) {
match t.test(opt, &self.current_bin_path, &self.command) {
Ok(s) => {
if let Some(stderrs) = s {
let mut buf = String::new();
Expand Down
24 changes: 14 additions & 10 deletions ci/svd2rust-regress/src/svd_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl TestCase {
&self,
opts: &Opts,
bin_path: &Path,
cli_opts: Option<&str>,
cli_opts: &Option<Vec<String>>,
) -> Result<Option<Vec<PathBuf>>, TestError> {
let (chip_dir, mut process_stderr_paths) = self
.setup_case(&opts.output_dir, bin_path, cli_opts)
Expand Down Expand Up @@ -175,7 +175,7 @@ impl TestCase {
&self,
output_dir: &Path,
svd2rust_bin_path: &Path,
command: Option<&str>,
command: &Option<Vec<String>>,
) -> Result<(PathBuf, Vec<PathBuf>), TestError> {
let user = match std::env::var("USER") {
Ok(val) => val,
Expand Down Expand Up @@ -211,10 +211,6 @@ impl TestCase {
.capture_outputs(true, "cargo init", None, None, &[])
.with_context(|| "Failed to cargo init")?;

let command_split = command
.map(|cmd| shell_words::split(cmd).context("unable to split command into args"))
.transpose()?;

self.prepare_chip_test_toml(&chip_dir, command)?;
let chip_svd = self.prepare_svd_file(&chip_dir)?;
self.prepare_rust_toolchain_file(&chip_dir)?;
Expand All @@ -228,7 +224,7 @@ impl TestCase {
&chip_dir,
&lib_rs_file,
&svd2rust_err_file,
&command_split,
command,
)?;
process_stderr_paths.push(svd2rust_err_file);
match self.arch {
Expand Down Expand Up @@ -331,7 +327,11 @@ impl TestCase {
Ok(())
}

fn prepare_chip_test_toml(&self, chip_dir: &Path, opts: Option<&str>) -> Result<(), TestError> {
fn prepare_chip_test_toml(
&self,
chip_dir: &Path,
opts: &Option<Vec<String>>,
) -> Result<(), TestError> {
let svd_toml = path_helper_base(chip_dir, &["Cargo.toml"]);
let mut file = OpenOptions::new()
.append(true)
Expand All @@ -348,8 +348,12 @@ impl TestCase {
Target::XtensaLX => [].iter(),
Target::None => unreachable!(),
})
.chain(if opts.unwrap_or_default().contains("--atomics") {
CRATES_ATOMICS.iter()
.chain(if let Some(opts) = opts {
if opts.iter().find(|v| v.contains("atomics")).is_some() {
CRATES_ATOMICS.iter()
} else {
[].iter()
}
} else {
[].iter()
})
Expand Down

0 comments on commit 72e5075

Please sign in to comment.