Skip to content

Conversation

@debarshiray
Copy link
Member

@debarshiray debarshiray commented Oct 21, 2025

Currently, if for some reason the set-up steps of a test function fails,
like opening /dev/ptmx, it continues to run and encounters subsequent
failures:

  --- FAIL: TestIsTerminalTerminal (0.00s)
      term_test.go:41:
                  Error Trace: toolbox/src/pkg/term/term_test.go:41
                  Error:       Received unexpected error:
                               open /dev/ptmx: not a directory
                  Test:        TestIsTerminalTerminal
      term_test.go:45:
                  Error Trace: toolbox/src/pkg/term/term_test.go:45
                  Error:       Should be true
                  Test:	       TestIsTerminalTerminal
  FAIL
  FAIL  github.com/containers/toolbox/pkg/term  0.004s

The test functions are only meaningful if the set-up succeeds, and
continuing in the case of a failure only leads to noise. Therefore,
stop executing them if they fail their set-up.

This changes the previous failure to:

  --- FAIL: TestIsTerminalTerminal (0.00s)
      term_test.go:42:
                  Error Trace: toolbox/src/pkg/term/term_test.go:42
                  Error:       Received unexpected error:
                               open /dev/ptmx: not a directory
                  Test:        TestIsTerminalTerminal
  FAIL
  FAIL  github.com/containers/toolbox/pkg/term  0.003s

Fallout from the following:

debarshiray added a commit to debarshiray/toolbox that referenced this pull request Oct 21, 2025
Currently, if for some reason the set-up steps of a test fails, like
opening /dev/ptmx, the test continues to run and encounters subsequent
failures:
  --- FAIL: TestIsTerminalTerminal (0.00s)
      term_test.go:41:
                  Error Trace: toolbox/src/pkg/term/term_test.go:41
                  Error:       Received unexpected error:
                               open /dev/ptmx: not a directory
                  Test:        TestIsTerminalTerminal
      term_test.go:45:
                  Error Trace: toolbox/src/pkg/term/term_test.go:45
                  Error:       Should be true
                  Test:	       TestIsTerminalTerminal
  FAIL
  FAIL  github.com/containers/toolbox/pkg/term  0.004s

The tests are only meaningful if the set-up succeeds, and continuing in
the case of a failure only leads to noise.  Therefore, stop executing
the tests if they fail their set-up.

This changes the previous failure to:
  --- FAIL: TestIsTerminalTerminal (0.00s)
      term_test.go:42:
                  Error Trace: toolbox/src/pkg/term/term_test.go:42
                  Error:       Received unexpected error:
                               open /dev/ptmx: not a directory
                  Test:        TestIsTerminalTerminal
  FAIL
  FAIL  github.com/containers/toolbox/pkg/term  0.003s

Fallout from 3d54993 and
aca4e9d

containers#1727
@debarshiray debarshiray force-pushed the wip/rishi/src-tests-stop-if-they-fail-their-setup branch from b71accf to d1c8762 Compare October 21, 2025 13:55
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Oct 21, 2025
A subsequent commit will ensure that the test functions are stopped if
they fail their set-up.  This means that tests that don't share the same
set-up shouldn't be in the same test function.  Otherwise, a failure in
one test's set-up will prevent the remaining tests that don't need the
failed set-up from running.

containers#1727
@debarshiray debarshiray force-pushed the wip/rishi/src-tests-stop-if-they-fail-their-setup branch from d1c8762 to 39673da Compare October 21, 2025 14:42
@debarshiray debarshiray changed the title pkg/term: Stop the tests if they fail their set-up pkg/term, pkg/utils: Stop the test functions if they fail their set-up Oct 21, 2025
@softwarefactory-project-zuul
Copy link

A subsequent commit will ensure that the test functions are stopped if
they fail their set-up.  This means that tests that don't share the same
set-up shouldn't be in the same test function.  Otherwise, a failure in
one test's set-up will prevent the remaining tests that don't need the
failed set-up from running.

containers#1727
Currently, if for some reason the set-up steps of a test function fails,
like opening /dev/ptmx, it continues to run and encounters subsequent
failures:
  --- FAIL: TestIsTerminalTerminal (0.00s)
      term_test.go:41:
                  Error Trace: toolbox/src/pkg/term/term_test.go:41
                  Error:       Received unexpected error:
                               open /dev/ptmx: not a directory
                  Test:        TestIsTerminalTerminal
      term_test.go:45:
                  Error Trace: toolbox/src/pkg/term/term_test.go:45
                  Error:       Should be true
                  Test:	       TestIsTerminalTerminal
  FAIL
  FAIL  github.com/containers/toolbox/pkg/term  0.004s

The test functions are only meaningful if the set-up succeeds, and
continuing in the case of a failure only leads to noise.  Therefore,
stop executing them if they fail their set-up.

This changes the previous failure to:
  --- FAIL: TestIsTerminalTerminal (0.00s)
      term_test.go:42:
                  Error Trace: toolbox/src/pkg/term/term_test.go:42
                  Error:       Received unexpected error:
                               open /dev/ptmx: not a directory
                  Test:        TestIsTerminalTerminal
  FAIL
  FAIL  github.com/containers/toolbox/pkg/term  0.003s

Fallout from the following:
  * 3d54993
  * aca4e9d
  * e9e77fb

containers#1727
@debarshiray debarshiray force-pushed the wip/rishi/src-tests-stop-if-they-fail-their-setup branch from 39673da to 59c96c3 Compare October 21, 2025 16:52
@softwarefactory-project-zuul
Copy link

@softwarefactory-project-zuul
Copy link

@debarshiray debarshiray merged commit 4ac94aa into containers:main Oct 23, 2025
3 checks passed
@debarshiray debarshiray deleted the wip/rishi/src-tests-stop-if-they-fail-their-setup branch October 23, 2025 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant