containers / toolbox

Tool for interactive command line environments on Linux
https://containertoolbx.org/
Apache License 2.0
2.51k stars 214 forks source link

test/system: Simplify checking if the container started or not #1367

Closed debarshiray closed 1 year ago

debarshiray commented 1 year ago

Bats' run helper is not necessary to merely check if a command succeeded or not [1]. In this case, it's idiomatic to pipe the output directly to grep(1) and use it as the condition for an if branch.

[1] https://bats-core.readthedocs.io/en/stable/writing-tests.html

softwarefactory-project-zuul[bot] commented 1 year ago

Build failed. https://softwarefactory-project.io/zuul/t/local/buildset/9327b6f5fd3949c892ff29cab2cd51f0

:heavy_check_mark: unit-test SUCCESS in 8m 31s :heavy_check_mark: unit-test-migration-path-for-coreos-toolbox SUCCESS in 3m 27s :heavy_check_mark: unit-test-restricted SUCCESS in 7m 31s :x: system-test-fedora-rawhide FAILURE in 33m 46s :heavy_check_mark: system-test-fedora-38 SUCCESS in 26m 31s :heavy_check_mark: system-test-fedora-37 SUCCESS in 26m 02s

softwarefactory-project-zuul[bot] commented 1 year ago

Build failed. https://softwarefactory-project.io/zuul/t/local/buildset/5441261ee8c643f1a6a20afc75aa24a0

:heavy_check_mark: unit-test SUCCESS in 9m 54s :heavy_check_mark: unit-test-migration-path-for-coreos-toolbox SUCCESS in 3m 14s :heavy_check_mark: unit-test-restricted SUCCESS in 7m 19s :x: system-test-fedora-rawhide FAILURE in 33m 48s :heavy_check_mark: system-test-fedora-38 SUCCESS in 26m 37s :heavy_check_mark: system-test-fedora-37 SUCCESS in 26m 34s

softwarefactory-project-zuul[bot] commented 1 year ago

Build failed. https://softwarefactory-project.io/zuul/t/local/buildset/c421793ed2934654a61ac405237bf4b2

:heavy_check_mark: unit-test SUCCESS in 14m 37s :heavy_check_mark: unit-test-migration-path-for-coreos-toolbox SUCCESS in 3m 23s :heavy_check_mark: unit-test-restricted SUCCESS in 7m 36s :x: system-test-fedora-rawhide FAILURE in 57m 00s :x: system-test-fedora-38 TIMED_OUT in 40m 35s :x: system-test-fedora-37 TIMED_OUT in 40m 35s

softwarefactory-project-zuul[bot] commented 1 year ago

Build failed. https://softwarefactory-project.io/zuul/t/local/buildset/76b4fc712e9d4e25a764e7581f6fa93f

:heavy_check_mark: unit-test SUCCESS in 7m 58s :heavy_check_mark: unit-test-migration-path-for-coreos-toolbox SUCCESS in 3m 10s :heavy_check_mark: unit-test-restricted SUCCESS in 6m 59s :x: system-test-fedora-rawhide FAILURE in 31m 49s :heavy_check_mark: system-test-fedora-38 SUCCESS in 23m 12s :heavy_check_mark: system-test-fedora-37 SUCCESS in 23m 30s

debarshiray commented 1 year ago

Straightforward and nicer to read 👍. But makes me wonder whether this function should be merged with start_container() as it does the same with the difference of also ensuring the container did, in fact, start.

Thanks for the review, @HarryMichal ! I have wondered that too. I didn't want to change too many things here, because my main objective here is to be able to enforce shellcheck(1) on all the Bats tests.

debarshiray commented 1 year ago

There are still some test failures on Fedora Rawhide. For example:

fedora-rawhide | not ok 3 help: Run command 'help' in 145ms
fedora-rawhide | # (from function `assert_line' in file test/system/libs/bats-assert/src/assert.bash, line 479,
fedora-rawhide | #  in test file test/system/002-help.bats, line 45)
fedora-rawhide | #   `assert_line --index 0 --partial "toolbox(1)"' failed
fedora-rawhide | # /usr/bin/man
fedora-rawhide | #
fedora-rawhide | # -- line does not contain substring --
fedora-rawhide | # index     : 0
fedora-rawhide | # substring : toolbox(1)
fedora-rawhide | # line      : troff:<standard input>:33: warning: cannot select font 'C'
fedora-rawhide | # --

I believe these are because of changes in various other components in Fedora 39, which we need to track down one by one and work out a fix.

In the mean time, I am going to temporarily override these failures.