diff --git a/.travis.yml b/.travis.yml index 31a72b7..86d2ae7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,115 @@ -language: rust -rust: - - stable - - beta - - nightly -matrix: - allow_failures: - - rust: nightly -notifications: - email: false +# Based on the "trust" template v0.1.1 +# https://github.com/japaric/trust/tree/v0.1.1 +dist: trusty +language: rust +services: docker +sudo: required + +# DONE Rust builds on stable by default, this can be +# overridden on a case by case basis down below. + +env: + global: + # DONE Update this to match the name of your project. + - CRATE_NAME=just + +matrix: + # DONE These are all the build jobs. Adjust as necessary. Comment out what you + # don't need + include: + # Linux + - env: TARGET=i686-unknown-linux-gnu + - env: TARGET=i686-unknown-linux-musl + - env: TARGET=x86_64-unknown-linux-gnu + - env: TARGET=x86_64-unknown-linux-musl + + # OSX + - env: TARGET=i686-apple-darwin + os: osx + before_install: + - set -e + - brew install dash + - env: TARGET=x86_64-apple-darwin + os: osx + before_install: + - set -e + - brew install dash + + # *BSD + - env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1 + - env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1 + - env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1 + + # Other architectures + - env: TARGET=aarch64-unknown-linux-gnu + - env: TARGET=armv7-unknown-linux-gnueabihf + - env: TARGET=mips-unknown-linux-gnu + - env: TARGET=mips64-unknown-linux-gnuabi64 + - env: TARGET=mips64el-unknown-linux-gnuabi64 + - env: TARGET=mipsel-unknown-linux-gnu + - env: TARGET=powerpc64-unknown-linux-gnu + - env: TARGET=powerpc64le-unknown-linux-gnu + - env: TARGET=s390x-unknown-linux-gnu DISABLE_TESTS=1 + + # powerpc-unknown-linux-gnu is currently failing some + # tests with 'Unsupported syscall: 384' + - env: TARGET=powerpc-unknown-linux-gnu DISABLE_TESTS=1 + + # Testing other channels + - env: TARGET=x86_64-unknown-linux-gnu + rust: nightly + - env: TARGET=x86_64-apple-darwin + os: osx + rust: nightly + before_install: + - set -e + - brew install dash + +before_install: set -e + +install: + - sh ci/install.sh + - source ~/.cargo/env || true + +script: + - bash ci/script.sh + +after_script: set +e + +before_deploy: + - sh ci/before_deploy.sh + +deploy: + # DONE update `api_key.secure` + # - Create a `public_repo` GitHub token. Go to: https://github.com/settings/tokens/new + # - Encrypt it: `travis encrypt 0123456789012345678901234567890123456789 + # - Paste the output down here + api_key: + secure: "YaOabSTnNtl0h6DwxtiKG+W6eE8swQSMXlE20oZvTBDpCPWa6daHSVNWBwthudlrcZLWvRuQmy+we62OELzc1f5AwNyyTZ0fgtiqcs7+MY3edSyBQHUIPbzZGeCsbvb1efQzJDZaU5u6TaeNvwqEcIEU2BTSl/3F7RrG+1CgwtnsIp4zrAeaJBHhY0RZCvpdfOica9+m5Dz37q0acl2xdVX9SGv9d+F1WZ2QsB35UCfFVJQ21/KE6QWYZIyEvjudZ7XbeafTnOZ9Xcmn0Mpo9OfhiG3/OP+wN8hOH26CjQR1ru5ftnmdXigE/YOAkUgeRfcFv1rptq6+Datrfu0sHvAM/zSAiqbakHnwn1zVLWe8WJHGjnvh428jAhMK85y1cStsnVsxnciqmWlnpr3bBL2Nopi9OuAOMJ1SG5jNmLCctQwCJubxzrFLaJRKeUefDye+L9u4/EyiQmx0p7b1IsBlEjYe1ammzgBdEA26fUmzM6gJKcOLKmH9CLpcBYiaGuAaiHIBW5Cbq05kB2fVay+947YQOFEnmMJm2sZMkITv1ZnofWqDoyj9BVttczrKUDho3oMBNu9jsrAO0ncqUnsao3aqiuKIVjmPgc2uV8c+UlEpqHu40PNAfF70KkWkefYeqqGMGKzuB1SnMr+4XmQg0GPnK2MuEHzQOmvASuo=" + file_glob: true + file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.* + on: + # DONE Here you can pick which targets will generate binary releases + # In this example, there are some targets that are tested using the stable + # and nightly channels. This condition makes sure there is only one release + # for such targets and that's generated using the stable channel + condition: $TRAVIS_RUST_VERSION = stable + tags: true + provider: releases + skip_cleanup: true + +cache: cargo +before_cache: + # Travis can't cache files that are not readable by "others" + - chmod -R a+r $HOME/.cargo + +branches: + only: + # release tags + - /^v\d+\.\d+\.\d+.*$/ + - master + +notifications: + email: + on_success: never diff --git a/Cargo.lock b/Cargo.lock index c626871..78875b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,14 +5,16 @@ dependencies = [ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "brev 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.23.3 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.24.1 (registry+https://github.com/rust-lang/crates.io-index)", "edit-distance 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", "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]] @@ -34,7 +36,7 @@ version = "0.2.2" 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)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -54,7 +56,7 @@ dependencies = [ [[package]] name = "clap" -version = "2.23.3" +version = "2.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -106,7 +108,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.21" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -114,7 +116,7 @@ name = "memchr" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -122,7 +124,7 @@ name = "rand" version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -142,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" @@ -161,7 +172,7 @@ version = "0.3.0" 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)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -171,7 +182,7 @@ version = "2.0.0" 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)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -202,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" @@ -218,18 +239,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d912da0db7fa85514874458ca3651fe2cddace8d0b0505571dbdcd41ab490159" "checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4" "checksum brev 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "3c162b21af86dda249325939ce983b993b67341a38eaf2d43121704231d54fb6" -"checksum clap 2.23.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f57e9b63057a545ad2ecd773ea61e49422ed1b1d63d74d5da5ecaee55b3396cd" +"checksum clap 2.24.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7541069be0b8aec41030802abe8b5cdef0490070afaa55418adea93b1e431e0" "checksum edit-distance 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cd50a61206c09132fdf9cbaccc64a82cfccb6be528453903e03d4eb4ec80a61d" "checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4833d6978da405305126af4ac88569b5d71ff758581ce5a987dbfa3755f694fc" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" -"checksum libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)" = "88ee81885f9f04bff991e306fea7c1c60a5f0f9e409e99f6b40e3311a3363135" +"checksum libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)" = "babb8281da88cba992fa1f4ddec7d63ed96280a1a53ec9b919fd37b53d71e502" "checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" "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" @@ -239,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 10b46d7..535b279 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,9 @@ authors = ["Casey Rodarmor "] license = "WTFPL OR MIT OR Apache-2.0" homepage = "https://github.com/casey/just" +[dev-dependencies] +glob = "^0.2.11" + [dependencies] ansi_term = "^0.9.0" atty = "^0.2.1" @@ -18,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 new file mode 100644 index 0000000..72b5255 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,93 @@ +# Based on the "trust" template v0.1.1 +# https://github.com/japaric/trust/tree/v0.1.1 + +environment: + global: + # DONE This is the Rust channel that build jobs will use by default but can be + # overridden on a case by case basis down below + RUST_VERSION: stable + + # DONE Update this to match the name of your project. + CRATE_NAME: just + + # DONE These are all the build jobs. Adjust as necessary. Comment out what you + # don't need + matrix: + # MinGW + - TARGET: i686-pc-windows-gnu + - TARGET: x86_64-pc-windows-gnu + + # MSVC + - TARGET: i686-pc-windows-msvc + - TARGET: x86_64-pc-windows-msvc + + # Testing other channels + - TARGET: x86_64-pc-windows-gnu + RUST_VERSION: nightly + - TARGET: x86_64-pc-windows-msvc + RUST_VERSION: nightly + +install: + - ps: >- + If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') { + $Env:PATH += ';C:\msys64\mingw64\bin' + } ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') { + $Env:PATH += ';C:\msys64\mingw32\bin' + } + - curl -sSf -o rustup-init.exe https://win.rustup.rs/ + - rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_VERSION% + - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin + - rustc -Vv + - cargo -V + +# DONE This is the "test phase", tweak it as you see fit +test_script: + # we don't run the "test phase" when doing deploys + - if [%APPVEYOR_REPO_TAG%]==[false] ( + cargo build --target %TARGET% && + cargo build --target %TARGET% --release && + cargo test --target %TARGET% && + cargo test --target %TARGET% --release && + cargo run --target %TARGET% && + cargo run --target %TARGET% --release + ) + +before_deploy: + # DONE Update this to build the artifacts that matter to you + - cargo rustc --target %TARGET% --release --bin just -- -C lto + - ps: ci\before_deploy.ps1 + +deploy: + artifact: /.*\.zip/ + # DONE update `auth_token.secure` + # - Create a `public_repo` GitHub token. Go to: https://github.com/settings/tokens/new + # - Encrypt it. Go to https://ci.appveyor.com/tools/encrypt + # - Paste the output down here + auth_token: + secure: vMKQ5Ta9vIXQzhrmIDfD++7d6yyu6K/myOPs1uo/6LIMFyMoB75ogMrLtEUDuyUJ + description: '' + on: + # DONE Here you can pick which targets will generate binary releases + # In this example, there are some targets that are tested using the stable + # and nightly channels. This condition makes sure there is only one release + # for such targets and that's generated using the stable channel + RUST_VERSION: stable + appveyor_repo_tag: true + provider: GitHub + +cache: + - C:\Users\appveyor\.cargo\registry + - target + +branches: + only: + # Release tags + - /^v\d+\.\d+\.\d+.*$/ + - master + +notifications: + - provider: Email + on_build_success: false + +# Building is done in the test phase, so we disable Appveyor's build phase. +build: false diff --git a/ci/before_deploy.ps1 b/ci/before_deploy.ps1 new file mode 100644 index 0000000..0f1a7c6 --- /dev/null +++ b/ci/before_deploy.ps1 @@ -0,0 +1,23 @@ +# This script takes care of packaging the build artifacts that will go in the +# release zipfile + +$SRC_DIR = $PWD.Path +$STAGE = [System.Guid]::NewGuid().ToString() + +Set-Location $ENV:Temp +New-Item -Type Directory -Name $STAGE +Set-Location $STAGE + +$ZIP = "$SRC_DIR\$($Env:CRATE_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:TARGET).zip" + +# DONE Update this to package the right artifacts +Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\just.exe" '.\' + +7z a "$ZIP" * + +Push-AppveyorArtifact "$ZIP" + +Remove-Item *.* -Force +Set-Location .. +Remove-Item $STAGE +Set-Location $SRC_DIR diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh new file mode 100644 index 0000000..901e348 --- /dev/null +++ b/ci/before_deploy.sh @@ -0,0 +1,33 @@ +# This script takes care of building your crate and packaging it for release + +set -ex + +main() { + local src=$(pwd) \ + stage= + + case $TRAVIS_OS_NAME in + linux) + stage=$(mktemp -d) + ;; + osx) + stage=$(mktemp -d -t tmp) + ;; + esac + + test -f Cargo.lock || cargo generate-lockfile + + # DONE Update this to build the artifacts that matter to you + cross rustc --bin just --target $TARGET --release -- -C lto + + # DONE Update this to package the right artifacts + cp target/$TARGET/release/just $stage/ + + cd $stage + tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz * + cd $src + + rm -rf $stage +} + +main diff --git a/ci/install.sh b/ci/install.sh new file mode 100644 index 0000000..748ad9a --- /dev/null +++ b/ci/install.sh @@ -0,0 +1,27 @@ +set -ex + +main() { + local target= + if [ $TRAVIS_OS_NAME = linux ]; then + target=x86_64-unknown-linux-musl + sort=sort + else + target=x86_64-apple-darwin + sort=gsort # for `sort --sort-version`, from brew's coreutils. + fi + + # This fetches latest stable release + local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \ + | cut -d/ -f3 \ + | grep -E '^v[0.1.0-9.]+$' \ + | $sort --version-sort \ + | tail -n1) + curl -LSfs https://japaric.github.io/trust/install.sh | \ + sh -s -- \ + --force \ + --git japaric/cross \ + --tag $tag \ + --target $target +} + +main diff --git a/ci/script.sh b/ci/script.sh new file mode 100644 index 0000000..fabbb59 --- /dev/null +++ b/ci/script.sh @@ -0,0 +1,24 @@ +# This script takes care of testing your crate + +set -ex + +# DONE This is the "test phase", tweak it as you see fit +main() { + cross build --target $TARGET + cross build --target $TARGET --release + + if [ ! -z $DISABLE_TESTS ]; then + return + fi + + cross test --target $TARGET + cross test --target $TARGET --release + + cross run --target $TARGET + cross run --target $TARGET --release +} + +# we don't run the "test phase" when doing deploys +if [ -z $TRAVIS_TAG ]; then + main +fi diff --git a/src/integration.rs b/src/integration.rs index b6dfb6b..0130126 100644 --- a/src/integration.rs +++ b/src/integration.rs @@ -1,5 +1,6 @@ extern crate tempdir; extern crate brev; +extern crate walkdir; use ::prelude::*; use tempdir::TempDir; @@ -35,6 +36,8 @@ macro_rules! integration_test { } } +static mut X: bool = false; + fn integration_test( shell: &str, justfile: &str, @@ -49,8 +52,29 @@ fn integration_test( let mut path = tmp.path().to_path_buf(); path.push("justfile"); brev::dump(path, justfile); - let mut binary = env::current_dir().unwrap(); - binary.push("./target/debug/just"); + + let binary = super::test_utils::just_binary_path(); + + unsafe { + if !X { + println!("tmpdir: {:?}", tmp.path()); + println!("cwd: {:?}", env::current_dir().unwrap()); + println!("binary: {:?}", binary); + + 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()); + } + + X = true; + } + } let output = process::Command::new(&binary) .current_dir(tmp.path()) diff --git a/src/lib.rs b/src/lib.rs index 2b2acb0..f554b97 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,9 @@ extern crate edit_distance; extern crate libc; extern crate brev; +#[cfg(test)] +mod test_utils; + #[cfg(test)] mod unit; diff --git a/src/search.rs b/src/search.rs index 2263507..80339ba 100644 --- a/src/search.rs +++ b/src/search.rs @@ -1,12 +1,11 @@ -extern crate brev; - use ::prelude::*; use tempdir::TempDir; use std::{path, str}; +use super::brev; fn search_test>(path: P, args: &[&str]) { - let mut binary = env::current_dir().unwrap(); - binary.push("./target/debug/just"); + let binary = super::test_utils::just_binary_path(); + let output = process::Command::new(binary) .current_dir(path) .args(args) diff --git a/src/test_utils.rs b/src/test_utils.rs new file mode 100644 index 0000000..ffbd5d1 --- /dev/null +++ b/src/test_utils.rs @@ -0,0 +1,24 @@ +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"); + + if !binary.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; + } + } + + binary +}