diff --git a/.changelog/unreleased/testing/247-e2e-fix-cmd-assert.md b/.changelog/unreleased/testing/247-e2e-fix-cmd-assert.md new file mode 100644 index 0000000000..6696c5946a --- /dev/null +++ b/.changelog/unreleased/testing/247-e2e-fix-cmd-assert.md @@ -0,0 +1,2 @@ +- E2E: Consume unread output before checking exit status. + ([#247](https://github.com/anoma/namada/pull/247)) diff --git a/tests/src/e2e/ledger_tests.rs b/tests/src/e2e/ledger_tests.rs index f150e6eac0..a83d3f54ca 100644 --- a/tests/src/e2e/ledger_tests.rs +++ b/tests/src/e2e/ledger_tests.rs @@ -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", @@ -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", diff --git a/tests/src/e2e/setup.rs b/tests/src/e2e/setup.rs index 2b0aba0696..28f1cf1825 100644 --- a/tests/src/e2e/setup.rs +++ b/tests/src/e2e/setup.rs @@ -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); }