Skip to content

Commit

Permalink
test: Move artifacts out of target
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin Blackman committed Jan 1, 2024
1 parent e180db6 commit 2f2fd57
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/target
/.bin
/.tmp
.gha/
*.profraw
lcov.info
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,23 @@ release = '''set -e
'''

test-coverage = '''set -e
rm -rf .tmp
cargo build
cargo llvm-cov nextest --ignore-filename-regex='_test.rs'
'''
test-coverage-html = '''set -e
rm -rf .tmp
cargo build
cargo llvm-cov nextest --open --ignore-filename-regex='_test.rs'
'''
test-coverage-lcov = '''set -e
rm -rf .tmp
cargo build
rm -f lcov.info
cargo llvm-cov nextest --lcov --output-path lcov.info --ignore-filename-regex='_test.rs'
'''
test = '''set -e
rm -rf .tmp
cargo build
cargo nextest run
'''
Expand Down
16 changes: 8 additions & 8 deletions tests/binary_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ mod cargo_install {
default_features: None,
features: None,
},
"./target/debug".into(),
"./.tmp".into(),
);

assert!(res.is_ok());
Expand All @@ -65,7 +65,7 @@ mod cargo_install {
default_features: None,
features: None,
},
"./target/debug".into(),
"./.tmp".into(),
);

assert!(res.is_ok());
Expand All @@ -87,7 +87,7 @@ mod cargo_install {
default_features: None,
features: None,
},
"./target/debug".into(),
"./.tmp".into(),
);

assert!(res.is_ok());
Expand All @@ -109,7 +109,7 @@ mod cargo_install {
default_features: None,
features: None,
},
"./target/debug".into(),
"./.tmp".into(),
);

assert!(res.is_ok());
Expand All @@ -131,7 +131,7 @@ mod cargo_install {
default_features: None,
features: None,
},
"./target/debug".into(),
"./.tmp".into(),
);

assert!(res.is_ok());
Expand All @@ -153,7 +153,7 @@ mod cargo_install {
default_features: None,
features: None,
},
"./target/debug".into(),
"./.tmp".into(),
);

assert!(res.is_ok());
Expand All @@ -180,7 +180,7 @@ mod binstall {
default_features: None,
features: None,
},
"./target/debug".into(),
"./.tmp".into(),
);

assert!(res.is_ok());
Expand All @@ -202,7 +202,7 @@ mod binstall {
default_features: None,
features: None,
},
"./target/debug".into(),
"./.tmp".into(),
);

assert!(res.is_ok());
Expand Down
39 changes: 12 additions & 27 deletions tests/cli_integration_test.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
use cargo_run_bin::metadata;

fn get_bin() -> String {
return metadata::get_project_root()
.unwrap()
.join(env!("CARGO_BIN_EXE_cargo-bin").replace(".exe", ""))
.to_str()
.unwrap()
.to_string();
}

mod direct {
use assert_cmd::Command;

use super::get_bin;

#[test]
fn it_syncs_aliases_successfully() {
let mut cmd = Command::cargo_bin(get_bin()).unwrap();
let mut cmd = Command::cargo_bin("cargo-bin").unwrap();
let assert = cmd.arg("--sync-aliases").assert();

let res = assert.success();
Expand All @@ -28,7 +15,7 @@ mod direct {

#[test]
fn it_install_all_bins_successfully() {
let mut cmd = Command::cargo_bin(get_bin()).unwrap();
let mut cmd = Command::cargo_bin("cargo-bin").unwrap();
let assert = cmd.arg("--install").assert();

let res = assert.success();
Expand All @@ -40,7 +27,7 @@ mod direct {

#[test]
fn it_builds_all_bins_successfully() {
let mut cmd = Command::cargo_bin(get_bin()).unwrap();
let mut cmd = Command::cargo_bin("cargo-bin").unwrap();
let assert = cmd.arg("--build").assert();

let res = assert.success();
Expand All @@ -52,7 +39,7 @@ mod direct {

#[test]
fn it_runs_help_successfully() {
let mut cmd = Command::cargo_bin(get_bin()).unwrap();
let mut cmd = Command::cargo_bin("cargo-bin").unwrap();
let assert = cmd.arg("--help").assert();

let res = assert.success();
Expand All @@ -62,7 +49,7 @@ mod direct {

#[test]
fn it_runs_nextest_help_successfully() {
let mut cmd = Command::cargo_bin(get_bin()).unwrap();
let mut cmd = Command::cargo_bin("cargo-bin").unwrap();
let assert = cmd.arg("cargo-nextest").arg("--help").assert();

let res = assert.success();
Expand All @@ -72,7 +59,7 @@ mod direct {

#[test]
fn it_fails_when_binary_is_not_configured() {
let mut cmd = Command::cargo_bin(get_bin()).unwrap();
let mut cmd = Command::cargo_bin("cargo-bin").unwrap();
let assert = cmd.arg("not-real").assert();

let res = assert.failure();
Expand All @@ -86,11 +73,9 @@ mod direct {
mod bin_prefix {
use assert_cmd::Command;

use super::get_bin;

#[test]
fn it_syncs_aliases_successfully() {
let mut cmd = Command::cargo_bin(get_bin()).unwrap();
let mut cmd = Command::cargo_bin("cargo-bin").unwrap();
let assert = cmd.arg("bin").arg("--sync-aliases").assert();

let res = assert.success();
Expand All @@ -102,7 +87,7 @@ mod bin_prefix {

#[test]
fn it_install_all_bins_successfully() {
let mut cmd = Command::cargo_bin(get_bin()).unwrap();
let mut cmd = Command::cargo_bin("cargo-bin").unwrap();
let assert = cmd.arg("bin").arg("--install").assert();

let res = assert.success();
Expand All @@ -114,7 +99,7 @@ mod bin_prefix {

#[test]
fn it_builds_all_bins_successfully() {
let mut cmd = Command::cargo_bin(get_bin()).unwrap();
let mut cmd = Command::cargo_bin("cargo-bin").unwrap();
let assert = cmd.arg("bin").arg("--build").assert();

let res = assert.success();
Expand All @@ -126,7 +111,7 @@ mod bin_prefix {

#[test]
fn it_runs_nextest_help_successfully() {
let mut cmd = Command::cargo_bin(get_bin()).unwrap();
let mut cmd = Command::cargo_bin("cargo-bin").unwrap();
let assert = cmd.arg("bin").arg("cargo-nextest").arg("--help").assert();

let res = assert.success();
Expand All @@ -136,7 +121,7 @@ mod bin_prefix {

#[test]
fn it_runs_help_successfully() {
let mut cmd = Command::cargo_bin(get_bin()).unwrap();
let mut cmd = Command::cargo_bin("cargo-bin").unwrap();
let assert = cmd.arg("bin").arg("--help").assert();

let res = assert.success();
Expand All @@ -146,7 +131,7 @@ mod bin_prefix {

#[test]
fn it_fails_when_binary_is_not_configured() {
let mut cmd = Command::cargo_bin(get_bin()).unwrap();
let mut cmd = Command::cargo_bin("cargo-bin").unwrap();
let assert = cmd.arg("bin").arg("not-real").assert();

let res = assert.failure();
Expand Down

0 comments on commit 2f2fd57

Please sign in to comment.