New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add output when the test fails #1728

Merged
merged 1 commit into from Nov 11, 2015

Conversation

Projects
None yet
2 participants
@alban
Member

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())

This comment has been minimized.

@iaguis

iaguis Nov 11, 2015

Member

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

@iaguis

iaguis Nov 11, 2015

Member

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

This comment has been minimized.

@iaguis

iaguis Nov 11, 2015

Member

Nevermind, %s will convert it automatically.

@iaguis

iaguis Nov 11, 2015

Member

Nevermind, %s will convert it automatically.

@iaguis

This comment has been minimized.

Show comment
Hide comment
@iaguis

iaguis Nov 11, 2015

Member

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 (?)

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

This comment has been minimized.

Show comment
Hide comment
@alban

alban Nov 11, 2015

Member

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.

Member

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

This comment has been minimized.

Show comment
Hide comment
@iaguis

iaguis Nov 11, 2015

Member

Fair enough. LGTM.

Member

iaguis commented Nov 11, 2015

Fair enough. LGTM.

alban added a commit that referenced this pull request Nov 11, 2015

Merge pull request #1728 from alban/alban/test-output
tests: add output when the test fails

@alban alban merged commit a3f9e85 into rkt:master Nov 11, 2015

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
semaphoreci The build passed on Semaphore.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment