1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
#!/usr/bin/python3
"Set up and run the OpenSCAD test suite"
# Copyright (C) 2012 chrysn <chrysn@fsfe.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# As a special exception, you have permission to link this program
# with the CGAL library and distribute executables, as long as you
# follow the requirements of the GNU GPL in regard to all of the
# software in the executable aside from CGAL.
import argparse
import os
import subprocess
import datetime
from os.path import join
from sys import byteorder
TESTSCRIPTS = "/usr/lib/openscad/testprograms"
TESTPROGRAMS = "/usr/libexec/openscad/testprograms"
EXAMPLES = "/usr/share/openscad/examples"
TESTDATA = "/usr/share/openscad/testdata"
REGRESSION = "/usr/share/openscad/regression"
LIBRARIES = "/usr/share/openscad/libraries"
OPENSCAD = "/usr/bin/openscad"
def main():
p = argparse.ArgumentParser(description=__doc__)
p.add_argument("-d", "--directory", help="Where to set up the files")
p.add_argument("-n", "--no-run", help="Just set up the files, don't run", action="store_true")
p.add_argument("--virtual", help="Run the tests on a virtual X server (xvfb-run)", action="store_true")
p.add_argument("additional", nargs="*", help="remaining arguments will be passed to ctest")
args = p.parse_args()
dirname = args.directory or "openscad-test-%s"%datetime.datetime.now().strftime("%Y-%m-%d_%H_%M")
builddir = join(dirname, "build")
print("Creating test infrastructure in", dirname)
os.mkdir(dirname)
os.mkdir(builddir)
os.symlink(EXAMPLES, join(dirname, "examples"))
# the csgpngtest family creates intermediate files like scad/3D/issues/issue1105c.scad.csg
subprocess.check_call(['cp', '-sa', TESTDATA, join(dirname, "testdata")])
os.symlink(REGRESSION, join(builddir, "regression"))
os.symlink(LIBRARIES, join(dirname, "libraries"))
os.symlink(OPENSCAD, join(dirname, "openscad"))
for dir in (TESTSCRIPTS, TESTPROGRAMS):
for f in os.listdir(dir):
os.symlink(join(dir, f), join(builddir, f))
# it's a lie, that's the gui version -- but we won't let anybody know...
#
# actually, the _nogui should be in another binary package, and
# alternatives should decide what is openscad in $PATH.
os.symlink('/usr/bin/openscad', join(builddir, 'openscad_nogui'))
# this is a workaround while the throwntogethertest handles includes subtly
# different from openscad's includes. in the build time tests, this does
# not surface as OPENSCADPATH has to be set anyway due to the default
# library include path depending on the binary location, which is not final
# in those tests.
#
# the tests that failed were throwntogethertest_text-search-test,
# throwntogethertest_include-tests and throwntogethertest_use-tests; it
# seems the importing failed in the second level of MCAD includes.
os.environ['OPENSCADPATH'] = '/usr/share/openscad/libraries'
if args.no_run:
print("Skipping test run")
else:
os.chdir(builddir)
# Put a default exclude pattern for tests that are know to fail:
# - Two tests that fail when run out-of-tree due to different paths
# in output.
# - Tests that require experimental features that are only available
# in development builds.
# - Two tests that fail on big-endian.
exclude_regex = 'echotest_include-overwrite-main|echotest_errors-warnings-included|astdumptest_allexpressions|echotest_function-literal-compare|echotest_function-literal-tests|echotest_allexpressions|lazyunion-.*'
if byteorder == 'big':
exclude_regex = exclude_regex + '|3mfpngtest_cube10|3mfexport_3mf-export'
exclude_regex = exclude_regex + '|cgalbinstlcgalpngtest_bad-stl-pcbvicebar|cgalbinstlcgalpngtest_bad-stl-tardis|cgalbinstlcgalpngtest_issue1225|cgalbinstlcgalpngtest_fn_bug'
exclude = ['--exclude-regex', '^(' + exclude_regex + ')']
if "-E" in args.additional or "--exclude-regex" in args.additional:
exclude = [ ];
# Run tests in parallel to speed things up, unless caller explicitly
# requested their own --parallel option.
parallel = [ ];
if not ("-j" in args.additional or
"--parallel" in args.additional or
"CTEST_PARALLEL_LEVEL" in os.environ):
try:
nproc_str = subprocess.run(["/usr/bin/nproc"],
check=True,
stdout=subprocess.PIPE).stdout
parallel = ["--parallel", str(int(nproc_str))]
except:
pass
invocation = ["ctest"] + parallel + exclude + args.additional
if args.virtual:
invocation = ['xvfb-run', '-s', '-screen 0 800x600x24 -noreset'] + invocation
os.execvp(invocation[0], invocation)
if __name__ == "__main__":
main()
|