Skip to content

Commit 01247df

Browse files
committed
Support overriding config's command through CLI args
Commit ab25958 added support for oneliners, but it marked the 'command' arg as conflicting with the 'config' arg. This prevents using a config file with `go run|test -exec`. Moreover, having a way to override the command defined in the config file gives an easy way to exec into a VM to manually debug a failing command. Signed-off-by: Albin Kerouanton <[email protected]>
1 parent 80cd7b5 commit 01247df

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ struct Args {
4545
#[clap(short, long, conflicts_with = "config")]
4646
qemu_command: Option<String>,
4747
/// Command to run in kernel mode. `-` to get an interactive shell.
48-
#[clap(conflicts_with = "config")]
4948
command: Vec<String>,
5049
}
5150

@@ -135,6 +134,13 @@ fn config(args: &Args) -> Result<Vmtest> {
135134
.target
136135
.into_iter()
137136
.filter(|t| filter.is_match(&t.name))
137+
.map(|t| {
138+
let mut t = t;
139+
if !args.command.is_empty() {
140+
t.command = args.command.join(" ");
141+
}
142+
t
143+
})
138144
.collect::<Vec<_>>();
139145
let base = config_path.parent().unwrap();
140146
Vmtest::new(base, config)

tests/test.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,7 @@ fn test_run_custom_resources() {
393393
image: Some(uefi_image_t2.as_pathbuf()),
394394
uefi: true,
395395
// Should be in the 200 thousands, but it's variable.
396-
command: r#"bash -xc "cat /proc/meminfo | grep 'MemTotal: 2..... kB'""#
397-
.into(),
396+
command: r#"bash -xc "cat /proc/meminfo | grep 'MemTotal: 2..... kB'""#.into(),
398397
vm: VMConfig {
399398
memory: "256M".into(),
400399
..Default::default()

0 commit comments

Comments
 (0)