mirror of
https://github.com/github/codeql.git
synced 2026-05-02 20:25:13 +02:00
Merge pull request #9697 from github/redsun82/swift-stop-stub-reverts
Swift: fix stub revert prevention
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user