Hi,
To my knowledge, in the future Go modules macros (which will hopefully
be available at some point in the future), we won't be able to pass -d
or -t to %gocheck to disable some test directory. In order to tackle the
problem of failing tests, I devised an alternative method to disable
failing tests with awk:
for test in "TestRestart" \
"TestStop" \
"TestActive" \
; do
awk -i inplace '/^func.*'"$test"'/ { print; print "\treturn"; next}1'
$(grep -rl $test)
done
You can see that it adds a return directly after the test function
definition to bypass the test. Instead of return, we could also use:
t.Skip("disabled failing test")
for test in "TestRestart" \
"TestStop" \
"TestActive" \
; do
awk -i inplace '/^func.*'"$test"'/ { print; print "\tt.Skip(\"disabled
failing test\")"; next}1' $(grep -rl $test)
done
Why I prefer this method:
- we don't have to manually create a patch for each test we want to
disable, so this is faster and easier.
- we don't have to port each patch if there was an update in the test
file.
- it offers more granularity compared to disabling an entire subdirectory.
Eventual problems:
- This only works if the format of the test is starting with ^func.*
$test and use (t *testing.T) as a parameter (for the second method). I
haven't tested this on a sufficient number of package to determine if
this is always the case.
- It needs awk in the buildroot, it is available by default but let's
hope it is not removed in the future.
Let me know what you think,
Best regards,
Robert-André