Skip to content

Instantly share code, notes, and snippets.

@briancroom
Last active April 17, 2016 11:05
Show Gist options
  • Save briancroom/e2c22f162f8ba5211e31 to your computer and use it in GitHub Desktop.
Save briancroom/e2c22f162f8ba5211e31 to your computer and use it in GitHub Desktop.
Script to assist with conforming to XCTestCaseProvider
#!/usr/bin/python
# Invoke this script with a Swift file containing an XCTestCase and it will
# generate an implementation for the `allTests` variable required for
# XCTestCaseProvider conformance on Linux
import sys
import re
inFile = open(sys.argv[1]) if len(sys.argv) > 1 else sys.stdin
testNames = []
for line in inFile:
matchObj = re.search(r'func (test.*)\(\)', line)
if matchObj:
testNames.append(matchObj.group(1))
print "var allTests: [(String, () throws -> Void)] {"
print " return ["
for testName in testNames:
print " (\""+testName+"\", "+testName+"),"
print " ]"
print "}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment