Last active
April 17, 2016 11:05
-
-
Save briancroom/e2c22f162f8ba5211e31 to your computer and use it in GitHub Desktop.
Script to assist with conforming to XCTestCaseProvider
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
#!/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