Skip to content

Commit 6426b8d

Browse files
authored
Merge pull request github#10891 from github/alexdenisov/xcode-autobuilder-tests
Swift: add Xcode autobuilder tests
2 parents 71b6495 + bb31ff7 commit 6426b8d

File tree

12 files changed

+818
-1
lines changed

12 files changed

+818
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "Swift: Build and test Xcode autobuilder"
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "swift/xcode-autobuilder/**"
7+
- "misc/bazel/**"
8+
- "*.bazel*"
9+
- .github/workflows/swift-autobuilder.yml
10+
branches:
11+
- main
12+
13+
jobs:
14+
autobuilder:
15+
runs-on: macos-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: bazelbuild/setup-bazelisk@v2
19+
- uses: actions/setup-python@v3
20+
- name: Build the Xcode autobuilder
21+
run: |
22+
bazel build //swift/xcode-autobuilder
23+
- name: Test the Xcode autobuilder
24+
run: |
25+
bazel test //swift/xcode-autobuilder/tests

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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
xcuserdata
2+
build
3+
*.actual
4+
IDEWorkspaceChecks.plist
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[
2+
py_test(
3+
name = test_dir + '-test',
4+
size = "small",
5+
srcs = ['autobuild_tester.py'],
6+
main = 'autobuild_tester.py',
7+
data = [
8+
"//swift/xcode-autobuilder",
9+
test_dir,
10+
] + glob([test_dir + '/**/*']),
11+
args = [
12+
'$(location //swift/xcode-autobuilder)',
13+
'$(location %s)' % test_dir,
14+
]
15+
)
16+
for test_dir in glob(["*"], exclude_directories=0, exclude=['*.*', '.*'])
17+
]
18+
19+
test_suite(
20+
name='tests'
21+
)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
with open(actual, 'wb') as out:
15+
ret = subprocess.run([str(autobuilder), '-dry-run', '.'], capture_output=True, check=True, cwd=test_dir)
16+
for line in ret.stdout.splitlines():
17+
out.write(line.rstrip())
18+
out.write(b'\n')
19+
20+
subprocess.run(['diff', '-u', expected, actual], check=True)
21+
22+
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)