2009-10-22 Mark Probst <mark.probst@gmail.com>
[mono-project/dkf.git] / mcs / build / tests.make
blob0c5cd1338ea1bf28bd92877923bcabf60e7a9c84
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 = $(CSCOMPILE)
15 endif
17 ## Unit test support
18 ifndef NO_TEST
19 test_nunit_lib = nunit.framework.dll nunit.core.dll nunit.util.dll nunit.mocks.dll
20 test_nunit_dep = $(test_nunit_lib:%=$(topdir)/class/lib/$(PROFILE)/%)
21 test_nunit_ref = $(test_nunit_dep:%=-r:%)
22 tests_CLEAN_FILES += TestResult*.xml
24 test_lib = $(ASSEMBLY:$(ASSEMBLY_EXT)=_test_$(PROFILE).dll)
25 test_sourcefile = $(ASSEMBLY:$(ASSEMBLY_EXT)=_test.dll.sources)
26 test_pdb = $(test_lib:.dll=.pdb)
27 test_response = $(depsdir)/$(test_lib).response
28 test_makefrag = $(depsdir)/$(test_lib).makefrag
29 test_flags = -r:$(the_assembly) $(test_nunit_ref) $(TEST_MCS_FLAGS)
30 tests_CLEAN_FILES += $(ASSEMBLY:$(ASSEMBLY_EXT)=_test*.dll) $(ASSEMBLY:$(ASSEMBLY_EXT)=_test*.pdb) $(test_response) $(test_makefrag)
32 ifndef HAVE_CS_TESTS
33 HAVE_CS_TESTS := $(wildcard $(test_sourcefile))
34 endif
36 endif
38 ifndef NO_TEST
39 $(test_nunit_dep): $(topdir)/build/deps/nunit-$(PROFILE).stamp
40 @if test -f $@; then :; else rm -f $<; $(MAKE) $<; fi
41 $(topdir)/build/deps/nunit-$(PROFILE).stamp:
42 cd ${topdir}/nunit24 && $(MAKE)
43 echo "stamp" >$@
44 tests_CLEAN_FILES += $(topdir)/build/deps/nunit-$(PROFILE).stamp
45 endif
47 test_assemblies :=
49 ifdef HAVE_CS_TESTS
50 test_assemblies += $(test_lib)
51 endif
53 ifdef test_assemblies
54 check: run-test
55 test-local: $(test_assemblies)
56 run-test-local: run-test-lib
57 run-test-ondotnet-local: run-test-ondotnet-lib
59 TEST_HARNESS_EXCLUDES = -exclude=$(PLATFORM_TEST_HARNESS_EXCLUDES)NotWorking,ValueAdd,CAS,InetAccess
60 TEST_HARNESS_EXCLUDES_ONDOTNET = /exclude:$(PLATFORM_TEST_HARNESS_EXCLUDES)NotDotNet,CAS
62 ifdef TEST_HARNESS_VERBOSE
63 TEST_HARNESS_OUTPUT = -labels
64 TEST_HARNESS_OUTPUT_ONDOTNET = -labels
65 TEST_HARNESS_POSTPROC = :
66 TEST_HARNESS_POSTPROC_ONDOTNET = :
67 else
68 TEST_HARNESS_OUTPUT = -output=TestResult-$(PROFILE).log
69 TEST_HARNESS_OUTPUT_ONDOTNET = -output=TestResult-ondotnet-$(PROFILE).log
70 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
71 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
72 endif
74 ifdef FIXTURE
75 FIXTURE_ARG = -fixture=MonoTests.$(FIXTURE)
76 endif
78 ifdef TESTNAME
79 TESTNAME_ARG = -run=MonoTests.$(TESTNAME)
80 endif
82 ## FIXME: i18n problem in the 'sed' command below
83 run-test-lib: test-local
84 ok=:; \
85 MONO_REGISTRY_PATH="$(HOME)/.mono/registry" $(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; \
86 $(TEST_HARNESS_POSTPROC) ; $$ok
88 run-test-ondotnet-lib: test-local
89 ok=:; \
90 $(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; \
91 $(TEST_HARNESS_POSTPROC_ONDOTNET) ; $$ok
92 endif # test_assemblies
94 TEST_FILES =
96 ifdef HAVE_CS_TESTS
97 TEST_FILES += `sed -e '/^$$/d' -e 's,^../,,' -et -e 's,^,Test/,' $(test_sourcefile)`
98 endif
100 ifdef HAVE_CS_TESTS
102 $(test_lib): $(the_assembly) $(test_response) $(test_nunit_dep)
103 $(TEST_COMPILE) -target:library -out:$@ $(test_flags) @$(test_response)
105 $(test_response): $(test_sourcefile)
106 @echo Creating $@ ...
107 @sed -e '/^$$/d' -e 's,^,Test/,' $(test_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
109 $(test_makefrag): $(test_response)
110 @echo Creating $@ ...
111 @sed 's,^,$(test_lib): ,' $< >$@
113 -include $(test_makefrag)
115 endif