Skip to content
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

Fix lines starting with ? being incorrectly interpreted #61

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adombeck
Copy link

Please describe the change you are making

Lines starting with ? are interpreted as a package being skipped:

{
regexp.MustCompile(`^\?\s+(?P<Package>[^\s]+)\s+\[(?P<Output>.*)]$`),
stateBetweenTests,
ActionSkip,
stateBetweenTests,
},

If a test prints a line that matches this pattern, then that output is incorrectly interpreted as a test being skipped and is therefore printed like this instead of hiding it (yes, the test does actually print a lot of question marks):

image

Looking at the JSON output produced by go test for packages being skipped:

{
  "Time": "2024-11-27T15:44:59.055963303+01:00",
  "Action": "output",
  "Package": "github.com/ubuntu/authd/.scratch/reproduce-gotestfmt-bug/bar",
  "Output": "?   \tgithub.com/ubuntu/authd/.scratch/reproduce-gotestfmt-bug/bar\t[no test files]\n"
}

and the JSON output of a test that prints a line starting with ?:

{
  "Time": "2024-11-27T15:44:59.137559943+01:00",
  "Action": "output",
  "Package": "github.com/ubuntu/authd/.scratch/reproduce-gotestfmt-bug/foo",
  "Test": "TestFoo",
  "Output": "?  foo bar\n"
}

we see that we can distinguish between these two cases on the basis of the Test field.

So this PR only interprets lines starting with ? as a package being skipped when it's not output from a test, i.e. its JSON line doesn't have a Test field. There was no functionality yet to encode such a condition, so this PR adds a precondition function to the stateChange struct.

Your code will be released under the Unlicense into the public domain for everyone to use for any purpose. Are you in the position, and are you willing to release your code under this license?

yes

These lines should only be interpreted as a package being skipped when
it's not output from a test. There was no functionality yet to encode
such a condition, so this commit adds a `precondition` function to the
stateChange struct.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant