Skip to content

Commit

Permalink
Merge branch 'tomas/e2e-fix-cmd-assert' (#247)
Browse files Browse the repository at this point in the history
* tomas/e2e-fix-cmd-assert:
  changelog: add #247
  test/e2e: update assert_success/failure to first consume output
  • Loading branch information
tzemanovic committed Aug 1, 2022
2 parents 489caac + 110c501 commit 2f3b9e0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/testing/247-e2e-fix-cmd-assert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- E2E: Consume unread output before checking exit status.
([#247](https://github.com/anoma/namada/pull/247))
4 changes: 2 additions & 2 deletions tests/src/e2e/ledger_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,7 @@ fn test_genesis_validators() -> Result<()> {
let validator_0_alias = "validator-0";
let validator_1_alias = "validator-1";

let init_genesis_validator_0 = setup::run_cmd(
let mut init_genesis_validator_0 = setup::run_cmd(
Bin::Client,
[
"utils",
Expand Down Expand Up @@ -1602,7 +1602,7 @@ fn test_genesis_validators() -> Result<()> {
.remove(validator_0_alias)
.unwrap();

let init_genesis_validator_1 = setup::run_cmd(
let mut init_genesis_validator_1 = setup::run_cmd(
Bin::Client,
[
"utils",
Expand Down
10 changes: 8 additions & 2 deletions tests/src/e2e/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,14 +503,20 @@ impl AnomaCmd {
}

/// Assert that the process exited with success
pub fn assert_success(&self) {
pub fn assert_success(&mut self) {
// Make sure that there is no unread output first
let _ = self.exp_eof().unwrap();

let status = self.session.wait().unwrap();
assert_eq!(WaitStatus::Exited(self.session.pid(), 0), status);
}

/// Assert that the process exited with failure
#[allow(dead_code)]
pub fn assert_failure(&self) {
pub fn assert_failure(&mut self) {
// Make sure that there is no unread output first
let _ = self.exp_eof().unwrap();

let status = self.session.wait().unwrap();
assert_ne!(WaitStatus::Exited(self.session.pid(), 0), status);
}
Expand Down

0 comments on commit 2f3b9e0

Please sign in to comment.