chore: Remove expect-exit as a dependency and add bacon config

This commit is contained in:
Gerald Pinder 2024-10-11 16:32:16 -04:00
parent 3a4782408d
commit ceefc7175a
5 changed files with 472 additions and 349 deletions

701
Cargo.lock generated

File diff suppressed because it is too large Load diff

94
bacon.toml Normal file
View file

@ -0,0 +1,94 @@
# This is a configuration file for the bacon tool
#
# Bacon repository: https://github.com/Canop/bacon
# Complete help on configuration: https://dystroy.org/bacon/config/
# You can also check bacon's own bacon.toml file
# as an example: https://github.com/Canop/bacon/blob/main/bacon.toml
default_job = "clippy-all"
[jobs.check]
command = ["cargo", "check", "--color", "always"]
need_stdout = false
default_watch = false
watch = ["src", "process", "recipe", "template", "utils", "Cargo.toml", "build.rs"]
[jobs.check-all]
command = ["cargo", "check", "--all-features", "--color", "always"]
need_stdout = false
default_watch = false
watch = ["src", "process", "recipe", "template", "utils", "Cargo.toml", "build.rs"]
[jobs.clippy]
command = [
"cargo", "clippy",
"--color", "always",
]
need_stdout = false
default_watch = false
watch = ["src", "process", "recipe", "template", "utils", "Cargo.toml", "build.rs"]
[jobs.clippy-all]
command = [
"cargo", "clippy",
"--all-features",
"--color", "always",
]
need_stdout = false
default_watch = false
watch = ["src", "process", "recipe", "template", "utils", "Cargo.toml", "build.rs"]
[jobs.test]
command = [
"cargo", "test", "--color", "always", "--workspace",
"--", "--color", "always",
]
need_stdout = true
default_watch = false
watch = ["src", "process", "recipe", "template", "utils", "Cargo.toml", "build.rs", "test-files"]
[jobs.test-all]
command = [
"cargo", "test", "--all-features", "--color", "always", "--workspace",
"--", "--color", "always"
]
need_stdout = true
default_watch = false
watch = ["src", "process", "recipe", "template", "utils", "Cargo.toml", "build.rs", "test-files"]
[jobs.doc]
command = ["cargo", "doc", "--color", "always", "--no-deps"]
need_stdout = false
default_watch = false
watch = ["src", "process", "recipe", "template", "utils", "Cargo.toml", "build.rs"]
# If the doc compiles, then it opens in your browser and bacon switches
# to the previous job
[jobs.doc-open]
command = ["cargo", "doc", "--color", "always", "--no-deps", "--open"]
need_stdout = false
on_success = "back" # so that we don't open the browser at each change
[jobs.install]
command = ["cargo", "install", "--path", ".", "--debug", "--locked", "--color", "always"]
need_stdout = false
allow_warnings = true
default_watch = false
watch = ["src", "process", "recipe", "template", "utils", "Cargo.toml", "build.rs"]
[jobs.install-all]
command = ["cargo", "install", "--all-features", "--path", ".", "--debug", "--locked", "--color", "always"]
need_stdout = false
allow_warnings = true
default_watch = false
watch = ["src", "process", "recipe", "template", "utils", "Cargo.toml", "build.rs"]
# You may define here keybindings that would be specific to
# a project, for example a shortcut to launch a specific job.
# Shortcuts to internal functions (scrolling, toggling, etc.)
# should go in your personal global prefs.toml file instead.
[keybindings]
# alt-m = "job:my-job"
c = "job:clippy-all" # comment this to have 'c' run clippy on only the default target
i = "job:install-all"
t = "job:test-all"

View file

@ -23,19 +23,19 @@ clean:
# Install bluebuild using cargo with release optimization
install:
cargo install --path .
cargo install --path . --locked
# Install bluebuild with all features with release optimizations
install-all-features:
cargo install --all-features --path .
cargo install --all-features --path . --locked
# Install bluebuild using cargo with debug targets
install-debug:
cargo install --debug --path .
cargo install --debug --path . --locked
# Install bluebuild with all features and debug target
install-debug-all-features:
cargo install --debug --all-features --path .
cargo install --debug --all-features --path . --locked
# Run unit tests
test:
@ -59,11 +59,11 @@ watch:
# Install bluebuild whenever there is a change in the project files
watch-install:
cargo watch -c -x 'install --debug --path .'
cargo watch -c -x 'install --debug --locked --path .'
# Install bluebuild whenever there is a change in the project files
watch-install-all-features:
cargo watch -c -x 'install --debug --all-features --path .'
cargo watch -c -x 'install --debug --locked --all-features --path .'
# Run tests anytime a file is changed
watch-test:
@ -91,7 +91,7 @@ tools:
rustup toolchain install stable
rustup override set stable
rustup component add --toolchain stable rust-analyzer clippy rustfmt
cargo install cargo-watch cargo-expand
cargo install --locked cargo-watch cargo-expand bacon
# Run cargo release and push the tag separately
release *args:

View file

@ -13,7 +13,6 @@ path = "process.rs"
[dependencies]
anyhow = "1"
blue-build-utils = { version = "=0.8.20", path = "../utils" }
expect-exit = "0.5"
indicatif-log-bridge = "0.2"
lenient_semver = "0.4"
log4rs = { version = "1", features = ["background_rotation"] }

View file

@ -1,6 +1,7 @@
use std::{
fs,
path::PathBuf,
process::ExitCode,
sync::{atomic::AtomicBool, Arc, Mutex},
thread,
};
@ -91,10 +92,10 @@ where
let app = thread::spawn(app_exec);
if matches!(app.join(), Ok(())) {
expect_exit::exit_unwind(0);
exit_unwind(ExitCode::SUCCESS);
} else {
error!("App thread panic!");
expect_exit::exit_unwind(1);
exit_unwind(ExitCode::FAILURE);
}
});
@ -131,7 +132,7 @@ where
});
drop(cid_list);
expect_exit::exit_unwind(1);
exit_unwind(ExitCode::FAILURE);
}
SIGTSTP => {
if has_terminal {
@ -153,6 +154,10 @@ where
}
}
fn exit_unwind(code: ExitCode) {
std::panic::resume_unwind(Box::new(code));
}
fn send_signal_processes(sig: i32) {
let pid_list = PID_LIST.clone();
let pid_list = pid_list.lock().expect("Should lock mutex");