File: openscad-testrun

package info (click to toggle)
openscad 2019.01~RC2-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 33,296 kB
  • sloc: cpp: 49,451; ansic: 4,381; sh: 4,320; python: 1,585; yacc: 766; lex: 384; lisp: 134; xml: 127; makefile: 76
file content (91 lines) | stat: -rwxr-xr-x 3,928 bytes parent folder | download
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
#!/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

TESTPROGRAMS = "/usr/lib/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 f in os.listdir(TESTPROGRAMS):
        os.symlink(join(TESTPROGRAMS, 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:
        #  - Customizer/SVG tests, because those are experimental features not
        #    enabled in the Debian binary.
        #  - Two tests that fail when run out-of-tree due to different paths
        #    in output.
        exclude = ['--exclude-regex', '^(customizertest|svgpngtest|echotest_include-overwrite-main|echotest_errors-warnings-included)']
        if "-E" in args.additional or "--exclude-regex" in args.additional:
            exclude = [ ];
        invocation = ["ctest"] + exclude + args.additional
        if args.virtual:
            invocation = ['xvfb-run', '-s', '-screen 0 800x600x24'] + invocation
        os.execvp(invocation[0], invocation)

if __name__ == "__main__":
    main()