Merge pull request #1525 from akoeplinger/fix-dynamicdata-test
[mono-project.git] / mcs / build / tests.make
bloba576ba602dbff7e642312899cdcacb52ee3a3d13
1 # -*- makefile -*-
3 # Rules for building unit tests.
4 #
5 # Includers of this file must define the following values:
7 # ASSEMBLY
8 # ASSEMBLY_EXT
9 # the_assembly
11 tests_CLEAN_FILES :=
13 ifndef TEST_COMPILE
14 TEST_COMPILE = $(subst $(test_remove),,$(CSCOMPILE))
15 endif
17 TEST_RUNTIME_WRAPPERS_PATH = $(shell dirname $(RUNTIME))/_tmpinst/bin
19 ## Unit test support
20 ifndef NO_TEST
21 test_nunit_lib = nunit.framework.dll nunit.core.dll nunit.util.dll nunit.mocks.dll
22 test_nunit_dep = $(test_nunit_lib:%=$(topdir)/class/lib/$(PROFILE)/%)
23 test_nunit_ref = $(test_nunit_dep:%=-r:%)
24 tests_CLEAN_FILES += TestResult*.xml
26 test_lib = $(ASSEMBLY:$(ASSEMBLY_EXT)=_test_$(PROFILE).dll)
27 test_sourcefile = $(ASSEMBLY:$(ASSEMBLY_EXT)=_test.dll.sources)
28 test_pdb = $(test_lib:.dll=.pdb)
29 test_response = $(depsdir)/$(test_lib).response
30 test_makefrag = $(depsdir)/$(test_lib).makefrag
31 test_flags = -r:$(the_assembly) $(test_nunit_ref) $(TEST_MCS_FLAGS)
32 tests_CLEAN_FILES += $(ASSEMBLY:$(ASSEMBLY_EXT)=_test*.dll) $(ASSEMBLY:$(ASSEMBLY_EXT)=_test*.pdb) $(test_response) $(test_makefrag)
34 ifndef HAVE_CS_TESTS
35 HAVE_CS_TESTS := $(wildcard $(test_sourcefile))
36 endif
38 endif
40 ifndef NO_TEST
41 $(test_nunit_dep): $(topdir)/build/deps/nunit-$(PROFILE).stamp
42 @if test -f $@; then :; else rm -f $<; $(MAKE) $<; fi
43 $(topdir)/build/deps/nunit-$(PROFILE).stamp:
44 cd ${topdir}/nunit24 && $(MAKE)
45 echo "stamp" >$@
46 tests_CLEAN_FILES += $(topdir)/build/deps/nunit-$(PROFILE).stamp
47 endif
49 test_assemblies :=
51 ifdef HAVE_CS_TESTS
52 test_assemblies += $(test_lib)
53 endif
55 ifdef test_assemblies
56 check: run-test
57 test-local: $(test_assemblies)
58 run-test-local: run-test-lib
59 run-test-ondotnet-local: run-test-ondotnet-lib
61 TEST_HARNESS_EXCLUDES = -exclude=$(PLATFORM_TEST_HARNESS_EXCLUDES)NotWorking,ValueAdd,CAS,InetAccess
62 TEST_HARNESS_EXCLUDES_ONDOTNET = /exclude:$(PLATFORM_TEST_HARNESS_EXCLUDES)NotDotNet,CAS
64 ifdef TEST_HARNESS_VERBOSE
65 TEST_HARNESS_OUTPUT = -labels
66 TEST_HARNESS_OUTPUT_ONDOTNET = -labels
67 TEST_HARNESS_POSTPROC = :
68 TEST_HARNESS_POSTPROC_ONDOTNET = :
69 else
70 TEST_HARNESS_OUTPUT = -output=TestResult-$(PROFILE).log
71 TEST_HARNESS_OUTPUT_ONDOTNET = -output=TestResult-ondotnet-$(PROFILE).log
72 TEST_HARNESS_POSTPROC = (echo ''; cat TestResult-$(PROFILE).log) | sed '1,/^Tests run: /d'; xsltproc $(topdir)/build/nunit-summary.xsl TestResult-$(PROFILE).xml >> TestResult-$(PROFILE).log
73 TEST_HARNESS_POSTPROC_ONDOTNET = (echo ''; cat TestResult-ondotnet-$(PROFILE).log) | sed '1,/^Tests run: /d'; xsltproc $(topdir)/build/nunit-summary.xsl TestResult-ondotnet-$(PROFILE).xml >> TestResult-ondotnet-$(PROFILE).log
74 endif
76 ifdef FIXTURE
77 FIXTURE_ARG = -fixture=MonoTests.$(FIXTURE)
78 endif
80 ifdef TESTNAME
81 TESTNAME_ARG = -run=MonoTests.$(TESTNAME)
82 endif
84 ## FIXME: i18n problem in the 'sed' command below
85 run-test-lib: test-local
86 ok=:; \
87 PATH="$(TEST_RUNTIME_WRAPPERS_PATH):$(PATH)" MONO_REGISTRY_PATH="$(HOME)/.mono/registry" MONO_TESTS_IN_PROGRESS="yes" $(TEST_RUNTIME) $(RUNTIME_FLAGS) $(TEST_HARNESS) $(test_assemblies) -noshadow $(TEST_HARNESS_FLAGS) $(LOCAL_TEST_HARNESS_FLAGS) $(TEST_HARNESS_EXCLUDES) $(TEST_HARNESS_OUTPUT) -xml=TestResult-$(PROFILE).xml $(FIXTURE_ARG) $(TESTNAME_ARG)|| ok=false; \
88 $(TEST_HARNESS_POSTPROC) ; $$ok
90 ## Instructs compiler to compile to target .net execution, it can be usefull in rare cases when runtime detection is not possible
91 run-test-ondotnet-lib: LOCAL_TEST_COMPILER_ONDOTNET_FLAGS:=-d:RUN_ONDOTNET
92 run-test-ondotnet-lib: test-local
93 ok=:; \
94 $(TEST_HARNESS) $(test_assemblies) -noshadow $(TEST_HARNESS_FLAGS) $(LOCAL_TEST_HARNESS_ONDOTNET_FLAGS) $(TEST_HARNESS_EXCLUDES_ONDOTNET) $(TEST_HARNESS_OUTPUT_ONDOTNET) -xml=TestResult-ondotnet-$(PROFILE).xml $(FIXTURE_ARG) $(TESTNAME_ARG) || ok=false; \
95 $(TEST_HARNESS_POSTPROC_ONDOTNET) ; $$ok
98 endif # test_assemblies
100 TEST_FILES =
102 ifdef HAVE_CS_TESTS
103 TEST_FILES += `sed -e '/^$$/d' -e 's,^../,,' -et -e 's,^,Test/,' $(test_sourcefile)`
104 endif
106 ifdef HAVE_CS_TESTS
108 $(test_lib): $(the_assembly) $(test_response) $(test_nunit_dep)
109 $(TEST_COMPILE) $(LIBRARY_FLAGS) -target:library -out:$@ $(test_flags) $(LOCAL_TEST_COMPILER_ONDOTNET_FLAGS) @$(test_response)
111 $(test_response): $(test_sourcefile)
112 # @echo Creating $@ ...
113 @sed -e '/^$$/d' -e 's,^,Test/,' $(test_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
115 $(test_makefrag): $(test_response)
116 # @echo Creating $@ ...
117 @sed 's,^,$(test_lib): ,' $< >$@
119 -include $(test_makefrag)
121 endif