Commits

Daniel Green committed b6fdbee

Convert testsuite to be compatible with GCC.

Comments (0)

Files changed (1493)

+# 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
+
+ifeq (freebsd,$(OS))
+    SHELL=/usr/local/bin/bash
+else
+    SHELL=/bin/bash
+endif
+QUIET=@
+#QUIET=
+export RESULTS_DIR=test_results
+export MODEL=32
+#export MODEL=64
+
+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 -g -O -unittest -gs
+export DMD=gdmd
+export EXE=
+export OBJ=.o
+export DSEP=/
+export SEP=/
+endif
+
+ifeq ($(OS),freebsd)
+DISABLED_TESTS += a20
+DISABLED_TESTS += cov2
+# coverage issues, see bug 5619
+
+DISABLED_TESTS += builtin
+# precision related bug: Error: static assert  (0x1.f9f8d9aea10fb28ep-2L == 0x1.f9f8d9aea10fdf1cp-2L) is false
+
+DISABLED_TESTS += dhry
+# runnable/dhry.d(488): Error: undefined identifier dtime
+
+# 64 bit test failures
+DISABLED_TESTS += test17
+DISABLED_SH_TESTS += test39
+endif
+
+ifeq ($(DMD),gdmd)
+DMD=$(shell which gdmd)
+
+# gdc does not implement dmd coverage
+DISABLED_TESTS += a20 cov2 sieve
+
+# gdc does not implement dmd profiling
+DISABLED_TESTS += hello-profile
+
+# inout contract inheritance unimplemented
+#DISABLED_TESTS += test42 testcontracts
+
+# no exception chaining in gdc
+DISABLED_TESTS += eh test4
+
+# iasm not up to par with DMD
+DISABLED_TESTS += iasm iasm64
+
+# std.format bug
+DISABLED_TESTS += testformat
+
+# New closures bug
+#DISABLED_TESTS += inner nested
+
+# NRVO unimplemented
+#DISABLED_TESTS += sdtor
+
+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
+
+$(addsuffix .d.out,$(addprefix $(RESULTS_DIR)/runnable/,$(DISABLED_TESTS))): $(RESULTS_DIR)/.created
+	$(QUIET) echo " ... $@ - disabled"
+
+$(addsuffix .sh.out,$(addprefix $(RESULTS_DIR)/runnable/,$(DISABLED_SH_TESTS))): $(RESULTS_DIR)/.created
+	$(QUIET) echo " ... $@ - disabled"
+
+$(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
+
+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) -g -od$(RESULTS_DIR) -of$(RESULTS_DIR)$(DSEP)d_do_test d_do_test.d
+

gdc.test/combinations.d

+extern(C) int printf(const char*, ...);
+
+void main(string[] args)
+{
+    args = args[1..$];
+    long combinations = 1 << args.length;
+    for (size_t i = 0; i < combinations; i++)
+    {
+        bool printed = false;
+
+        //printf("\"");
+        for (size_t j = 0; j < args.length; j++)
+        {
+            if (i & 1 << j)
+            {
+                if (printed)
+                    printf(" ");
+                printf("%.*s", args[j].length, args[j].ptr);
+                printed = true;
+            }
+        }
+        //printf("\"\n");
+        printf("\n");
+    }
+}

gdc.test/compilable/99bottles.d

+// written by Don Clugston:
+//    http://www.digitalmars.com/d/archives/digitalmars/D/announce/4374.html
+//    http://www.99-bottles-of-beer.net/language-d-1212.html
+
+// Displays the "99 bottles of beer" song at compile time,
+// using the template metaprograming facilities of D. 
+// No executable is generated. No libraries are used.
+// Illustrates template default values, template string value parameters,
+// compile-time concatenation of constant strings, static if.
+
+module bottles99;
+
+template decimaldigit(int n) {
+    const string decimaldigit = "0123456789"[n..n+1];
+}
+
+template itoa(ulong n)
+{
+    static if ( n < 10L )
+	const string itoa = decimaldigit!(n);
+    else
+	const string itoa = itoa!( n / 10L ) ~ decimaldigit!( n % 10L );
+}
+
+template showHowMany(int n, string where, bool needcapital = false)
+{
+  static if ( n > 1 ) 
+      const string showHowMany = itoa!(n) ~ " bottles of beer" ~ where ~ "\n";
+  else static if ( n == 1 )
+      const string showHowMany = "1 bottle of beer" ~ where ~ "\n";
+  else static if ( needcapital )
+      const string showHowMany = "No more bottles of beer" ~ where ~ "\n";
+  else 
+      const string showHowMany = "no more bottles of beer" ~ where ~ "\n";
+}