Skip to content

Instantly share code, notes, and snippets.

@OliverLetterer
Forked from briancroom/xctest_finder.py
Created December 30, 2015 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OliverLetterer/14ce879ef6a65c7c5f95 to your computer and use it in GitHub Desktop.
Save OliverLetterer/14ce879ef6a65c7c5f95 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, () -> 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