Skip to content

Commit e514855

Browse files
committed
Swift: introduce xcode-autobuilder tests
1 parent 0c3fd9f commit e514855

File tree

8 files changed

+419
-1
lines changed

8 files changed

+419
-1
lines changed

swift/xcode-autobuilder/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ swift_cc_binary(
77
"*.cpp",
88
"*.h",
99
]),
10-
visibility = ["//swift:__pkg__"],
10+
visibility = ["//swift:__subpackages__"],
1111
linkopts = [
1212
"-lxml2",
1313
"-framework CoreFoundation",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
xcuserdata
2+
build
3+
*.actual
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
py_test(
2+
name = 'hello-autobuilder-test',
3+
size = "small",
4+
srcs = ['autobuild_tester.py'],
5+
main = 'autobuild_tester.py',
6+
data = [
7+
"//swift/xcode-autobuilder",
8+
'hello-autobuilder',
9+
] + glob(['hello-autobuilder/**/*'], exclude = ['**/*.actual']),
10+
args = [
11+
'$(location //swift/xcode-autobuilder)',
12+
'$(location hello-autobuilder)',
13+
]
14+
)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python3
2+
3+
import sys
4+
import subprocess
5+
import pathlib
6+
import os
7+
8+
autobuilder = pathlib.Path(sys.argv[1]).absolute()
9+
test_dir = pathlib.Path(sys.argv[2])
10+
11+
expected = test_dir / 'commands.expected'
12+
actual = pathlib.Path('commands.actual')
13+
14+
print(os.getcwd())
15+
16+
with open(actual, 'wb') as out:
17+
ret = subprocess.run([str(autobuilder), '-dry-run', '.'], capture_output=True, check=True, cwd=test_dir)
18+
for line in ret.stdout.splitlines():
19+
out.write(line.rstrip())
20+
out.write(b'\n')
21+
22+
subprocess.run(['diff', '-u', expected, actual], check=True)
23+
24+
print("SUCCESS!")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/usr/bin/xcodebuild build -project ./hello-autobuilder.xcodeproj -target hello-autobuilder CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO

0 commit comments

Comments
 (0)