You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that adding new tests in cmd/compile/internal/gc/asm_test.go can be slightly annoying because all the test functions for a given architecture are dumped in the same file, so the function names need to be unique.
Most of the names go like f0, f1, ... f80. They are not informative and if you need, for example, to add a variant of test f17, you can:
call it f81 and put it after f17 (making the list unsorted);
call it f81 and put it at the end (now f17 and f81, which test the same thing, are far away);
add some suffix like f17_2 (names are already ugly, this will make it worse).
This is not a problem for architectures like 386, which has like 4 tests, but amd64 has ~100 tests and at least 70 of them are named f%d, which also makes pretty clear that function names are not being used to explain what the function is testing (it seems that people prefer to put a sentence in a comment above the test struct).
I propose switching to a name-placeholder $ in the test functions, like this:
and you can search for f1 in the test file, but it's not foul-proof because there are half a dozen of test functions called f1 in the file (one in the amd64 array, another in the arm array, etc...).
and the func_1 name is auto-generated, so it's not in the file. You can still search for the 9*n part, tough (we always print the func body); and this is only a problem when there's a test failure.
Sounds fine to me. Maybe make the name indicate location? A line number would be ideal, but maybe not feasible. An arch + index into the test array would be acceptable.
I found that adding new tests in
cmd/compile/internal/gc/asm_test.go
can be slightly annoying because all the test functions for a given architecture are dumped in the same file, so the function names need to be unique.Most of the names go like
f0, f1, ... f80
. They are not informative and if you need, for example, to add a variant of testf17
, you can:f81
and put it afterf17
(making the list unsorted);f81
and put it at the end (nowf17
andf81
, which test the same thing, are far away);f17_2
(names are already ugly, this will make it worse).This is not a problem for architectures like 386, which has like 4 tests, but amd64 has ~100 tests and at least 70 of them are named
f%d
, which also makes pretty clear that function names are not being used to explain what the function is testing (it seems that people prefer to put a sentence in a comment above the test struct).I propose switching to a name-placeholder
$
in the test functions, like this:and modify the function that dumps the tests on file to replace
$
withfunc_X
with X = 0, 1, 2 ...The only drawback is slightly worse failure messages. Right now they say:
and you can search for
f1
in the test file, but it's not foul-proof because there are half a dozen of test functions calledf1
in the file (one in the amd64 array, another in the arm array, etc...).After the change they would say:
and the
func_1
name is auto-generated, so it's not in the file. You can still search for the9*n
part, tough (we always print thefunc
body); and this is only a problem when there's a test failure.Opinions? @randall77 @josharian @TocarIP
The text was updated successfully, but these errors were encountered: