Commit 66693401 authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺
Browse files

Fold testsuite.git into ghc.git (re #8545)

This commit performs a subtree merge of testsuite.git into ghc.git;
The next commit will adapt `sync-all` et al. to the new situation.

At the time of merge, testsuite.git was at commit
[998a816ae89c4fd573f4abd7c6abb346cf7ee9af/testsuite]

The following steps have been used to accomplish this merge:

1. Clone a fresh testsuite.git copy (& cd into)

2. Remove accidentally committed binary files from history

 git filter-branch \
  --index-filter "git rm -r --cached --ignore-unmatch \
    tests/haddock/should_compile_flag_nohaddock/a.out \
    tests/haddock/should_compile_noflag_nohaddock/a.out \
    tests/ghc-regress/haddock/should_compile_flag_nohaddock/a.out \
    tests/ghc-regress/haddock/should_compile_noflag_nohaddock/a.out \
    tests/ghc-regress/dph/diophantine/dph-diophantine-fast \
    tests/ghc-regress/dph/diophantine/dph-diophantine-opt \
    tests/ghc-regress/dph/primespj/dph-primespj-fast \
    tests/ghc-regress/dph/quickhull/dph-quickhull-fast \
    tests/ghc-regress/dph/smvm/dph-smvm \
    tests/ghc-regress/dph/sumnats/dph-sumnats \
    tests/ghc-regress/dph/words/dph-words-fast \
    tests/ghc-regress/plugins/plugins01" \
   HEAD

3. Rename all paths in testsuite.git to be prefixed with `testsuite/`

 git filter-branch -f --prune-empty --tree-filter \
  "mkdir -p testsuite; \
   git ls-tree --name-only \$GIT_COMMIT | xargs -I files mv files testsuite/"

4. cd into ghc/ checkout, and perform subtree merge of testsuite into ghc
   (see also http://nuclearsquid.com/writings/subtree-merging-and-you/

)

 cd ../ghc/
 git remote add -f testsuite ../testsuite/.git
 git merge -s ours --no-commit testsuite/master
 git read-tree --prefix=/ -u testsuite/master
 git commit
Signed-off-by: Herbert Valerio Riedel's avatarHerbert Valerio Riedel <hvr@gnu.org>
parents a924debc ad233cf6
......@@ -68,7 +68,6 @@ _darcs/
/libraries/unix/
/libraries/utf8-string/
/nofib/
/testsuite/
/utils/haddock/
/utils/hsc2hs/
......
This diff is collapsed.
The Glasgow Haskell Compiler License
Copyright 2002, The University Court of the University of Glasgow.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Neither name of the University nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
================================================================================
The GHC testsuite contains several files under different licenses, explained
here:
The following tests are under the GPLv3, or (at your option) any later version:
- tests/indexed-types/should_compile/T3787.hs
- tests/typecheck/should_compile/T4524.hs
- tests/simplCore/should_run/T3591.hs
You should have received a copy of the GNU General Public License along with
the GHC testsuite, in LICENSE.GPL
This diff is collapsed.
TOP = .
# If we're cleaning then we don't want to do all the GHC detection hardwork,
# and we certainly don't want to fail if GHC etc can't be found!
# However, we can't just put this conditional in boilerplate.mk, as
# some of the tests have a "clean" makefile target that relies on GHC_PKG
# being defined.
ifneq "$(MAKECMDGOALS)" "clean"
ifneq "$(MAKECMDGOALS)" "distclean"
ifneq "$(MAKECMDGOALS)" "maintainer-clean"
include $(TOP)/mk/boilerplate.mk
boot:
$(MAKE) -C $(TOP)/timeout all
all:
$(MAKE) -C $(TOP)/tests all
fast:
$(MAKE) -C $(TOP)/tests fast
endif
endif
endif
clean distclean maintainer-clean:
$(MAKE) -C $(TOP)/timeout $@
$(RM) -f mk/*.o
$(RM) -f mk/*.hi
$(RM) -f mk/ghcconfig*.mk
$(RM) -f mk/ghc-config mk/ghc-config.exe
$(RM) -f driver/*.pyc
@echo
@echo "NOTICE: To clean up test files, try running 'make CLEANUP=1 CLEAN_ONLY=YES'"
@echo
GHC Testsuite Readme
====================
For the full testsuite documentation, please see [here][1].
## Quick Guide
Commands to run testsuite:
* Full testsuite: `make`
* Using more threads: `make THREADS=12`
* Reduced (fast) testsuite: `make fast`
* Run a specific test: `make TEST=tc054`
* Test a specific 'way': `make WAY=optllvm`
* Test a specifc stage of GHC: `make stage=1`
* Skip performance tests: `make SKIP_PERF_TESTS=YES`
* Set verbosity: `make VERBOSE=n`
where n=0: No per-test ouput, n=1: Only failures,
n=2: Progress output, n=3: Include commands called (default)
* Pass in extra GHC options: `make EXTRA_HC_OPTS=-fvectorize`
You can also change directory to a specific test folder to run that
individual test or group of tests. For example:
``` .sh
$ cd tests/array
$ make
```
## Testsuite Ways
The testsuite can be run in a variety of 'ways'. This concept refers
to different ways that GHC can compile the code. For example, using
the native code generator (`-fasm`) is one way, while using the LLVM
code generator (`-fllvm`) is another way.
The various ways that GHC supports are defined in `config/ghc`
## Adding Tests
Please see the more extensive documentation [here][1].
[1]: http://hackage.haskell.org/trac/ghc/wiki/Building/RunningTests
This is a bad postscript file
import os
import re
# Testsuite configuration setup for GHC
#
# This file is Python source
#
config.compiler_type = 'ghc'
config.compiler = 'ghc'
config.compiler_always_flags = ghc_compiler_always_flags.split()
config.hp2ps = 'hp2ps'
config.hpc = 'hpc'
config.gs = 'gs'
config.confdir = '.'
# By default, we test the 'normal', 'opt' and 'hpc' ways.
# 'optasm' is added by mk/test.mk if the compiler has a native code gen,
# 'prof' is added by mk/test.mk if the profiling way is enabled.
config.compile_ways = ['normal', 'hpc']
config.run_ways = ['normal', 'hpc']
# ways that are not enabled by default, but can always be invoked explicitly
config.other_ways = ['extcore','optextcore',
'prof',
'prof_hc_hb','prof_hb',
'prof_hd','prof_hy','prof_hr',
'threaded1_ls', 'threaded2_hT',
'llvm', 'debugllvm',
'profllvm', 'profoptllvm', 'profthreadedllvm',
'threaded1llvm', 'threaded2llvm',
'dynllvm']
if (ghc_with_native_codegen == 1):
config.compile_ways.append('optasm')
config.run_ways.append('optasm')
config.compiler_debugged = ghc_debugged
if (ghc_with_vanilla == 1):
config.have_vanilla = True
if (ghc_with_dynamic == 1):
config.have_dynamic = True
if (ghc_with_profiling == 1):
config.have_profiling = True
config.compile_ways.append('profasm')
config.run_ways.append('profasm')
if (ghc_with_interpreter == 1):
config.have_interp = True
config.run_ways.append('ghci')
config.unregisterised = (ghc_unregisterised == 1)
if (ghc_with_threaded_rts == 1):
config.run_ways.append('threaded1')
if (ghc_with_smp == 1):
config.have_smp = True
config.run_ways.append('threaded2')
if (ghc_with_dynamic_rts == 1):
config.have_shared_libs = True
config.ghc_dynamic_by_default = ghc_dynamic_by_default
if ghc_dynamic_by_default and ghc_with_vanilla == 1:
config.run_ways.append('static')
else:
if (ghc_with_dynamic_rts == 1):
config.run_ways.append('dyn')
config.ghc_dynamic = ghc_dynamic
if (ghc_with_profiling == 1 and ghc_with_threaded_rts == 1):
config.run_ways.append('profthreaded')
if (ghc_with_llvm == 1):
config.compile_ways.append('optllvm')
config.run_ways.append('optllvm')
config.in_tree_compiler = in_tree_compiler
config.clean_only = clean_only
config.way_flags = lambda name : {
'normal' : [],
'g1' : [],
'optasm' : ['-O', '-fasm'],
'llvm' : ['-fllvm'],
'optllvm' : ['-O', '-fllvm'],
'debugllvm' : ['-fllvm', '-keep-llvm-files'],
'prof' : ['-prof', '-static', '-auto-all', '-fasm'],
'profasm' : ['-O', '-prof', '-static', '-auto-all'],
'profthreaded' : ['-O', '-prof', '-static', '-auto-all', '-threaded'],
'ghci' : ['--interactive', '-v0', '-ignore-dot-ghci', '+RTS', '-I0.1', '-RTS'],
'extcore' : ['-fext-core'],
'optextcore' : ['-O', '-fext-core'],
'threaded1' : ['-threaded', '-debug'],
'threaded1_ls' : ['-threaded', '-debug'],
'threaded2' : ['-O', '-threaded', '-eventlog'],
'threaded2_hT' : ['-O', '-threaded'],
'hpc' : ['-O', '-fhpc', '-hpcdir', '.hpc.' + name ],
'prof_hc_hb' : ['-O', '-prof', '-static', '-auto-all'],
'prof_hb' : ['-O', '-prof', '-static', '-auto-all'],
'prof_hd' : ['-O', '-prof', '-static', '-auto-all'],
'prof_hy' : ['-O', '-prof', '-static', '-auto-all'],
'prof_hr' : ['-O', '-prof', '-static', '-auto-all'],
'dyn' : ['-O', '-dynamic'],
'static' : ['-O', '-static'],
# llvm variants...
'profllvm' : ['-prof', '-static', '-auto-all', '-fllvm'],
'profoptllvm' : ['-O', '-prof', '-static', '-auto-all', '-fllvm'],
'profthreadedllvm' : ['-O', '-prof', '-static', '-auto-all', '-threaded', '-fllvm'],
'threaded1llvm' : ['-threaded', '-debug', '-fllvm'],
'threaded2llvm' : ['-O', '-threaded', '-eventlog', '-fllvm'],
'dynllvm' : ['-O', '-dynamic', '-fllvm']
}
config.way_rts_flags = {
'normal' : [],
'g1' : ['-G1'],
'optasm' : [],
'llvm' : [],
'optllvm' : [],
'debugllvm' : [],
'prof' : ['-p'],
'profasm' : ['-hc', '-p'], # test heap profiling too
'profthreaded' : ['-p'],
'ghci' : [],
'extcore' : [],
'optextcore' : [],
'threaded1' : [],
'threaded1_ls' : ['-ls'],
'threaded2' : ['-N2 -ls'],
'threaded2_hT' : ['-N2', '-hT'],
'hpc' : [],
'prof_hc_hb' : ['-hc -hbvoid'],
'prof_hb' : ['-hb'],
'prof_hd' : ['-hd'],
'prof_hy' : ['-hy'],
'prof_hr' : ['-hr'],
'dyn' : [],
'static' : [],
# llvm variants...
'profllvm' : ['-p'],
'profoptllvm' : ['-hc', '-p'],
'profthreadedllvm' : ['-p'],
'threaded1llvm' : [],
'threaded2llvm' : ['-N2 -ls'],
'dynllvm' : []
}
# Useful classes of ways that can be used with only_ways() and
# expect_broken_for().
prof_ways = map (lambda x: x[0], \
filter(lambda x: '-prof' in x[1], \
config.way_flags('dummy_name').items()))
threaded_ways = map (lambda x: x[0], \
filter(lambda x: '-threaded' in x[1] or 'ghci' == x[0], \
config.way_flags('dummy_name').items()))
opt_ways = map (lambda x: x[0], \
filter(lambda x: '-O' in x[1], \
config.way_flags('dummy_name').items()))
def get_compiler_info():
# This should really not go through the shell
h = os.popen('"' + config.compiler + '" --info', 'r')
s = h.read()
s = re.sub('[\r\n]', '', s)
h.close()
compilerInfoDict = dict(eval(s))
h = os.popen('"' + config.compiler + '" +RTS --info', 'r')
s = h.read()
s = re.sub('[\r\n]', '', s)
h.close()
rtsInfoDict = dict(eval(s))
# We use a '/'-separated path for libdir, even on Windows
config.libdir = re.sub('\\\\','/',compilerInfoDict['LibDir'])
v = compilerInfoDict["Project version"].split('-')
config.compiler_version = v[0]
config.compiler_maj_version = re.sub('^([0-9]+\.[0-9]+).*',r'\1', v[0])
config.compiler_tags = v[1:]
# -fno-ghci-history was added in 7.3
if version_ge(config.compiler_version, '7.3'):
config.compiler_always_flags = \
config.compiler_always_flags + ['-fno-ghci-history']
if re.match(".*_p(_.*|$)", rtsInfoDict["RTS way"]):
config.compiler_profiled = True
config.run_ways = filter(lambda x: x != 'ghci', config.run_ways)
else:
config.compiler_profiled = False
try:
config.package_conf_cache_file = compilerInfoDict["Global Package DB"] + '/package.cache'
except:
config.package_conf_cache_file = ''
try:
if compilerInfoDict["GHC Dynamic"] == "YES":
ghcDynamic = True
elif compilerInfoDict["GHC Dynamic"] == "NO":
ghcDynamic = False
else:
raise 'Bad value for "GHC Dynamic"'
except KeyError:
# GHC < 7.7 doesn't have a "GHC Dynamic" field
ghcDynamic = False
if ghcDynamic:
config.ghc_th_way_flags = "-dynamic"
config.ghci_way_flags = "-dynamic"
config.ghc_th_way = "dyn"
config.ghc_plugin_way = "dyn"
else:
config.ghc_th_way_flags = "-static"
config.ghci_way_flags = "-static"
config.ghc_th_way = "normal"
config.ghc_plugin_way = "normal"
% this is a good postscript file
#
# (c) Simon Marlow 2002
#
import sys
import os
import string
import getopt
import platform
import time
import re
# We don't actually need subprocess in runtests.py, but:
# * We do need it in testlibs.py
# * We can't import testlibs.py until after we have imported ctypes
# * If we import ctypes before subprocess on cygwin, then sys.exit(0)
# says "Aborted" and we fail with exit code 134.
# So we import it here first, so that the testsuite doesn't appear to fail.
try:
import subprocess
except:
pass
from testutil import *
from testglobals import *
# Readline sometimes spews out ANSI escapes for some values of TERM,
# which result in test failures. Thus set TERM to a nice, simple, safe
# value.
os.environ['TERM'] = 'vt100'
global config
config = getConfig() # get it from testglobals
# -----------------------------------------------------------------------------
# cmd-line options
long_options = [
"config=", # config file
"rootdir=", # root of tree containing tests (default: .)
"output-summary=", # file in which to save the (human-readable) summary
"only=", # just this test (can be give multiple --only= flags)
"way=", # just this way
"skipway=", # skip this way
"threads=", # threads to run simultaneously
"check-files-written", # check files aren't written by multiple tests
"verbose=", # verbose (0,1,2 so far)
"skip-perf-tests", # skip performance tests
]
opts, args = getopt.getopt(sys.argv[1:], "e:", long_options)
for opt,arg in opts:
if opt == '--config':
execfile(arg)
# -e is a string to execute from the command line. For example:
# testframe -e 'config.compiler=ghc-5.04'
if opt == '-e':
exec arg
if opt == '--rootdir':
config.rootdirs.append(arg)
if opt == '--output-summary':
config.output_summary = arg
if opt == '--only':
config.only.append(arg)
if opt == '--way':
if (arg not in config.run_ways and arg not in config.compile_ways and arg not in config.other_ways):
sys.stderr.write("ERROR: requested way \'" +
arg + "\' does not exist\n")
sys.exit(1)
config.cmdline_ways = [arg] + config.cmdline_ways
if (arg in config.other_ways):
config.run_ways = [arg] + config.run_ways
config.compile_ways = [arg] + config.compile_ways
if opt == '--skipway':
if (arg not in config.run_ways and arg not in config.compile_ways and arg not in config.other_ways):
sys.stderr.write("ERROR: requested way \'" +
arg + "\' does not exist\n")
sys.exit(1)
config.other_ways = filter(neq(arg), config.other_ways)
config.run_ways = filter(neq(arg), config.run_ways)
config.compile_ways = filter(neq(arg), config.compile_ways)
if opt == '--threads':
config.threads = int(arg)
config.use_threads = 1
if opt == '--check-files-written':
config.check_files_written = True
if opt == '--skip-perf-tests':
config.skip_perf_tests = True
if opt == '--verbose':
if arg not in ["0","1","2","3"]:
sys.stderr.write("ERROR: requested verbosity %s not supported, use 0,1,2 or 3" % arg)
sys.exit(1)
config.verbose = int(arg)
if config.use_threads == 1:
# Trac #1558 says threads don't work in python 2.4.4, but do
# in 2.5.2. Probably >= 2.5 is sufficient, but let's be
# conservative here.
# Some versions of python have things like '1c1' for some of
# these components (see trac #3091), but int() chokes on the
# 'c1', so we drop it.
(maj, min, pat) = platform.python_version_tuple()
# We wrap maj, min, and pat in str() to work around a bug in python
# 2.6.1
maj = int(re.sub('[^0-9].*', '', str(maj)))
min = int(re.sub('[^0-9].*', '', str(min)))
pat = int(re.sub('[^0-9].*', '', str(pat)))
if (maj, min, pat) < (2, 5, 2):
print "Warning: Ignoring request to use threads as python version < 2.5.2"
config.use_threads = 0
# We also need to disable threads for python 2.7.2, because of
# this bug: http://bugs.python.org/issue13817
elif (maj, min, pat) == (2, 7, 2):
print "Warning: Ignoring request to use threads as python version is 2.7.2"
print "See http://bugs.python.org/issue13817 for details."
config.use_threads = 0
if windows:
print "Warning: Ignoring request to use threads as running on Windows"
config.use_threads = 0
config.cygwin = False
config.msys = False
if windows:
h = os.popen('uname -s', 'r')
v = h.read()
h.close()
if v.startswith("CYGWIN"):
config.cygwin = True
elif v.startswith("MINGW"):
# msys gives "MINGW32"
# msys2 gives "MINGW_NT-6.2"
config.msys = True
else:
raise Exception("Can't detect Windows terminal type")
# Try to use UTF8
if windows:
import ctypes
if config.cygwin:
# Is this actually right? Which calling convention does it use?
# As of the time of writing, ctypes.windll doesn't exist in the
# cygwin python, anyway.
mydll = ctypes.cdll
else:
mydll = ctypes.windll
# This actually leaves the terminal in codepage 65001 (UTF8) even
# after python terminates. We ought really remember the old codepage
# and set it back.
if mydll.kernel32.SetConsoleCP(65001) == 0:
raise Exception("Failure calling SetConsoleCP(65001)")
if mydll.kernel32.SetConsoleOutputCP(65001) == 0:
raise Exception("Failure calling SetConsoleOutputCP(65001)")
else:
# Try and find a utf8 locale to use
# First see if we already have a UTF8 locale
h = os.popen('locale | grep LC_CTYPE | grep -i utf', 'r')
v = h.read()
h.close()
if v == '':
# We don't, so now see if 'locale -a' works
h = os.popen('locale -a', 'r')
v = h.read()
h.close()
if v != '':
# If it does then use the first utf8 locale that is available
h = os.popen('locale -a | grep -i "utf8\|utf-8" 2>/dev/null', 'r')
v = h.readline().strip()
h.close()
if v != '':
os.environ['LC_ALL'] = v
print "setting LC_ALL to", v
else:
print 'WARNING: No UTF8 locale found.'
print 'You may get some spurious test failures.'
# This has to come after arg parsing as the args can change the compiler
get_compiler_info()
# Can't import this earlier as we need to know if threading will be
# enabled or not
from testlib import *
# On Windows we need to set $PATH to include the paths to all the DLLs
# in order for the dynamic library tests to work.
if windows or darwin:
pkginfo = getStdout([config.ghc_pkg, 'dump'])
topdir = config.libdir
for line in pkginfo.split('\n'):
if line.startswith('library-dirs:'):
path = line.rstrip()
path = re.sub('^library-dirs: ', '', path)
path = re.sub('\\$topdir', topdir, path)
if path.startswith('"'):
path = re.sub('^"(.*)"$', '\\1', path)
path = re.sub('\\\\(.)', '\\1', path)
if windows:
if config.cygwin:
# On cygwin we can't put "c:\foo" in $PATH, as : is a
# field separator. So convert to /cygdrive/c/foo instead.
# Other pythons use ; as the separator, so no problem.
path = re.sub('([a-zA-Z]):', '/cygdrive/\\1', path)
path = re.sub('\\\\', '/', path)
os.environ['PATH'] = os.pathsep.join([path, os.environ.get("PATH", "")])
else:
# darwin
os.environ['DYLD_LIBRARY_PATH'] = os.pathsep.join([path, os.environ.get("DYLD_LIBRARY_PATH", "")])
global testopts_local
testopts_local.x = TestOptions()
if config.use_threads:
t.lock = threading.Lock()
t.thread_pool = threading.Condition(t.lock)
t.lockFilesWritten = threading.Lock()
t.running_threads = 0
# if timeout == -1 then we try to calculate a sensible value
if config.timeout == -1:
config.timeout = int(read_no_crs(config.top + '/timeout/calibrate.out'))
print 'Timeout is ' + str(config.timeout)
# -----------------------------------------------------------------------------
# The main dude
if config.rootdirs == []:
config.rootdirs = ['.']
t_files = findTFiles(config.rootdirs)
print 'Found', len(t_files), '.T files...'
t = getTestRun()
# Avoid cmd.exe built-in 'date' command on Windows
t.start_time = time.localtime()
print 'Beginning test run at', time.strftime("%c %Z",t.start_time)
# set stdout to unbuffered (is this the best way to do it?)
sys.stdout.flush()