Skip to content

Commit

Permalink
fix(cucumber): update and exit process on ctrl+c (#1026)
Browse files Browse the repository at this point in the history
Description
---
fix(cucumber): update and exit process on ctrl+c

Motivation and Context
---
Cucumbers would continue running after ctrl+c is pressed, requiring the
user to find the PID and manually kill the process. This PR explicitly
handles ctrl+c and ends the process.

Cucumber updated to 0.21. No code changes needed for the update.

How Has This Been Tested?
---
Ctrl+c while cucumbers are running

What process can a PR reviewer use to test or verify this change?
---
As above

Breaking Changes
---

- [x] None
- [ ] Requires data directory to be deleted
- [ ] Other - Please specify
  • Loading branch information
sdbondi authored May 2, 2024
1 parent 9474a26 commit 4ae0774
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 80 deletions.
140 changes: 83 additions & 57 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ chacha20poly1305 = "0.10.1"
chrono = "0.4.24"
config = "0.14.0"
convert_case = "0.6.0"
cucumber = "0.18.0"
cucumber = "0.21.0"
d3ne = { git = "https://github.com/stringhandler/d3ne-rs.git", tag = "v0.8.0-pre.3" }
dashmap = "5.5.0"
diesel = { version = "2", default-features = false }
Expand Down
21 changes: 3 additions & 18 deletions integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,18 @@ anyhow = { workspace = true }
# if we set this version in the workspace it would break other crates
base64 = "0.21.0"
config = { workspace = true }
cucumber = { workspace = true, features = [
"default",
"libtest",
"output-junit",
] }
cucumber = { workspace = true, features = ["default", "libtest", "output-junit"] }
httpmock = { workspace = true }
indexmap = { workspace = true }
libp2p = { workspace = true }
log = { workspace = true, features = ["std"] }
log4rs = { workspace = true, features = [
"rolling_file_appender",
"compound_policy",
"size_trigger",
"fixed_window_roller",
] }
log4rs = { workspace = true, features = ["rolling_file_appender", "compound_policy", "size_trigger", "fixed_window_roller"] }
rand = { workspace = true }
reqwest = { workspace = true }
serde = { workspace = true, features = ["default", "derive"] }
serde_json = { workspace = true }
time = { workspace = true }
tokio = { workspace = true, features = [
"default",
"macros",
"time",
"sync",
"rt-multi-thread",
] }
tokio = { workspace = true, features = ["default", "macros", "time", "sync", "rt-multi-thread", "signal"] }
tonic = { workspace = true }

[[test]]
Expand Down
21 changes: 17 additions & 4 deletions integration_tests/tests/cucumber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ use integration_tests::{
wallet_daemon_cli,
TariWorld,
};
use libp2p::Multiaddr;
use libp2p::{
futures::{
future::{select, Either},
pin_mut,
},
Multiaddr,
};
use tari_common::initialize_logging;
use tari_dan_engine::abi::Type;
use tari_dan_storage::consensus_models::QuorumDecision;
Expand All @@ -54,7 +60,7 @@ async fn main() {
let mock_port = spawn_template_http_server(shutdown.to_signal()).await;

let file = fs::File::create("cucumber-output-junit.xml").unwrap();
TariWorld::cucumber()
let cucumber_fut = TariWorld::cucumber()
.max_concurrent_scenarios(1)
.with_writer(writer::Tee::new(
writer::JUnit::new(file, Verbosity::ShowWorldAndDocString).normalized(),
Expand Down Expand Up @@ -84,8 +90,15 @@ async fn main() {
Box::pin(future::ready(()))
})
.fail_on_skipped()
.filter_run("tests/features/", |_, _, sc| !sc.tags.iter().any(|t| t == "ignore"))
.await;
.filter_run("tests/features/", |_, _, sc| !sc.tags.iter().any(|t| t == "ignore"));

let ctrl_c = tokio::signal::ctrl_c();
pin_mut!(ctrl_c);
pin_mut!(cucumber_fut);
match select(cucumber_fut, ctrl_c).await {
Either::Left(_) => {},
Either::Right((ctrl_c, _)) => ctrl_c.unwrap(),
}

shutdown.trigger();
}
Expand Down

0 comments on commit 4ae0774

Please sign in to comment.