Skip to content

Commit

Permalink
Merge pull request #248 from stan-dev/feature/issue-247-runtests
Browse files Browse the repository at this point in the history
Fixes #247. Updating runTests.py and makefile
  • Loading branch information
syclik committed Mar 8, 2016
2 parents 849be86 + a521399 commit 0c044b0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
8 changes: 7 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,16 @@ endif
@echo ''
@echo ' Header tests'
@echo ' - test-headers : tests all source headers to ensure they are compilable and'
@echo ' include enough header files.'
@echo ' include enough header files.'
@echo ''
@echo ' To run a single header test, add "-test" to the end of the file name.'
@echo ' Example: make stan/math/constants.hpp-test'
@echo ' - test-math-dependencies : walks through all the header files and indicates'
@echo ' when the math dependencies are violated. Dependencies should follow:'
@echo ' * rev -> prim'
@echo ' * fwd -> prim'
@echo ' * mix -> {rev, fwd, prim}'
@echo ' * within {prim, rev, fwd, mix}: mat -> arr -> scal'
@echo ''
@echo ' Cpplint'
@echo ' - cpplint : runs cpplint.py on source files. requires python 2.7.'
Expand Down
24 changes: 13 additions & 11 deletions runTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import sys
import subprocess
import time
import re

winsfx = ".exe"
testsfx = "_test.cpp"
Expand All @@ -34,7 +35,7 @@ def isWin():
return True
return False

# set up good makefile target name
# set up good makefile target name
def mungeName(name):
if (name.endswith(testsfx)):
name = name.replace(testsfx,"_test")
Expand Down Expand Up @@ -65,7 +66,7 @@ def makeTest(name, j):
else:
command = 'make -j%d %s' % (j,target)
doCommand(command)

def makeTests(dirname, filenames, j):
targets = list()
for name in filenames:
Expand All @@ -92,7 +93,7 @@ def makeTests(dirname, filenames, j):
endIdx = startIdx + batchSize
if (endIdx > len(targets)):
endIdx = len(targets)


def runTest(name):
executable = mungeName(name).replace("/",os.sep)
Expand All @@ -115,17 +116,19 @@ def main():
try:
jprime = int(j)
if (jprime < 1 or jprime > 16):
stopErr("bad value for -j flag",-1)
stopErr("bad value for -j flag",-1)
j = jprime
except ValueError:
stopErr("bad value for -j flag",-1)

# pass 0: generate all auto-generated tests
generateTests(j)
tests = sys.argv[argsIdx:]
prob_args = ['test/prob' in arg for arg in tests]
if any(prob_args):
generateTests(j)

# pass 1: call make to compile test targets
for i in range(argsIdx,len(sys.argv)):
testname = sys.argv[i]
for testname in tests:
if (not(os.path.exists(testname))):
stopErr('%s: no such file or directory' % testname,-1)
if (not(os.path.isdir(testname))):
Expand All @@ -141,8 +144,7 @@ def main():
makeTests(root,files,j)

# pass 2: run test targets
for i in range(argsIdx,len(sys.argv)):
testname = sys.argv[i]
for testname in tests:
if (not(os.path.isdir(testname))):
if (debug):
print("run single test: %s" % testname)
Expand All @@ -155,6 +157,6 @@ def main():
print("run dir,test: %s,%s" % (root,name))
runTest(os.sep.join([root,name]))


if __name__ == "__main__":
main()

0 comments on commit 0c044b0

Please sign in to comment.