Merge pull request #363 from GuillaumeGomez/test-command
Add basics for `test` command in build system
This commit is contained in:
commit
d4a74fba1f
@ -5,6 +5,7 @@ mod build;
|
|||||||
mod config;
|
mod config;
|
||||||
mod prepare;
|
mod prepare;
|
||||||
mod rustc_info;
|
mod rustc_info;
|
||||||
|
mod test;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
macro_rules! arg_error {
|
macro_rules! arg_error {
|
||||||
@ -23,6 +24,7 @@ Available commands for build_system:
|
|||||||
|
|
||||||
prepare : Run prepare command
|
prepare : Run prepare command
|
||||||
build : Run build command
|
build : Run build command
|
||||||
|
test : Run test command
|
||||||
--help : Show this message"
|
--help : Show this message"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -30,6 +32,7 @@ Available commands for build_system:
|
|||||||
pub enum Command {
|
pub enum Command {
|
||||||
Prepare,
|
Prepare,
|
||||||
Build,
|
Build,
|
||||||
|
Test,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -40,6 +43,7 @@ fn main() {
|
|||||||
let command = match env::args().nth(1).as_deref() {
|
let command = match env::args().nth(1).as_deref() {
|
||||||
Some("prepare") => Command::Prepare,
|
Some("prepare") => Command::Prepare,
|
||||||
Some("build") => Command::Build,
|
Some("build") => Command::Build,
|
||||||
|
Some("test") => Command::Test,
|
||||||
Some("--help") => {
|
Some("--help") => {
|
||||||
usage();
|
usage();
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
@ -55,6 +59,7 @@ fn main() {
|
|||||||
if let Err(e) = match command {
|
if let Err(e) = match command {
|
||||||
Command::Prepare => prepare::run(),
|
Command::Prepare => prepare::run(),
|
||||||
Command::Build => build::run(),
|
Command::Build => build::run(),
|
||||||
|
Command::Test => test::run(),
|
||||||
} {
|
} {
|
||||||
eprintln!("Command failed to run: {e:?}");
|
eprintln!("Command failed to run: {e:?}");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
|
15
build_system/src/test.rs
Normal file
15
build_system/src/test.rs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
use crate::utils::run_command_with_output;
|
||||||
|
|
||||||
|
fn get_args<'a>(args: &mut Vec<&'a dyn AsRef<std::ffi::OsStr>>, extra_args: &'a Vec<String>) {
|
||||||
|
for extra_arg in extra_args {
|
||||||
|
args.push(extra_arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run() -> Result<(), String> {
|
||||||
|
let mut args: Vec<&dyn AsRef<std::ffi::OsStr>> = vec![&"bash", &"test.sh"];
|
||||||
|
let extra_args = std::env::args().skip(2).collect::<Vec<_>>();
|
||||||
|
get_args(&mut args, &extra_args);
|
||||||
|
let current_dir = std::env::current_dir().map_err(|error| format!("`current_dir` failed: {:?}", error))?;
|
||||||
|
run_command_with_output(args.as_slice(), Some(¤t_dir))
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user