Skip to content

Conversation

@debarshiray
Copy link
Member

Tests are a good way to specify the behaviour of a piece of code. These
two new tests for PathExists clarify that in the case of symbolic links,
it checks if the targets exist or not.

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
Tests are a good way to specify the behaviour of a piece of code.  These
two new tests for PathExists clarify that in the case of symbolic links,
it checks if the targets exist or not.

containers#1728
@debarshiray debarshiray force-pushed the wip/rishi/src-pkg-utils-test-PathExists-symlink branch from 1acf21f to bec3a8e Compare October 21, 2025 17:33
@softwarefactory-project-zuul
Copy link

@softwarefactory-project-zuul
Copy link

@debarshiray debarshiray merged commit e9ec7f1 into containers:main Oct 23, 2025
3 checks passed
@debarshiray debarshiray deleted the wip/rishi/src-pkg-utils-test-PathExists-symlink branch October 23, 2025 08:45
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