From 839f3144391a3c2819ccec4029240f6d478d45ac Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Fri, 12 May 2017 22:03:43 -0400 Subject: [PATCH] Make appveyor continuous integration tests pass (#196) --- Cargo.lock | 22 ++++++++++++++++++++++ Cargo.toml | 1 + appveyor.yml | 3 +++ src/integration.rs | 41 +++++++++++++++++++++++++++++++++++------ src/test_utils.rs | 22 +++++++++++----------- 5 files changed, 72 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index effe0c2..78875b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,6 +14,7 @@ dependencies = [ "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -143,6 +144,15 @@ name = "regex-syntax" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "same-file" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "strsim" version = "0.6.0" @@ -203,6 +213,16 @@ name = "vec_map" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "walkdir" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "winapi" version = "0.2.8" @@ -231,6 +251,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "022e0636ec2519ddae48154b028864bdce4eaf7d35226ab8e65c611be97b189d" "checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" +"checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7" "checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694" "checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6" "checksum term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2b6b55df3198cc93372e85dd2ed817f0e38ce8cc0f22eb32391bfad9c4bf209" @@ -240,5 +261,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f" "checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" "checksum vec_map 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8cdc8b93bd0198ed872357fb2e667f7125646b1762f16d60b2c96350d361897" +"checksum walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bb08f9e670fab86099470b97cd2b252d6527f0b3cc1401acdb595ffc9dd288ff" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/Cargo.toml b/Cargo.toml index 3713920..535b279 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,3 +21,4 @@ libc = "^0.2.21" regex = "^0.1.77" tempdir = "^0.3.5" unicode-width = "^0.1.3" +walkdir = "^1.0.7" diff --git a/appveyor.yml b/appveyor.yml index 72b5255..e338f44 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,9 @@ # Based on the "trust" template v0.1.1 # https://github.com/japaric/trust/tree/v0.1.1 +init: + - cmd: set PATH=%PATH%;C:\cygwin64\bin + environment: global: # DONE This is the Rust channel that build jobs will use by default but can be diff --git a/src/integration.rs b/src/integration.rs index 1964bf5..1fe32d7 100644 --- a/src/integration.rs +++ b/src/integration.rs @@ -1,9 +1,11 @@ extern crate tempdir; extern crate brev; +extern crate walkdir; use ::prelude::*; use tempdir::TempDir; use std::str; +use std::sync::{Once, ONCE_INIT}; /// Instantiate integration tests for a given test case using /// sh, dash, and bash. @@ -17,9 +19,9 @@ macro_rules! integration_test { name: $name:ident, justfile: $text:tt, args: ($($arg:tt)*), - stdout: $stdout:tt, - stderr: $stderr:tt, - status: $status:tt, + stdout: $stdout:expr, + stderr: $stderr:expr, + status: $status:expr, ) => { mod $name { use ::prelude::*; @@ -35,6 +37,8 @@ macro_rules! integration_test { } } +static ONCE: Once = ONCE_INIT; + fn integration_test( shell: &str, justfile: &str, @@ -50,8 +54,33 @@ fn integration_test( path.push("justfile"); brev::dump(path, justfile); + let mut once = false; + + ONCE.call_once(|| { once = true; }); + + if once { + println!("tmpdir: {:?}", tmp.path()); + println!("cwd: {:?}", env::current_dir().unwrap()); + println!(); + + for (key, val) in env::vars() { + println!("{} = {}", key, val); + } + + for entry in self::walkdir::WalkDir::new("target") { + let entry = entry.unwrap(); + println!("{}", entry.path().display()); + } + + println!(); + } + let binary = super::test_utils::just_binary_path(); + if once { + println!("binary: {:?}", binary); + } + let output = process::Command::new(&binary) .current_dir(tmp.path()) .args(args) @@ -730,12 +759,12 @@ integration_test! { justfile: "", args: ("--quiet", "--dry-run"), stdout: "", - stderr: "error: The argument '--dry-run' cannot be used with '--quiet' + stderr: &format!("error: The argument '--dry-run' cannot be used with '--quiet' USAGE: - just --color --quiet --shell + just{} --color --quiet --shell -For more information try --help\n", +For more information try --help\n", env::consts::EXE_SUFFIX), status: 1, } diff --git a/src/test_utils.rs b/src/test_utils.rs index ffbd5d1..5672a11 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -3,22 +3,22 @@ extern crate glob; use ::prelude::*; pub fn just_binary_path() -> PathBuf { - let mut binary = env::current_dir().unwrap(); - binary.push("target"); - binary.push("debug"); - binary.push("just"); + let exe = String::from("just") + env::consts::EXE_SUFFIX; - if !binary.is_file() { + let mut path = env::current_dir().unwrap(); + path.push("target"); + path.push("debug"); + path.push(&exe); + + if !path.is_file() { let mut pattern = env::current_dir().unwrap(); pattern.push("target"); pattern.push("*"); pattern.push("debug"); - pattern.push("just"); - for path in glob::glob(pattern.to_str().unwrap()).unwrap() { - binary = path.unwrap(); - break; - } + pattern.push(&exe); + path = glob::glob(pattern.to_str().unwrap()).unwrap() + .take_while(Result::is_ok).nth(0).unwrap().unwrap(); } - binary + path }