mvdan / sh

A shell parser, formatter, and interpreter with bash support; includes shfmt
https://pkg.go.dev/mvdan.cc/sh/v3
BSD 3-Clause "New" or "Revised" License
7.15k stars 338 forks source link

interp: touch timestamp test is flaky #784

Closed mvdan closed 2 years ago

mvdan commented 2 years ago

https://github.com/mvdan/sh/runs/4669017549?check_suite_focus=true

    --- FAIL: TestRunnerRun/#435 (0.01s)
        interp_test.go:3233: wrong output in "touch -t 202111050000 a; touch -t 202111060000 b; [[ a -ot b ]]":
            want: ""
            got:  "exit status 1"
FAIL

I believe @riacataquian also ran into this failure, also on Windows.

The tests use touch -t instead of touch -d since d36d14903235de79f41ca3bea388f83ce33ad174, but the test builtin only implements -d. So we are effectively having test -t 123 foo create three files -t, 123, and foo - without a custom timestamp :see_no_evil:

The fix is: 1) fix up the touch implementation in interp_test.go to support the -t flag, and 2) add some sanity check that none of the interp_test.go builtins are misusing flags as arguments. For instance, by failing if any argument begins with a dash.

This is not a bug in the interpreter, but still a bug - in the test code.

riacataquian commented 2 years ago

oopsy! you are right, will be sending a fix for this.