diff --git a/ci/expected/baseline.run b/ci/expected/baseline.run deleted file mode 100644 index fa3822f696..0000000000 --- a/ci/expected/baseline.run +++ /dev/null @@ -1,4 +0,0 @@ -init(baseline = Instant(0)) -foo(baseline = Instant(0)) -UART0(baseline = Instant(904)) -foo(baseline = Instant(904)) \ No newline at end of file diff --git a/ci/expected/cfg.run b/ci/expected/cfg.run deleted file mode 100644 index b584958b38..0000000000 --- a/ci/expected/cfg.run +++ /dev/null @@ -1,2 +0,0 @@ -foo has been called 1 time -foo has been called 2 times diff --git a/ci/expected/late.run b/ci/expected/late.run deleted file mode 100644 index 6d3d3e43e5..0000000000 --- a/ci/expected/late.run +++ /dev/null @@ -1 +0,0 @@ -received message: 42 diff --git a/ci/expected/not-send.run b/ci/expected/not-send.run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ci/expected/ramfunc.grep.bar b/ci/expected/ramfunc.grep.bar deleted file mode 100644 index 1fa5bad1dd..0000000000 --- a/ci/expected/ramfunc.grep.bar +++ /dev/null @@ -1 +0,0 @@ -20000000 t ramfunc::bar::h9d6714fe5a3b0c89 \ No newline at end of file diff --git a/ci/expected/ramfunc.grep.foo b/ci/expected/ramfunc.grep.foo deleted file mode 100644 index 845f277f73..0000000000 --- a/ci/expected/ramfunc.grep.foo +++ /dev/null @@ -1 +0,0 @@ -00000162 t ramfunc::foo::h30e7789b08c08e19 \ No newline at end of file diff --git a/ci/expected/resource.run b/ci/expected/resource.run deleted file mode 100644 index 9b60960f44..0000000000 --- a/ci/expected/resource.run +++ /dev/null @@ -1,2 +0,0 @@ -UART1: local_to_uart1 = 1 -UART0: local_to_uart0 = 1 diff --git a/ci/expected/shared-with-init.run b/ci/expected/shared-with-init.run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ci/expected/singleton.run b/ci/expected/singleton.run deleted file mode 100644 index c55dc1ac76..0000000000 --- a/ci/expected/singleton.run +++ /dev/null @@ -1,2 +0,0 @@ -bar(2) -foo(1) diff --git a/ci/expected/types.run b/ci/expected/types.run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/xtask/src/build.rs b/xtask/src/build.rs index 904e9177c0..148a9fde29 100644 --- a/xtask/src/build.rs +++ b/xtask/src/build.rs @@ -1,9 +1,4 @@ -use std::{ - fs, - path::{Path, PathBuf}, -}; - -use crate::{command::BuildMode, TestRunError}; +use std::{fs, path::Path}; const HEX_BUILD_ROOT: &str = "ci/builds"; @@ -16,38 +11,3 @@ pub fn init_build_dir() -> anyhow::Result<()> { fs::create_dir_all(HEX_BUILD_ROOT) .map_err(|_| anyhow::anyhow!("Could not create directory: {}", HEX_BUILD_ROOT)) } - -pub fn build_hexpath( - example: &str, - features: Option<&str>, - build_mode: BuildMode, - build_num: u32, -) -> anyhow::Result { - let features = match features { - Some(f) => f, - None => "", - }; - - let filename = format!("{}_{}_{}_{}.hex", example, features, build_mode, build_num); - - let mut path = PathBuf::from(HEX_BUILD_ROOT); - path.push(filename); - - path.into_os_string() - .into_string() - .map_err(|e| anyhow::Error::new(TestRunError::PathConversionError(e))) -} - -pub fn compare_builds(expected: String, got: String) -> anyhow::Result<()> { - let buf_1 = std::fs::read_to_string(expected.clone())?; - let buf_2 = std::fs::read_to_string(got.clone())?; - - if buf_1 != buf_2 { - return Err(anyhow::Error::new(TestRunError::FileCmpError { - expected, - got, - })); - } - - Ok(()) -} diff --git a/xtask/src/command.rs b/xtask/src/command.rs index d94a7ab3d0..2f719bf5c9 100644 --- a/xtask/src/command.rs +++ b/xtask/src/command.rs @@ -1,7 +1,7 @@ use crate::{RunResult, TestRunError}; use core::fmt; use os_pipe::pipe; -use std::{fs::File, io::Read, path::Path, process::Command}; +use std::{fs::File, io::Read, process::Command}; #[allow(dead_code)] #[derive(Debug, Clone, Copy, PartialEq)] @@ -18,32 +18,23 @@ pub enum CargoCommand<'a> { features: Option<&'a str>, mode: BuildMode, }, - Build { - example: &'a str, + BuildAll { target: &'a str, features: Option<&'a str>, mode: BuildMode, }, - Objcopy { - example: &'a str, - target: &'a str, - features: Option<&'a str>, - ihex: &'a str, - }, - Size { - example_paths: Vec<&'a Path>, - }, - Clean, + // Size { + // example_paths: Vec<&'a Path>, + // }, + // Clean, } impl<'a> CargoCommand<'a> { fn name(&self) -> &str { match self { CargoCommand::Run { .. } => "run", - CargoCommand::Size { example_paths: _ } => "rust-size", - CargoCommand::Clean => "clean", - CargoCommand::Build { .. } => "build", - CargoCommand::Objcopy { .. } => "objcopy", + // CargoCommand::Size { example_paths: _ } => "rust-size", + CargoCommand::BuildAll { .. } => "build", } } @@ -54,12 +45,6 @@ impl<'a> CargoCommand<'a> { target, features, mode, - } - | CargoCommand::Build { - example, - target, - features, - mode, } => { let mut args = vec![self.name(), "--example", example, "--target", target]; @@ -71,26 +56,23 @@ impl<'a> CargoCommand<'a> { } args } - CargoCommand::Size { example_paths } => { - example_paths.iter().map(|p| p.to_str().unwrap()).collect() - } - CargoCommand::Clean => vec!["clean"], - CargoCommand::Objcopy { - example, + CargoCommand::BuildAll { target, features, - ihex, + mode, } => { - let mut args = vec![self.name(), "--example", example, "--target", target]; + let mut args = vec![self.name(), "--examples", "--target", target]; if let Some(feature_name) = features { args.extend_from_slice(&["--features", feature_name]); } - - // this always needs to go at the end - args.extend_from_slice(&["--", "-O", "ihex", ihex]); + if let Some(flag) = mode.to_flag() { + args.push(flag); + } args - } + } // CargoCommand::Size { example_paths } => { + // example_paths.iter().map(|p| p.to_str().unwrap()).collect() + // } } } @@ -99,7 +81,7 @@ impl<'a> CargoCommand<'a> { // we need to cheat a little here: // `cargo size` can't be ran on multiple files, so we're using `rust-size` instead – // which isn't a command that starts wizh `cargo`. So we're sneakily swapping them out :) - CargoCommand::Size { .. } => "rust-size", + // CargoCommand::Size { .. } => "rust-size", _ => "cargo", } } diff --git a/xtask/src/main.rs b/xtask/src/main.rs index ad8719ad53..76ce04bd4c 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -14,7 +14,7 @@ use std::{ use structopt::StructOpt; use crate::{ - build::{build_hexpath, compare_builds, init_build_dir}, + build::init_build_dir, command::{run_command, run_successful, BuildMode, CargoCommand}, }; @@ -93,25 +93,6 @@ fn main() -> anyhow::Result<()> { }) .collect(); - // let examples = &[ - // "idle", - // "init", - // "hardware", - // "preempt", - // "binds", - // "lock", - // "multilock", - // "only-shared-access", - // "task", - // "message", - // "capacity", - // "not-sync", - // "generics", - // "pool", - // "ramfunc", - // "peripherals-taken", - // ]; - let opts = Options::from_args(); let target = &opts.target; @@ -120,11 +101,9 @@ fn main() -> anyhow::Result<()> { if target == "all" { for t in targets { run_test(t, &examples)?; - build_test(t, &examples)?; } } else if targets.contains(&target.as_str()) { run_test(&target, &examples)?; - build_test(&target, &examples)?; } else { eprintln!( "The target you specified is not available. Available targets are:\ @@ -139,6 +118,12 @@ fn main() -> anyhow::Result<()> { } fn run_test(target: &str, examples: &[String]) -> anyhow::Result<()> { + arm_example(&CargoCommand::BuildAll { + target, + features: None, + mode: BuildMode::Release, + })?; + for example in examples { let cmd = CargoCommand::Run { example, @@ -147,37 +132,16 @@ fn run_test(target: &str, examples: &[String]) -> anyhow::Result<()> { mode: BuildMode::Release, }; - arm_example(&cmd, 1)?; - - arm_example( - &CargoCommand::Build { - example, - target, - features: None, - mode: BuildMode::Release, - }, - 1, - )?; + arm_example(&cmd)?; } Ok(()) } // run example binary `example` -fn arm_example(command: &CargoCommand, build_num: u32) -> anyhow::Result<()> { +fn arm_example(command: &CargoCommand) -> anyhow::Result<()> { match *command { - CargoCommand::Run { - example, - target, - features, - mode, - } - | CargoCommand::Build { - example, - target, - features, - mode, - } => { + CargoCommand::Run { example, .. } => { let run_file = format!("{}.run", example); let expected_output_file = ["ci", "expected", &run_file] .iter() @@ -197,77 +161,14 @@ fn arm_example(command: &CargoCommand, build_num: u32) -> anyhow::Result<()> { _ => (), } - // now, prepare to objcopy - let hexpath = build_hexpath(example, features, mode, build_num)?; - - run_command(&CargoCommand::Objcopy { - example, - target, - features, - ihex: &hexpath, - })?; - Ok(()) } - _ => Err(anyhow::Error::new(TestRunError::IncompatibleCommand)), + CargoCommand::BuildAll { .. } => { + // command is either build or run + let cargo_run_result = run_command(&command)?; + println!("{}", cargo_run_result.output); + + Ok(()) + } // _ => Err(anyhow::Error::new(TestRunError::IncompatibleCommand)), } } - -fn build_test(target: &str, examples: &[String]) -> anyhow::Result<()> { - run_command(&CargoCommand::Clean)?; - - let mut built = vec![]; - let build_path: PathBuf = ["target", target, "release", "examples"].iter().collect(); - - for example in examples { - let no_features = None; - arm_example( - &CargoCommand::Build { - target, - example, - mode: BuildMode::Release, - features: no_features, - }, - 2, - )?; - let expected = build_hexpath(example, no_features, BuildMode::Release, 1)?; - let got = build_hexpath(example, no_features, BuildMode::Release, 2)?; - - compare_builds(expected, got)?; - - arm_example( - &CargoCommand::Build { - target, - example, - mode: BuildMode::Release, - features: no_features, - }, - 2, - )?; - let expected = build_hexpath(example, no_features, BuildMode::Release, 1)?; - let got = build_hexpath(example, no_features, BuildMode::Release, 2)?; - - compare_builds(expected, got)?; - - built.push(build_path.join(example)); - } - - let example_paths: Vec<&Path> = built.iter().map(|p| p.as_path()).collect(); - let size_run_result = run_command(&CargoCommand::Size { example_paths })?; - - if size_run_result.exit_status.success() { - println!("{}", size_run_result.output); - } - - Ok(()) -} - -// /// Check if lines in `output` contain `pattern` and print matching lines -// fn print_from_output(pattern: &str, lines: &str) { -// let lines = lines.split("\n"); -// for line in lines { -// if line.contains(pattern) { -// println!("{}", line); -// } -// } -// }