Skip to content

Commit

Permalink
chore: Drop owo
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinblackman committed Jul 5, 2024
1 parent 33a2c0f commit 1dd54c4
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 47 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ watch = ["bin", "cargo-watch"]

[env]
BINSTALL_STRATEGIES = "crate-meta-data,compile"

[net]
git-fetch-with-cli = true
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ required-features = ["cli"]

[features]
default = ["cli"]
cli = ["dep:clap", "dep:owo-colors"]
cli = ["dep:clap"]

[dependencies]
anyhow = "1.0.40"
cfg-if = "1.0.0"
clap = { version = "4.3.19", optional = true }
owo-colors = { version = "3.5.0", optional = true }
rustversion = "1.0.14"
serde = { version = "1.0.149", features = ["derive"] }
toml = "0.5.9"
Expand Down Expand Up @@ -120,23 +119,23 @@ release = '''set -e
test-coverage = '''set -e
rm -rf .tmp
cargo build
cargo llvm-cov nextest --ignore-filename-regex='_test.rs'
cargo llvm-cov nextest -j 1 --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'
cargo llvm-cov nextest -j 1 --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'
cargo llvm-cov nextest -j 1 --lcov --output-path lcov.info --ignore-filename-regex='_test.rs'
'''
test = '''set -e
rm -rf .tmp
cargo build
cargo nextest run
cargo nextest run -j 1
'''
test-watch = '''set -e
cargo watch -i .cargo -x 'cmd test'
Expand Down
5 changes: 2 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use anyhow::Result;
use clap::Arg;
use clap::ArgMatches;
use clap::Command;
use owo_colors::OwoColorize;

use crate::binary;
use crate::cargo_config;
Expand All @@ -18,13 +17,13 @@ fn install_all_binaries() -> Result<()> {
binary::install(binary_package)?;
}

println!("{}", "Done!".green());
println!("\x1b[32m{}\x1b[0m", "Done!");
return Ok(());
}

fn sync_aliases() -> Result<()> {
cargo_config::sync_aliases()?;
println!("{}", "Done!".green());
println!("\x1b[32m{}\x1b[0m", "Done!");
return Ok(());
}

Expand Down
4 changes: 1 addition & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use std::process;

use owo_colors::OwoColorize;

fn main() {
let res = cargo_run_bin::cli::run();

// Only reached if run-bin code fails, otherwise process exits early from within
// binary::run.
if let Err(res) = res {
eprintln!("{}", format!("run-bin failed: {res}").red());
eprintln!("\x1b[31m{}\x1b[0m", format!("run-bin failed: {res}"));
process::exit(1);
}
}
13 changes: 1 addition & 12 deletions tests/cargo_config_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,4 @@ mod sync_aliases {
assert!(res.is_ok());
assert!(toml_str.contains("nextest = [\"bin\", \"cargo-nextest\"]"));
}
}

mod binstall_alias_exists {
use cargo_run_bin::cargo_config::binstall_alias_exists;

// Lazy happy path test.
#[test]
fn it_should_return_true() {
let res = binstall_alias_exists().unwrap();
assert!(res);
}
}
}
32 changes: 16 additions & 16 deletions tests/cli_integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ mod direct {
let res = assert.success();
let stdout = String::from_utf8(res.get_output().stdout.clone()).unwrap();
insta::assert_snapshot!(stdout, @r###"
[32mDone![39m
"###);
[32mDone![0m
"###);
}

#[test]
Expand All @@ -21,8 +21,8 @@ mod direct {
let res = assert.success();
let stdout = String::from_utf8(res.get_output().stdout.clone()).unwrap();
insta::assert_snapshot!(stdout, @r###"
[32mDone![39m
"###);
[32mDone![0m
"###);
}

#[test]
Expand All @@ -33,8 +33,8 @@ mod direct {
let res = assert.success();
let stdout = String::from_utf8(res.get_output().stdout.clone()).unwrap();
insta::assert_snapshot!(stdout, @r###"
[32mDone![39m
"###);
[32mDone![0m
"###);
}

#[test]
Expand Down Expand Up @@ -65,8 +65,8 @@ mod direct {
let res = assert.failure();
let stderr = String::from_utf8(res.get_output().stderr.clone()).unwrap();
insta::assert_snapshot!(stderr, @r###"
[31mrun-bin failed: No package found for binary not-real[39m
"###);
[31mrun-bin failed: No package found for binary not-real[0m
"###);
}
}

Expand All @@ -81,8 +81,8 @@ mod bin_prefix {
let res = assert.success();
let stdout = String::from_utf8(res.get_output().stdout.clone()).unwrap();
insta::assert_snapshot!(stdout, @r###"
[32mDone![39m
"###);
[32mDone![0m
"###);
}

#[test]
Expand All @@ -93,8 +93,8 @@ mod bin_prefix {
let res = assert.success();
let stdout = String::from_utf8(res.get_output().stdout.clone()).unwrap();
insta::assert_snapshot!(stdout, @r###"
[32mDone![39m
"###);
[32mDone![0m
"###);
}

#[test]
Expand All @@ -105,8 +105,8 @@ mod bin_prefix {
let res = assert.success();
let stdout = String::from_utf8(res.get_output().stdout.clone()).unwrap();
insta::assert_snapshot!(stdout, @r###"
[32mDone![39m
"###);
[32mDone![0m
"###);
}

#[test]
Expand Down Expand Up @@ -137,7 +137,7 @@ mod bin_prefix {
let res = assert.failure();
let stderr = String::from_utf8(res.get_output().stderr.clone()).unwrap();
insta::assert_snapshot!(stderr, @r###"
[31mrun-bin failed: No package found for binary not-real[39m
"###);
[31mrun-bin failed: No package found for binary not-real[0m
"###);
}
}

0 comments on commit 1dd54c4

Please sign in to comment.