-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17178 from github/criemen/pytest-swift
Port Swift integration tests to pytest.
- Loading branch information
Showing
28 changed files
with
141 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
swift/ql/integration-tests/autobuilder/unsupported-os/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import runs_on | ||
|
||
|
||
@(runs_on.linux or runs_on.windows) | ||
def test(codeql, swift): | ||
codeql.database.create(_assert_failure=True) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
9 changes: 5 additions & 4 deletions
9
swift/ql/integration-tests/linux-only/RegexLiteralExpr/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from create_database_utils import * | ||
import runs_on | ||
|
||
run_codeql_database_create([ | ||
"swiftc -enable-bare-slash-regex regex.swift -o /dev/null", | ||
], lang="swift") | ||
|
||
@runs_on.linux | ||
def test(codeql, swift): | ||
codeql.database.create(command="swiftc -enable-bare-slash-regex regex.swift -o /dev/null") |
5 changes: 0 additions & 5 deletions
5
swift/ql/integration-tests/linux-only/autobuilder/unsupported-os/test.py
This file was deleted.
Oops, something went wrong.
9 changes: 5 additions & 4 deletions
9
swift/ql/integration-tests/osx-only/autobuilder/failure/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from create_database_utils import * | ||
from diagnostics_test_utils import * | ||
import runs_on | ||
|
||
run_codeql_database_create([], lang='swift', keep_trap=True, db=None, runFunction=runUnsuccessfully) | ||
check_diagnostics() | ||
|
||
@runs_on.macos | ||
def test(codeql, swift): | ||
codeql.database.create(_assert_failure=True) |
9 changes: 5 additions & 4 deletions
9
swift/ql/integration-tests/osx-only/autobuilder/no-build-system/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from create_database_utils import * | ||
from diagnostics_test_utils import * | ||
import runs_on | ||
|
||
run_codeql_database_create([], lang='swift', keep_trap=True, db=None, runFunction=runUnsuccessfully) | ||
check_diagnostics() | ||
|
||
@runs_on.macos | ||
def test(codeql, swift): | ||
codeql.database.create(_assert_failure=True) |
9 changes: 5 additions & 4 deletions
9
swift/ql/integration-tests/osx-only/autobuilder/no-swift-with-spm/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from create_database_utils import * | ||
from diagnostics_test_utils import * | ||
import runs_on | ||
|
||
run_codeql_database_create([], lang='swift', keep_trap=True, db=None, runFunction=runUnsuccessfully) | ||
check_diagnostics() | ||
|
||
@runs_on.macos | ||
def test(codeql, swift): | ||
codeql.database.create(_assert_failure=True) |
9 changes: 5 additions & 4 deletions
9
swift/ql/integration-tests/osx-only/autobuilder/no-swift/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from create_database_utils import * | ||
from diagnostics_test_utils import * | ||
import runs_on | ||
|
||
run_codeql_database_create([], lang='swift', keep_trap=True, db=None, runFunction=runUnsuccessfully) | ||
check_diagnostics() | ||
|
||
@runs_on.macos | ||
def test(codeql, swift): | ||
codeql.database.create(_assert_failure=True) |
9 changes: 5 additions & 4 deletions
9
swift/ql/integration-tests/osx-only/autobuilder/no-xcode-with-spm/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from create_database_utils import * | ||
from diagnostics_test_utils import * | ||
import runs_on | ||
|
||
run_codeql_database_create([], lang='swift', keep_trap=True, db=None, runFunction=runUnsuccessfully) | ||
check_diagnostics() | ||
|
||
@runs_on.macos | ||
def test(codeql, swift): | ||
codeql.database.create(_assert_failure=True) |
9 changes: 5 additions & 4 deletions
9
swift/ql/integration-tests/osx-only/autobuilder/only-tests-with-spm/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from create_database_utils import * | ||
from diagnostics_test_utils import * | ||
import runs_on | ||
|
||
run_codeql_database_create([], lang='swift', keep_trap=True, db=None, runFunction=runUnsuccessfully) | ||
check_diagnostics() | ||
|
||
@runs_on.macos | ||
def test(codeql, swift): | ||
codeql.database.create(_assert_failure=True) |
9 changes: 5 additions & 4 deletions
9
swift/ql/integration-tests/osx-only/autobuilder/only-tests/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from create_database_utils import * | ||
from diagnostics_test_utils import * | ||
import runs_on | ||
|
||
run_codeql_database_create([], lang='swift', keep_trap=True, db=None, runFunction=runUnsuccessfully) | ||
check_diagnostics() | ||
|
||
@runs_on.macos | ||
def test(codeql, swift): | ||
codeql.database.create(_assert_failure=True) |
11 changes: 7 additions & 4 deletions
11
swift/ql/integration-tests/osx-only/autobuilder/xcode-fails-spm-works/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
from create_database_utils import * | ||
import runs_on | ||
import pytest | ||
|
||
runSuccessfully(['xcodebuild', 'clean']) | ||
runSuccessfully(['swift', 'package', 'clean']) | ||
run_codeql_database_create([], lang='swift', keep_trap=True) | ||
|
||
@runs_on.macos | ||
@pytest.mark.ql_test("DB-CHECK", xfail=True) | ||
def test(codeql, swift): | ||
codeql.database.create() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from create_database_utils import * | ||
import runs_on | ||
|
||
run_codeql_database_create([ | ||
'./build.sh', | ||
], lang='swift') | ||
|
||
@runs_on.macos | ||
def test(codeql, swift): | ||
codeql.database.create(command="./build.sh") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
from create_database_utils import * | ||
import runs_on | ||
import pytest | ||
|
||
run_codeql_database_create([ | ||
'xcodebuild clean', | ||
'xcodebuild build ' | ||
'-project codeql-swift-autobuild-test.xcodeproj ' | ||
'-target codeql-swift-autobuild-test ' | ||
'CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO', | ||
], lang='swift', keep_trap=True) | ||
|
||
@runs_on.macos | ||
@pytest.mark.ql_test("DB-CHECK", xfail=True) | ||
def test(codeql, swift): | ||
codeql.database.create( | ||
command="xcodebuild build " | ||
"-project codeql-swift-autobuild-test.xcodeproj " | ||
"-target codeql-swift-autobuild-test " | ||
"CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO", | ||
) |
12 changes: 7 additions & 5 deletions
12
swift/ql/integration-tests/posix-only/cross-references/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
from create_database_utils import * | ||
import runs_on | ||
import pytest | ||
|
||
run_codeql_database_create([ | ||
'swift package clean', | ||
'swift build' | ||
], lang='swift') | ||
|
||
@runs_on.posix | ||
@pytest.mark.ql_test("DB-CHECK", xfail=True) | ||
def test(codeql, swift): | ||
codeql.database.create(command="swift build") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
swift/ql/integration-tests/posix-only/deduplication/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from create_database_utils import * | ||
import runs_on | ||
|
||
run_codeql_database_create([ | ||
'swift package clean', | ||
'swift build', | ||
], lang='swift', keep_trap=True) | ||
|
||
@runs_on.posix | ||
def test(codeql, swift): | ||
codeql.database.create(command="swift build", keep_trap=True) |
36 changes: 19 additions & 17 deletions
36
swift/ql/integration-tests/posix-only/frontend-invocations/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
from create_database_utils import * | ||
from subprocess import check_call | ||
from hashlib import sha256 | ||
from pathlib import Path | ||
import runs_on | ||
import pytest | ||
|
||
run_codeql_database_create([ | ||
'./build.sh', | ||
], lang='swift', | ||
) | ||
|
||
with open('hashes.expected', 'w') as expected: | ||
for f in sorted(Path().glob("*.swiftmodule")): | ||
with open(f, 'rb') as module: | ||
print(f.name, sha256(module.read()).hexdigest(), file=expected) | ||
@runs_on.posix | ||
@pytest.mark.ql_test("DB-CHECK", xfail=True) | ||
def test(codeql, swift, expected_files): | ||
codeql.database.create(command="./build.sh") | ||
with open("hashes.expected", "w") as expected: | ||
for f in sorted(Path().glob("*.swiftmodule")): | ||
with open(f, "rb") as module: | ||
print(f.name, sha256(module.read()).hexdigest(), file=expected) | ||
|
||
with open('hashes.actual', 'w') as actual: | ||
hashes = [(s.name, s.resolve().name) for s in Path("test-db/working/swift-extraction-artifacts/store").iterdir()] | ||
hashes.sort() | ||
for module, hash in hashes: | ||
print(module, hash, file=actual) | ||
|
||
check_call(['diff', '-u', 'hashes.expected', 'hashes.actual']) | ||
with open("hashes.actual", "w") as actual: | ||
hashes = [ | ||
(s.name, s.resolve().name) | ||
for s in Path("test-db/working/swift-extraction-artifacts/store").iterdir() | ||
] | ||
hashes.sort() | ||
for module, hash in hashes: | ||
print(module, hash, file=actual) | ||
expected_files.add("hashes.expected") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from create_database_utils import * | ||
import runs_on | ||
|
||
run_codeql_database_create([ | ||
'swift package clean', | ||
'swift build' | ||
], lang='swift') | ||
|
||
@runs_on.posix | ||
def test(codeql, swift): | ||
codeql.database.create(command="swift build") |
11 changes: 7 additions & 4 deletions
11
swift/ql/integration-tests/posix-only/linkage-awareness/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
from create_database_utils import * | ||
import runs_on | ||
import pytest | ||
|
||
run_codeql_database_create([ | ||
'./build.sh', | ||
], lang='swift', keep_trap=True) | ||
|
||
@runs_on.posix | ||
@pytest.mark.ql_test("DB-CHECK", xfail=True) | ||
def test(codeql, swift): | ||
codeql.database.create(command="./build.sh") |
12 changes: 7 additions & 5 deletions
12
swift/ql/integration-tests/posix-only/partial-modules/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
from create_database_utils import * | ||
import runs_on | ||
import pytest | ||
|
||
run_codeql_database_create([ | ||
'swift package clean', | ||
'swift build' | ||
], lang='swift', keep_trap=True) | ||
|
||
@runs_on.posix | ||
@pytest.mark.ql_test("DB-CHECK", xfail=True) | ||
def test(codeql, swift): | ||
codeql.database.create(command="swift build") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
from create_database_utils import * | ||
import os | ||
import runs_on | ||
import pytest | ||
|
||
symlinks = ['preserve/Sources/A.swift', 'resolve/Sources/A.swift'] | ||
|
||
for s in symlinks: | ||
try: | ||
os.symlink(os.getcwd() + '/main.swift', s) | ||
except: | ||
pass | ||
@runs_on.posix | ||
@pytest.mark.ql_test("DB-CHECK", xfail=True) | ||
def test(codeql, swift): | ||
symlinks = ["preserve/Sources/A.swift", "resolve/Sources/A.swift"] | ||
|
||
run_codeql_database_create([ | ||
'swift package clean --package-path resolve', | ||
'swift build --package-path resolve', | ||
'swift package clean --package-path preserve', | ||
'env CODEQL_PRESERVE_SYMLINKS=true swift build --package-path preserve' | ||
], lang='swift', keep_trap=True) | ||
|
||
for s in symlinks: | ||
os.unlink(s) | ||
for s in symlinks: | ||
try: | ||
os.symlink(os.getcwd() + "/main.swift", s) | ||
except: | ||
pass | ||
codeql.database.create( | ||
command=[ | ||
"swift build --package-path resolve", | ||
"env CODEQL_PRESERVE_SYMLINKS=true swift build --package-path preserve", | ||
] | ||
) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.