浏览代码

Run AML tests on CI, no_compile option

Isaac Woods 5 年之前
父节点
当前提交
b81a8bf423
共有 2 个文件被更改,包括 19 次插入3 次删除
  1. 4 0
      .travis.yml
  2. 15 3
      aml_tester/src/main.rs

+ 4 - 0
.travis.yml

@@ -20,6 +20,9 @@ branches:
     # This allows building of pull requests
     - master
 
+before_install:
+  - sudo apt-get install -y acpica-tools
+
 before_script:
   - rustup component add rustfmt-preview
 
@@ -27,6 +30,7 @@ script:
   - cargo fmt --all -- --check
   - cargo build --all
   - cargo test --all
+  - cargo run --bin aml_tester -- -p tests
 
 notifications:
   email: change

+ 15 - 3
aml_tester/src/main.rs

@@ -15,6 +15,7 @@ use std::{
     ffi::OsStr,
     fs::{self, File},
     io::Read,
+    ops::Not,
     path::Path,
     process::Command,
 };
@@ -25,12 +26,15 @@ fn main() -> std::io::Result<()> {
         .author("Isaac Woods")
         .about("Compiles and tests ASL files")
         .arg(Arg::with_name("path").short("p").long("path").required(true).takes_value(true))
+        .arg(Arg::with_name("no_compile").long("no-compile"))
         .get_matches();
 
     println!("Running tests in directory: {:?}", matches.value_of("path"));
     let dir_path = Path::new(matches.value_of("path").unwrap());
 
-    compile_asl_files(dir_path)?;
+    if !matches.is_present("no_compile") {
+        compile_asl_files(dir_path)?;
+    }
 
     /*
      * Now, we find all the AML files in the directory, and try to compile them with the `aml`
@@ -75,11 +79,19 @@ fn main() -> std::io::Result<()> {
 }
 
 fn compile_asl_files(dir_path: &Path) -> std::io::Result<()> {
-    let asl_files = fs::read_dir(dir_path)?
+    let mut asl_files = fs::read_dir(dir_path)?
         .filter(|entry| {
             entry.is_ok() && entry.as_ref().unwrap().path().extension() == Some(OsStr::new("asl"))
         })
-        .map(|file| file.unwrap());
+        .map(|file| file.unwrap())
+        .peekable();
+
+    if !asl_files.peek().is_none() {
+        // Test if `iasl` is installed, so we can give a good error if it's not
+        if Command::new("iasl").arg("-v").status().unwrap().success().not() {
+            panic!("`iasl` is not installed, but we want to compile some ASL files! Pass --no-compile, or install `iasl`");
+        }
+    }
 
     for file in asl_files {
         let aml_path = file.path().with_extension(OsStr::new("aml"));