Skip to content

Commit 4821090

Browse files
committed
Fix benchmarks not running on Linux
Apparently, "swift test" has different behavior on Linux: 1. It outputs to stdout instead of stderr 2. Format of output itself differs, so regex in ppbenchmarks has to be adjusted.
1 parent dd9884e commit 4821090

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ jobs:
2323
os: osx
2424
osx_image: xcode10
2525
script:
26+
# On macOS swift test (i.e. XCTest) outputs to stderr so we need to redirect pipes.
2627
- swift test -c release -Xswiftc -enable-testing --filter BitByteDataBenchmarks 2>&1 | ./ppbenchmarks.py
2728
- language: generic
2829
os: linux
2930
dist: trusty
3031
install:
3132
- eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)"
3233
script:
33-
- swift test -c release -Xswiftc -enable-testing --filter BitByteDataBenchmarks 2>&1 | ./ppbenchmarks.py
34+
# On Linux swift test outputs to stdout so we don't need to do anything.
35+
- swift test -c release -Xswiftc -enable-testing --filter BitByteDataBenchmarks | ./ppbenchmarks.py
3436
- stage: deploy
3537
if: tag IS present
3638
language: generic

ppbenchmarks.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@
88
for line in sys.stdin:
99
line = line.rstrip()
1010
print(line)
11-
p = re.compile("Test Case '-\[BitByteDataBenchmarks\.(.+Benchmarks) (test.+)\]'.+average: (\d+.\d+), relative standard deviation: (\d+.\d+)\%")
11+
p = None
12+
# Output format of 'swift test' differs between macOS and Linux platforms.
13+
if sys.platform == "darwin":
14+
p = re.compile("Test Case '-\[BitByteDataBenchmarks\.(.+Benchmarks) (test.+)\]'.+average: (\d+.\d+), relative standard deviation: (\d+.\d+)\%")
15+
elif sys.platform == "linux":
16+
p = re.compile("Test Case '(.+Benchmarks)\.(test.+)'.+average: (\d+.\d+), relative standard deviation: (\d+.\d+)\%")
17+
else:
18+
raise Exception("Unknown platform: " + sys.platform)
19+
1220
matches = p.findall(line)
1321
if len(matches) == 1 and len(matches[0]) == 4:
1422
benchmark_name = matches[0][0]

0 commit comments

Comments
 (0)