Skip to content

Commit 72e5075

Browse files
committed
need to adapt the clap args
1 parent 7dcb79e commit 72e5075

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

ci/svd2rust-regress/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub struct TestAll {
100100
#[clap(short = 'p', long = "svd2rust-path", default_value = default_svd2rust())]
101101
pub current_bin_path: PathBuf,
102102
#[clap(last = true)]
103-
pub command: Option<String>,
103+
pub command: Option<Vec<String>>,
104104
// TODO: Specify smaller subset of tests? Maybe with tags?
105105
// TODO: Compile svd2rust?
106106
}
@@ -149,7 +149,7 @@ pub struct Test {
149149
#[clap(short = 'p', long = "svd2rust-path", default_value = default_svd2rust())]
150150
pub current_bin_path: PathBuf,
151151
#[clap(last = true)]
152-
pub command: Option<String>,
152+
pub command: Option<Vec<String>>,
153153
}
154154

155155
impl Test {
@@ -191,7 +191,7 @@ impl Test {
191191
.ok_or_else(|| anyhow::anyhow!("no test found for chip"))?
192192
.to_owned()
193193
};
194-
test.test(opts, &self.current_bin_path, self.command.as_deref())?;
194+
test.test(opts, &self.current_bin_path, &self.command)?;
195195
Ok(())
196196
}
197197
}
@@ -247,7 +247,7 @@ impl TestAll {
247247
tests.par_iter().for_each(|t| {
248248
let start = Instant::now();
249249

250-
match t.test(opt, &self.current_bin_path, self.command.as_deref()) {
250+
match t.test(opt, &self.current_bin_path, &self.command) {
251251
Ok(s) => {
252252
if let Some(stderrs) = s {
253253
let mut buf = String::new();

ci/svd2rust-regress/src/svd_test.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl TestCase {
141141
&self,
142142
opts: &Opts,
143143
bin_path: &Path,
144-
cli_opts: Option<&str>,
144+
cli_opts: &Option<Vec<String>>,
145145
) -> Result<Option<Vec<PathBuf>>, TestError> {
146146
let (chip_dir, mut process_stderr_paths) = self
147147
.setup_case(&opts.output_dir, bin_path, cli_opts)
@@ -175,7 +175,7 @@ impl TestCase {
175175
&self,
176176
output_dir: &Path,
177177
svd2rust_bin_path: &Path,
178-
command: Option<&str>,
178+
command: &Option<Vec<String>>,
179179
) -> Result<(PathBuf, Vec<PathBuf>), TestError> {
180180
let user = match std::env::var("USER") {
181181
Ok(val) => val,
@@ -211,10 +211,6 @@ impl TestCase {
211211
.capture_outputs(true, "cargo init", None, None, &[])
212212
.with_context(|| "Failed to cargo init")?;
213213

214-
let command_split = command
215-
.map(|cmd| shell_words::split(cmd).context("unable to split command into args"))
216-
.transpose()?;
217-
218214
self.prepare_chip_test_toml(&chip_dir, command)?;
219215
let chip_svd = self.prepare_svd_file(&chip_dir)?;
220216
self.prepare_rust_toolchain_file(&chip_dir)?;
@@ -228,7 +224,7 @@ impl TestCase {
228224
&chip_dir,
229225
&lib_rs_file,
230226
&svd2rust_err_file,
231-
&command_split,
227+
command,
232228
)?;
233229
process_stderr_paths.push(svd2rust_err_file);
234230
match self.arch {
@@ -331,7 +327,11 @@ impl TestCase {
331327
Ok(())
332328
}
333329

334-
fn prepare_chip_test_toml(&self, chip_dir: &Path, opts: Option<&str>) -> Result<(), TestError> {
330+
fn prepare_chip_test_toml(
331+
&self,
332+
chip_dir: &Path,
333+
opts: &Option<Vec<String>>,
334+
) -> Result<(), TestError> {
335335
let svd_toml = path_helper_base(chip_dir, &["Cargo.toml"]);
336336
let mut file = OpenOptions::new()
337337
.append(true)
@@ -348,8 +348,12 @@ impl TestCase {
348348
Target::XtensaLX => [].iter(),
349349
Target::None => unreachable!(),
350350
})
351-
.chain(if opts.unwrap_or_default().contains("--atomics") {
352-
CRATES_ATOMICS.iter()
351+
.chain(if let Some(opts) = opts {
352+
if opts.iter().find(|v| v.contains("atomics")).is_some() {
353+
CRATES_ATOMICS.iter()
354+
} else {
355+
[].iter()
356+
}
353357
} else {
354358
[].iter()
355359
})

0 commit comments

Comments
 (0)