Skip to content

Commit 0bbc676

Browse files
Do not allow update_file.py to be called on output.txt (#2847)
## Tests Manually: ``` ➜ cli git:(do-not-allow-output) ./acceptance/bin/update_file.py output.txt a b Traceback (most recent call last): File "/Users/shreyas.goenka/repos/cli/./acceptance/bin/update_file.py", line 21, in <module> assert filename != "output.txt" AssertionError ```
1 parent a2d6cbe commit 0bbc676

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

acceptance/bin/update_file.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010
import sys
1111

1212
filename, old, new = sys.argv[1:]
13+
14+
# Acceptance tests by default keep output.txt open to append output to.
15+
# Using update_file.py on output.txt can be flaky on windows, likely because
16+
# of some internal buffering with the file handle. Thus we do not allow updating
17+
# output.txt with this script.
18+
#
19+
# You are instead recommended to write the output to a different file and
20+
# call update_file.py on that file.
21+
assert filename != "output.txt"
22+
1323
data = open(filename).read()
1424
newdata = data.replace(old, new)
1525
if newdata == data:

0 commit comments

Comments
 (0)