Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

tests: add output when the test fails #1728

Merged
merged 1 commit into from Nov 11, 2015
Merged

Conversation

alban
Copy link
Member

@alban alban commented Nov 11, 2015

The previous error on #1696 was:

--- FAIL: TestAPIServiceGetInfo (0.10s)
    rkt_api_service_test.go:37: Running rkt install
    rkt_api_service_test.go:42: Running rkt api service
    rkt_tests.go:125: rkt didn't terminate correctly: exit status 2

This patch should add more output.

/cc @yifan-gu

@@ -111,11 +111,11 @@ func waitOrFail(t *testing.T, child *gexpect.ExpectSubprocess, shouldSucceed boo
err := child.Wait()
switch {
case !shouldSucceed && err == nil:
t.Fatalf("Expected test to fail but it didn't")
t.Fatalf("Expected test to fail but it didn't\nOutput:\n%s", child.Collect())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collect() returns a []byte so you need to wrap it with a string().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, %s will convert it automatically.

@iaguis
Copy link
Member

iaguis commented Nov 11, 2015

If we've already Collected (for example, with an expect*WithOutput, the output would be empty right?

I guess it's good for cases where we don't expect (?)

@alban
Copy link
Member Author

alban commented Nov 11, 2015

If we've already Collected (for example, with an expect*WithOutput, the output would be empty right?

expect*WithOutput only call Collect() in case of error, so the caller of expect*WithOutput should already print the output and exit in case of error.

@iaguis
Copy link
Member

iaguis commented Nov 11, 2015

Fair enough. LGTM.

alban added a commit that referenced this pull request Nov 11, 2015
tests: add output when the test fails
@alban alban merged commit a3f9e85 into rkt:master Nov 11, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants