diff options
author | Thomas Miedema <thomasmiedema@gmail.com> | 2015-08-29 15:52:43 +0200 |
---|---|---|
committer | Thomas Miedema <thomasmiedema@gmail.com> | 2016-05-17 18:06:05 +0200 |
commit | 3f3dc23ea64573a12e2f4bfdaaa3aa536ad3188d (patch) | |
tree | 19caf96220f19094efca6171fa980829f4b9794d /testsuite/driver/testutil.py | |
parent | dc94914eb0da985a2f006e2bd390fa1fdbafcc33 (diff) | |
download | haskell-3f3dc23ea64573a12e2f4bfdaaa3aa536ad3188d.tar.gz |
Testsuite: run tests in /tmp after copying required files
Major change to the testsuite driver.
For each TEST:
* create a directory `<testdir>` inside `/tmp`.
* link/copy all source files that the test needs into `<testdir>`.
* run the test inside `<testdir>`.
* delete `<testdir>`
Extra files are (temporarily) tracked in
`testsuite/driver/extra_files.py`, but can also be specified using the
`extra_files` setup function.
Differential Revision: https://phabricator.haskell.org/D1187
Reviewed by: Rufflewind, bgamari
Trac: #11980
Diffstat (limited to 'testsuite/driver/testutil.py')
-rw-r--r-- | testsuite/driver/testutil.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/testsuite/driver/testutil.py b/testsuite/driver/testutil.py index 029a3b6cb9..563ba3646c 100644 --- a/testsuite/driver/testutil.py +++ b/testsuite/driver/testutil.py @@ -1,7 +1,10 @@ # ----------------------------------------------------------------------------- # Utils +import errno +import os import subprocess +import shutil def version_to_ints(v): return [ int(x) for x in v.split('.') ] @@ -36,3 +39,32 @@ def getStdout(cmd_and_args): if stderr: raise Exception("stderr from command: " + str(cmd_and_args)) return stdout + +def mkdirp(path): + try: + os.makedirs(path) + except OSError as e: + if e.errno == errno.EEXIST and os.path.isdir(path): + pass + else: + raise + +def lndir(srcdir, dstdir): + # Create symlinks for all files in src directory. + # Not all developers might have lndir installed. + # os.system('lndir -silent {0} {1}'.format(srcdir, dstdir)) + for filename in os.listdir(srcdir): + src = os.path.join(srcdir, filename) + dst = os.path.join(dstdir, filename) + if os.path.isfile(src): + link_or_copy_file(src, dst) + else: + os.mkdir(dst) + lndir(src, dst) + +# On Windows, os.symlink is not defined. Except when using msys2, as ghc +# does. Then it copies the source file, instead of creating a symbolic +# link to it. We define the following function to make this magic more +# explicit/discoverable. You are enouraged to use it instead of +# os.symlink. +link_or_copy_file = getattr(os, "symlink", shutil.copyfile) |