Skip to content

Commit

Permalink
rename y.sh test --clean-ui-tests to y.sh clean ui-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rowan-sl committed Jan 18, 2024
1 parent 1a8e0c3 commit 94ed9d1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 46 deletions.
76 changes: 45 additions & 31 deletions build_system/src/clean.rs
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
use crate::utils::remove_file;
use crate::utils::{remove_file, run_command};

use std::fs::remove_dir_all;

#[derive(Default)]
struct CleanArg {
all: bool,
enum CleanArg {
/// `clean all`
All,
/// `clean ui-tests`
UiTests,
/// `clean --help`
#[default]
Help,
}

impl CleanArg {
fn new() -> Result<Option<Self>, String> {
let mut args = CleanArg::default();

fn new() -> Result<Self, String> {
// We skip the binary and the "clean" option.
for arg in std::env::args().skip(2) {
match arg.as_str() {
"all" => args.all = true,
"--help" => {
Self::usage();
return Ok(None);
}
a => return Err(format!("Unknown argument `{}`", a)),
}
return match arg.as_str() {
"all" => Ok(Self::All),
"ui-tests" => Ok(Self::UiTests),
"--help" => Ok(Self::Help),
a => Err(format!("Unknown argument `{}`", a)),
};
}
Ok(Some(args))
Ok(Self::default())
}
}

fn usage() {
println!(
r#"
`clean` command help:
fn usage() {
println!(
r#"
`clean` command help:
all : Clean all data
--help : Show this help
"#
)
}
all : Clean all data
ui-tests : Clean ui tests
--help : Show this help
"#
)
}

fn clean_all() -> Result<(), String> {
Expand All @@ -60,14 +63,25 @@ fn clean_all() -> Result<(), String> {
Ok(())
}

pub fn run() -> Result<(), String> {
let args = match CleanArg::new()? {
Some(a) => a,
None => return Ok(()),
};
fn clean_ui_tests() -> Result<(), String> {
run_command(
&[
&"find",
&"rust/build/x86_64-unknown-linux-gnu/test/ui/",
&"-name",
&"stamp",
&"-delete",
],
None,
)?;
Ok(())
}

if args.all {
clean_all()?;
pub fn run() -> Result<(), String> {
match CleanArg::new()? {
CleanArg::All => clean_all()?,
CleanArg::UiTests => clean_ui_tests()?,
CleanArg::Help => usage(),
}
Ok(())
}
15 changes: 0 additions & 15 deletions build_system/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ fn get_runners() -> Runners {
("Run failing rustc tests", test_failing_rustc),
);
runners.insert("--test-libcore", ("Run libcore tests", test_libcore));
runners.insert("--clean-ui-tests", ("Clean ui tests", clean_ui_tests));
runners.insert("--clean", ("Empty cargo target directory", clean));
runners.insert("--build-sysroot", ("Build sysroot", build_sysroot));
runners.insert("--std-tests", ("Run std tests", std_tests));
Expand Down Expand Up @@ -1086,20 +1085,6 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
})
}

fn clean_ui_tests(_env: &Env, _args: &TestArg) -> Result<(), String> {
run_command(
&[
&"find",
&"rust/build/x86_64-unknown-linux-gnu/test/ui/",
&"-name",
&"stamp",
&"-delete",
],
None,
)?;
Ok(())
}

fn run_all(env: &Env, args: &TestArg) -> Result<(), String> {
clean(env, args)?;
mini_tests(env, args)?;
Expand Down

0 comments on commit 94ed9d1

Please sign in to comment.