-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
proposal: testing: add TB.WriteFile(name string, data string) string #45562
Comments
The That argument doesn't apply here. There is nothing specific to the testing package about providing a function that writes a string to a file with a default mode. We could do that in the os package. |
This proposal has been added to the active column of the proposals project |
Based on the discussion above, this proposal seems like a likely decline. |
No change in consensus, so declined. |
While working on some CL on the tests I noted a common pattern: calling
os.WriteFile
to create a temporary file using a string as input.Here is the list, obtained using
grep -F "os.WriteFile(" **/*_test.go | grep -F '[]byte'
:The list is quite long. In contrast, while working on #45448 I noted that the new
T.Setenv
could be used only in few cases.There is an interesting fact in the list: the
perm
argument is not always 0644; the interesting cases are0
(in one cases it is for windows so it make senses) and0755
used on non executable files.Using the proposed
TB.WriteFile
should reduce a bit of noise in the tests.I'm not sure if
TB.WriteTempFile(name, data string) string
(where the returned value is the file name) is a better API (assuming that each call ofTB.WriteTempFile
reuses the same temporary directory).Thanks.
The text was updated successfully, but these errors were encountered: