dmd/test/Makefile
2011-01-23 22:33:24 -08:00

212 lines
7 KiB
Makefile

# Execute the dmd test suite
#
# Targets:
#
# default | all: run all unit tests that haven't been run yet
#
# run_tests: run all tests
# run_runnable_tests: run just the runnable tests
# run_compilable_tests: run just the runnable tests
# run_fail_compilation_tests: run just the runnable tests
#
# quick: run all tests with no default permuted args
# (individual test specified options still honored)
#
# clean: remove all temporary or result files from prevous runs
#
#
# In-test variables:
#
# COMPILE_SEPARATELY: if present, forces each .d file to compile separately and linked
# together in an extra setp.
# default: (none, aka compile/link all in one step)
#
# EXECUTE_ARGS: parameters to add to the execution of the test
# default: (none)
#
# EXTRA_SOURCES: list of extra files to build and link along with the test
# default: (none)
#
# PERMUTE_ARGS: the set of arguments to permute in multiple $(DMD) invocations
# default: the make variable ARGS (see below)
#
# POST_SCRIPT: name of script to execute after test run
# default: (none)
#
# REQUIRED_ARGS: arguments to add to the $(DMD) command line
# default: (none)
ifeq (,$(OS))
OS:=$(shell uname)
ifeq (Darwin,$(OS))
OS:=osx
else
ifeq (Linux,$(OS))
OS:=posix
else
ifeq (FreeBSD,$(OS))
OS:=freebsd
else
$(error Unrecognized or unsupported OS for uname: $(OS))
endif
endif
endif
else
ifeq (Windows_NT,$(OS))
OS:=win32
else
ifeq (Win_32,$(OS))
OS:=win32
endif
endif
endif
export OS
SHELL=/bin/bash
QUIET=@
export RESULTS_DIR=test_results
export MODEL=32
ifeq ($(OS),win32)
export ARGS=-inline -release -g -O -unittest
export DMD=../src/dmd.exe
export EXE=.exe
export OBJ=.obj
export DSEP=\\
export SEP=$(shell echo '\')
# bug in vim syntax hilighting, needed to kick it back into life: ')
else
export ARGS=-inline -release -gc -O -unittest -fPIC
export DMD=../src/dmd
export EXE=
export OBJ=.o
export DSEP=/
export SEP=/
endif
runnable_tests=$(wildcard runnable/*.d) $(wildcard runnable/*.html) $(wildcard runnable/*.sh)
runnable_test_results=$(addsuffix .out,$(addprefix $(RESULTS_DIR)/,$(runnable_tests)))
compilable_tests=$(wildcard compilable/*.d)
compilable_test_results=$(addsuffix .out,$(addprefix $(RESULTS_DIR)/,$(compilable_tests)))
fail_compilation_tests=$(wildcard fail_compilation/*.d)
fail_compilation_test_results=$(addsuffix .out,$(addprefix $(RESULTS_DIR)/,$(fail_compilation_tests)))
all: run_tests
ifeq ($(MODEL),64)
DISABLED_TESTS += testmath
# needs std.math
DISABLED_TESTS += hospital
# int vs long issues
DISABLED_TESTS += s2ir
DISABLED_TESTS += test16
DISABLED_TESTS += test20
DISABLED_TESTS += test28
# -fPIC: transition from R_X86_64_TLSGD to R_X86_64_GOTTPOFF against
DISABLED_TESTS += test22
# has x86 specific asm code that needs translation
DISABLED_TESTS += test34
# looks like lots of issues with std.format, at least array and aa formatting is borked..
DISABLED_TESTS += testarray
# sensitive code checking a specific runtime bug
DISABLED_TESTS += testconst
# segv in a misleading place.. printfs around the functions in the backtrace
# not firing. More research needed.
DISABLED_TESTS += testgc2
# various gc related issues
DISABLED_TESTS += testzip
# zlib version error
$(addsuffix .d.out,$(addprefix $(RESULTS_DIR)/runnable/,$(DISABLED_TESTS))): $(RESULTS_DIR)/.created
$(QUIET) echo " ... $@ - disabled"
$(RESULTS_DIR)/runnable/test2.sh.out:
$(QUIET) echo " ... $@ - disabled"
$(QUIET) touch $@
$(RESULTS_DIR)/runnable/%.d.out: runnable/%.d $(RESULTS_DIR)/.created $(RESULTS_DIR)/combinations $(DMD)
$(QUIET) ./do_test.sh $(<D) $* d
$(RESULTS_DIR)/runnable/%.html.out: runnable/%.html $(RESULTS_DIR)/.created $(RESULTS_DIR)/combinations $(DMD)
$(QUIET) ./do_test.sh $(<D) $* html
$(RESULTS_DIR)/runnable/%.sh.out: runnable/%.sh $(RESULTS_DIR)/.created $(RESULTS_DIR)/combinations $(DMD)
$(QUIET) echo " ... $(<D)/$*.sh"
$(QUIET) ./$(<D)/$*.sh
$(RESULTS_DIR)/compilable/%.d.out: compilable/%.d $(RESULTS_DIR)/.created $(RESULTS_DIR)/combinations $(DMD)
$(QUIET) ./do_test.sh $(<D) $* d
$(RESULTS_DIR)/fail_compilation/%.d.out: fail_compilation/%.d $(RESULTS_DIR)/.created $(RESULTS_DIR)/combinations $(DMD)
$(QUIET) ./do_test.sh $(<D) $* d
else
$(RESULTS_DIR)/runnable/%.d.out: runnable/%.d $(RESULTS_DIR)/.created $(RESULTS_DIR)/d_do_test $(DMD)
$(QUIET) ./$(RESULTS_DIR)/d_do_test $(<D) $* d
$(RESULTS_DIR)/runnable/%.html.out: runnable/%.html $(RESULTS_DIR)/.created $(RESULTS_DIR)/d_do_test $(DMD)
$(QUIET) ./$(RESULTS_DIR)/d_do_test $(<D) $* html
$(RESULTS_DIR)/runnable/%.sh.out: runnable/%.sh $(RESULTS_DIR)/.created $(RESULTS_DIR)/d_do_test $(DMD)
$(QUIET) echo " ... $(<D)/$*.sh"
$(QUIET) ./$(<D)/$*.sh
$(RESULTS_DIR)/compilable/%.d.out: compilable/%.d $(RESULTS_DIR)/.created $(RESULTS_DIR)/d_do_test $(DMD)
$(QUIET) ./$(RESULTS_DIR)/d_do_test $(<D) $* d
$(RESULTS_DIR)/fail_compilation/%.d.out: fail_compilation/%.d $(RESULTS_DIR)/.created $(RESULTS_DIR)/d_do_test $(DMD)
$(QUIET) ./$(RESULTS_DIR)/d_do_test $(<D) $* d
endif
quick:
$(MAKE) ARGS="" run_tests
clean:
@echo "Removing output directory: $(RESULTS_DIR)"
$(QUIET)if [ -e $(RESULTS_DIR) ]; then rm -rf $(RESULTS_DIR); fi
$(RESULTS_DIR)/.created:
@echo Creating output directory: $(RESULTS_DIR)
$(QUIET)if [ ! -d $(RESULTS_DIR) ]; then mkdir $(RESULTS_DIR); fi
$(QUIET)if [ ! -d $(RESULTS_DIR)/runnable ]; then mkdir $(RESULTS_DIR)/runnable; fi
$(QUIET)if [ ! -d $(RESULTS_DIR)/compilable ]; then mkdir $(RESULTS_DIR)/compilable; fi
$(QUIET)if [ ! -d $(RESULTS_DIR)/fail_compilation ]; then mkdir $(RESULTS_DIR)/fail_compilation; fi
$(QUIET)touch $(RESULTS_DIR)/.created
run_tests: start_runnable_tests start_compilable_tests start_fail_compilation_tests
run_runnable_tests: $(runnable_test_results)
start_runnable_tests: $(RESULTS_DIR)/.created $(RESULTS_DIR)/d_do_test
@echo "Running runnable tests"
$(QUIET)$(MAKE) --no-print-directory run_runnable_tests
run_compilable_tests: $(compilable_test_results)
start_compilable_tests: $(RESULTS_DIR)/.created $(RESULTS_DIR)/d_do_test
@echo "Running compilable tests"
$(QUIET)$(MAKE) --no-print-directory run_compilable_tests
run_fail_compilation_tests: $(fail_compilation_test_results)
start_fail_compilation_tests: $(RESULTS_DIR)/.created $(RESULTS_DIR)/d_do_test
@echo "Running fail compilation tests"
$(QUIET)$(MAKE) --no-print-directory run_fail_compilation_tests
$(RESULTS_DIR)/d_do_test: d_do_test.d $(RESULTS_DIR)/.created
@echo "Building d_do_test tool"
$(QUIET)$(DMD) -m$(MODEL) -od$(RESULTS_DIR) -of$(RESULTS_DIR)$(DSEP)d_do_test d_do_test.d
$(RESULTS_DIR)/combinations: combinations.d $(RESULTS_DIR)/.created
@echo "Building combinations tool"
$(QUIET)$(DMD) -m$(MODEL) -od$(RESULTS_DIR) -of$(RESULTS_DIR)$(DSEP)combinations combinations.d