Merge pull request #9697 from github/redsun82/swift-stop-stub-reverts

Swift: fix stub revert prevention
This commit is contained in:
Paolo Tranquilli
2022-06-24 09:32:29 +02:00
committed by GitHub
2 changed files with 3 additions and 3 deletions

View File

@@ -103,8 +103,8 @@ def _is_generated_stub(file, check_modification=False):
# no lines
return False
if check_modification:
# one line already read, if we can read 4 other we are past the normal stub generation
line_threshold = 4
# one line already read, if we can read 5 other we are past the normal stub generation
line_threshold = 5
if sum(1 for _ in zip(range(line_threshold), contents)) == line_threshold:
raise ModifiedStubMarkedAsGeneratedError(
f"{file.name} stub was modified but is still marked as generated")

View File

@@ -378,7 +378,7 @@ def test_non_empty_cleanup(opts, generate, renderer):
def test_modified_stub_still_generated(qlgen_opts, renderer):
stub = qlgen_opts.ql_stub_output / "A.qll"
write(stub, "// generated\n\n\n\nsomething\n")
write(stub, "// generated\nprivate import foo\n\nclass Bar extends BarBase {\n int x() { none() }\n}\n")
with pytest.raises(qlgen.ModifiedStubMarkedAsGeneratedError):
run_generation(qlgen.generate, qlgen_opts, renderer)