Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Pryor <jpryor@novell.com>2009-04-05 17:33:36 +0400
committerJonathan Pryor <jpryor@novell.com>2009-04-05 17:33:36 +0400
commitfe78acafcbd522e6aae88a7bcb9582a5b9d2d054 (patch)
tree61bf15b6762438546461d82ade21da3e8cbb72aa
parenta01bd7e478d0780b0c3e751ed6cce216db85e115 (diff)
* executable.make: Support HAS_NUNIT_TEST variable; if set, will build
an NUnit test assembly during 'make test' and will run the tests within the NUnit test assembly during 'make run-test'. * library.make: Split out NUnit test rules/logic into tests.make. * Makefile: Distribute tests.make. * README.makefiles: Document HAS_NUNIT_TEST for executable.make, documenting how to have NUnit tests for executables. * tests.make: Added; NUnit test logic rules. svn path=/trunk/mcs/; revision=131072
-rw-r--r--mcs/build/ChangeLog11
-rw-r--r--mcs/build/Makefile1
-rw-r--r--mcs/build/README.makefiles17
-rw-r--r--mcs/build/executable.make9
-rw-r--r--mcs/build/library.make148
-rw-r--r--mcs/build/tests.make116
6 files changed, 161 insertions, 141 deletions
diff --git a/mcs/build/ChangeLog b/mcs/build/ChangeLog
index ade954d243f..2d302742826 100644
--- a/mcs/build/ChangeLog
+++ b/mcs/build/ChangeLog
@@ -1,3 +1,14 @@
+2009-04-05 Jonathan Pryor <jpryor@novell.com>
+
+ * executable.make: Support HAS_NUNIT_TEST variable; if set, will build
+ an NUnit test assembly during 'make test' and will run the tests
+ within the NUnit test assembly during 'make run-test'.
+ * library.make: Split out NUnit test rules/logic into tests.make.
+ * Makefile: Distribute tests.make.
+ * README.makefiles: Document HAS_NUNIT_TEST for executable.make,
+ documenting how to have NUnit tests for executables.
+ * tests.make: Added; NUnit test logic rules.
+
2009-01-08 Geoff Norton <gnorton@novell.com>
* Makefile: Add darwin.make to the make dist target as well
diff --git a/mcs/build/Makefile b/mcs/build/Makefile
index ac5e8012442..3f6a89897f3 100644
--- a/mcs/build/Makefile
+++ b/mcs/build/Makefile
@@ -43,6 +43,7 @@ DISTFILES = \
library.make \
nunit-summary.xsl \
rules.make \
+ tests.make \
$(COMMON_SRCS:%=common/%) \
$(PLATFORMS:%=platforms/%.make) $(PROFILES:%=profiles/%.make)
diff --git a/mcs/build/README.makefiles b/mcs/build/README.makefiles
index 610468d5cdf..1e1ace7d7b1 100644
--- a/mcs/build/README.makefiles
+++ b/mcs/build/README.makefiles
@@ -266,6 +266,23 @@ mytester.exe: mytester.cs
$(CSCOMPILE) /target:exe /out:$@ mytester.cs
========================================
+If your program has NUnit tests, set the variable HAS_NUNIT_TEST:
+
+========================================
+PROGRAM = myprogram.exe
+LOCAL_MCS_FLAGS = /r:System.Xml.dll
+HAS_NUNIT_TEST = yes
+include ../build/executable.make
+========================================
+
+HAS_NUNIT_TEST tests follow library.make NUnit test conventions:
+the files should be in a subdirectory called Test/, and if
+your program is called myprogram.exe, they should be listed in
+myprogram_test.dll.sources. The names in that files should *not* have
+the Test/ prefix. 'make test' will build myprogram_test_$(PROFILE).dll
+in the current directory, automatically supplying the flags to
+reference the original program and NUnit.Framework.dll.
+
If your program has 'built sources', that is, source files generated
from other files (say, generated by jay), define a variable called
BUILT_SOURCES and do *not* list the sources in $(PROGRAM).sources:
diff --git a/mcs/build/executable.make b/mcs/build/executable.make
index 7e94162b0a1..61d8d2a886e 100644
--- a/mcs/build/executable.make
+++ b/mcs/build/executable.make
@@ -61,7 +61,7 @@ uninstall-local:
endif
clean-local:
- -rm -f $(executable_CLEAN_FILES) $(CLEAN_FILES)
+ -rm -f $(executable_CLEAN_FILES) $(CLEAN_FILES) $(tests_CLEAN_FILES)
test-local:
@:
@@ -124,3 +124,10 @@ $(makefrag): $(topdir)/build/executable.make $(depsdir)/.stamp
doc-update-local:
@:
+ifdef HAS_NUNIT_TEST
+ASSEMBLY = $(PROGRAM)
+ASSEMBLY_EXT = .exe
+the_assembly = $(PROGRAM)
+include $(topdir)/build/tests.make
+endif
+
diff --git a/mcs/build/library.make b/mcs/build/library.make
index f385b972843..9ec8a25a35b 100644
--- a/mcs/build/library.make
+++ b/mcs/build/library.make
@@ -59,37 +59,6 @@ else
build_lib = $(the_lib)
endif
-ifndef NO_TEST
-test_nunit_lib = nunit.framework.dll nunit.core.dll nunit.util.dll
-test_nunit_dep = $(test_nunit_lib:%=$(topdir)/class/lib/$(PROFILE)/%)
-test_nunit_ref = $(test_nunit_dep:%=-r:%)
-library_CLEAN_FILES += TestResult*.xml
-
-test_lib = $(LIBRARY:.dll=_test_$(PROFILE).dll)
-test_sourcefile = $(LIBRARY:.dll=_test.dll.sources)
-test_pdb = $(test_lib:.dll=.pdb)
-test_response = $(depsdir)/$(test_lib).response
-test_makefrag = $(depsdir)/$(test_lib).makefrag
-test_flags = -r:$(the_lib) $(test_nunit_ref) $(TEST_MCS_FLAGS)
-library_CLEAN_FILES += $(LIBRARY:.dll=_test*.dll) $(LIBRARY:.dll=_test*.pdb) $(test_response) $(test_makefrag)
-
-btest_lib = $(LIBRARY:.dll=_btest_$(PROFILE).dll)
-btest_sourcefile = $(LIBRARY:.dll=_btest.dll.sources)
-btest_pdb = $(btest_lib:.dll=.pdb)
-btest_response = $(depsdir)/$(btest_lib).response
-btest_makefrag = $(depsdir)/$(btest_lib).makefrag
-btest_flags = -r:$(the_lib) $(test_nunit_ref) $(TEST_MBAS_FLAGS)
-library_CLEAN_FILES += $(LIBRARY:.dll=_btest*.dll) $(LIBRARY:.dll=_btest*.pdb) $(btest_response) $(btest_makefrag)
-
-ifndef HAVE_CS_TESTS
-HAVE_CS_TESTS := $(wildcard $(test_sourcefile))
-endif
-ifndef HAVE_VB_TESTS
-HAVE_VB_TESTS := $(wildcard $(btest_sourcefile))
-endif
-
-endif
-
ifdef NO_SIGN_ASSEMBLY
SN = :
else
@@ -161,85 +130,21 @@ install-local: $(gacutil)
uninstall-local: $(gacutil)
-$(GACUTIL) /u $(LIBRARY_NAME:.dll=) $(gacdir_flag) /root $(GACROOT) $(package_flag)
-endif
-endif
+endif # LIBRARY_INSTALL_DIR
+endif # NO_INSTALL
clean-local:
- -rm -f $(library_CLEAN_FILES) $(CLEAN_FILES)
+ -rm -f $(tests_CLEAN_FILES) $(library_CLEAN_FILES) $(CLEAN_FILES)
test-local run-test-local run-test-ondotnet-local:
@:
-ifndef NO_TEST
-$(test_nunit_dep): $(topdir)/build/deps/nunit-$(PROFILE).stamp
- @if test -f $@; then :; else rm -f $<; $(MAKE) $<; fi
-$(topdir)/build/deps/nunit-$(PROFILE).stamp:
- cd ${topdir}/nunit24 && $(MAKE)
- echo "stamp" >$@
-library_CLEAN_FILES += $(topdir)/build/deps/nunit-$(PROFILE).stamp
-endif
-
-test_assemblies :=
-
-ifdef HAVE_CS_TESTS
-test_assemblies += $(test_lib)
-endif
-
-ifdef HAVE_VB_TESTS
-test_assemblies += $(btest_lib)
-endif
-
-ifdef test_assemblies
-check: run-test
-test-local: $(test_assemblies)
-run-test-local: run-test-lib
-run-test-ondotnet-local: run-test-ondotnet-lib
-
-TEST_HARNESS_EXCLUDES = -exclude=$(PLATFORM_TEST_HARNESS_EXCLUDES)NotWorking,ValueAdd,CAS,InetAccess
-TEST_HARNESS_EXCLUDES_ONDOTNET = /exclude:$(PLATFORM_TEST_HARNESS_EXCLUDES)NotDotNet,CAS
-
-ifdef TEST_HARNESS_VERBOSE
-TEST_HARNESS_OUTPUT = -labels
-TEST_HARNESS_OUTPUT_ONDOTNET = -labels
-TEST_HARNESS_POSTPROC = :
-TEST_HARNESS_POSTPROC_ONDOTNET = :
-else
-TEST_HARNESS_OUTPUT = -output=TestResult-$(PROFILE).log
-TEST_HARNESS_OUTPUT_ONDOTNET = -output=TestResult-ondotnet-$(PROFILE).log
-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
-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
-endif
-
-ifdef FIXTURE
-FIXTURE_ARG = -fixture=MonoTests.$(FIXTURE)
-endif
-
-ifdef TESTNAME
-TESTNAME_ARG = -run=MonoTests.$(TESTNAME)
-endif
-
-## FIXME: i18n problem in the 'sed' command below
-run-test-lib: test-local
- ok=:; \
- 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; \
- $(TEST_HARNESS_POSTPROC) ; $$ok
-
-run-test-ondotnet-lib: test-local
- ok=:; \
- $(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; \
- $(TEST_HARNESS_POSTPROC_ONDOTNET) ; $$ok
-endif
-
DISTFILES = $(wildcard *$(LIBRARY)*.sources) $(EXTRA_DISTFILES)
-TEST_FILES =
-
ifdef HAVE_CS_TESTS
-TEST_FILES += `sed -e '/^$$/d' -e 's,^../,,' -et -e 's,^,Test/,' $(test_sourcefile)`
DISTFILES += $(test_sourcefile)
endif
ifdef HAVE_VB_TESTS
-TEST_FILES += `sed -e '/^$$/d' -e 's,^../,,' -et -e 's,^,Test/,' $(btest_sourcefile)`
DISTFILES += $(btest_sourcefile)
endif
@@ -267,14 +172,6 @@ ifndef LIBRARY_COMPILE
LIBRARY_COMPILE = $(CSCOMPILE)
endif
-ifndef TEST_COMPILE
-TEST_COMPILE = $(CSCOMPILE)
-endif
-
-ifndef BTEST_COMPILE
-BTEST_COMPILE = $(BASCOMPILE)
-endif
-
ifndef LIBRARY_SNK
LIBRARY_SNK = $(topdir)/class/mono.snk
endif
@@ -335,40 +232,6 @@ endif
# for now, don't give any /lib flags or set MONO_PATH, since we
# give a full path to the assembly.
-ifdef HAVE_CS_TESTS
-
-$(test_lib): $(the_lib) $(test_response) $(test_nunit_dep)
- $(TEST_COMPILE) -target:library -out:$@ $(test_flags) @$(test_response)
-
-$(test_response): $(test_sourcefile)
- @echo Creating $@ ...
- @sed -e '/^$$/d' -e 's,^,Test/,' $(test_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
-
-$(test_makefrag): $(test_response)
- @echo Creating $@ ...
- @sed 's,^,$(test_lib): ,' $< >$@
-
--include $(test_makefrag)
-
-endif
-
-ifdef HAVE_VB_TESTS
-
-$(btest_lib): $(the_lib) $(btest_response) $(test_nunit_dep)
- $(BTEST_COMPILE) -target:library -out:$@ $(btest_flags) @$(btest_response)
-
-$(btest_response): $(btest_sourcefile)
- @echo Creating $@ ...
- @sed -e '/^$$/d' -e 's,^,Test/,' $(btest_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
-
-$(btest_makefrag): $(btest_response)
- @echo Creating $@ ...
- @sed 's,^,$(btest_lib): ,' $< >$@
-
--include $(btest_makefrag)
-
-endif
-
## Include corcompare stuff
include $(topdir)/build/corcompare.make
@@ -396,3 +259,8 @@ $(the_libdir)/.doc-stamp: $(the_lib)
$(MDOC_UP)
@echo "doc-stamp" > $@
+ASSEMBLY = $(LIBRARY)
+ASSEMBLY_EXT = .dll
+the_assembly = $(the_lib)
+include $(topdir)/build/tests.make
+
diff --git a/mcs/build/tests.make b/mcs/build/tests.make
new file mode 100644
index 00000000000..866d07d3b61
--- /dev/null
+++ b/mcs/build/tests.make
@@ -0,0 +1,116 @@
+# -*- makefile -*-
+#
+# Rules for building unit tests.
+#
+# Includers of this file must define the following values:
+#
+# ASSEMBLY
+# ASSEMBLY_EXT
+# the_assembly
+
+tests_CLEAN_FILES :=
+
+ifndef TEST_COMPILE
+TEST_COMPILE = $(CSCOMPILE)
+endif
+
+## Unit test support
+ifndef NO_TEST
+test_nunit_lib = nunit.framework.dll nunit.core.dll nunit.util.dll
+test_nunit_dep = $(test_nunit_lib:%=$(topdir)/class/lib/$(PROFILE)/%)
+test_nunit_ref = $(test_nunit_dep:%=-r:%)
+tests_CLEAN_FILES += TestResult*.xml
+
+test_lib = $(ASSEMBLY:$(ASSEMBLY_EXT)=_test_$(PROFILE).dll)
+test_sourcefile = $(ASSEMBLY:$(ASSEMBLY_EXT)=_test.dll.sources)
+test_pdb = $(test_lib:.dll=.pdb)
+test_response = $(depsdir)/$(test_lib).response
+test_makefrag = $(depsdir)/$(test_lib).makefrag
+test_flags = -r:$(the_assembly) $(test_nunit_ref) $(TEST_MCS_FLAGS)
+tests_CLEAN_FILES += $(ASSEMBLY:$(ASSEMBLY_EXT)=_test*.dll) $(ASSEMBLY:$(ASSEMBLY_EXT)=_test*.pdb) $(test_response) $(test_makefrag)
+
+ifndef HAVE_CS_TESTS
+HAVE_CS_TESTS := $(wildcard $(test_sourcefile))
+endif
+
+endif
+
+ifndef NO_TEST
+$(test_nunit_dep): $(topdir)/build/deps/nunit-$(PROFILE).stamp
+ @if test -f $@; then :; else rm -f $<; $(MAKE) $<; fi
+$(topdir)/build/deps/nunit-$(PROFILE).stamp:
+ cd ${topdir}/nunit24 && $(MAKE)
+ echo "stamp" >$@
+tests_CLEAN_FILES += $(topdir)/build/deps/nunit-$(PROFILE).stamp
+endif
+
+test_assemblies :=
+
+ifdef HAVE_CS_TESTS
+test_assemblies += $(test_lib)
+endif
+
+ifdef test_assemblies
+check: run-test
+test-local: $(test_assemblies)
+run-test-local: run-test-lib
+run-test-ondotnet-local: run-test-ondotnet-lib
+
+TEST_HARNESS_EXCLUDES = -exclude=$(PLATFORM_TEST_HARNESS_EXCLUDES)NotWorking,ValueAdd,CAS,InetAccess
+TEST_HARNESS_EXCLUDES_ONDOTNET = /exclude:$(PLATFORM_TEST_HARNESS_EXCLUDES)NotDotNet,CAS
+
+ifdef TEST_HARNESS_VERBOSE
+TEST_HARNESS_OUTPUT = -labels
+TEST_HARNESS_OUTPUT_ONDOTNET = -labels
+TEST_HARNESS_POSTPROC = :
+TEST_HARNESS_POSTPROC_ONDOTNET = :
+else
+TEST_HARNESS_OUTPUT = -output=TestResult-$(PROFILE).log
+TEST_HARNESS_OUTPUT_ONDOTNET = -output=TestResult-ondotnet-$(PROFILE).log
+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
+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
+endif
+
+ifdef FIXTURE
+FIXTURE_ARG = -fixture=MonoTests.$(FIXTURE)
+endif
+
+ifdef TESTNAME
+TESTNAME_ARG = -run=MonoTests.$(TESTNAME)
+endif
+
+## FIXME: i18n problem in the 'sed' command below
+run-test-lib: test-local
+ ok=:; \
+ 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; \
+ $(TEST_HARNESS_POSTPROC) ; $$ok
+
+run-test-ondotnet-lib: test-local
+ ok=:; \
+ $(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; \
+ $(TEST_HARNESS_POSTPROC_ONDOTNET) ; $$ok
+endif # test_assemblies
+
+TEST_FILES =
+
+ifdef HAVE_CS_TESTS
+TEST_FILES += `sed -e '/^$$/d' -e 's,^../,,' -et -e 's,^,Test/,' $(test_sourcefile)`
+endif
+
+ifdef HAVE_CS_TESTS
+
+$(test_lib): $(the_assembly) $(test_response) $(test_nunit_dep)
+ $(TEST_COMPILE) -target:library -out:$@ $(test_flags) @$(test_response)
+
+$(test_response): $(test_sourcefile)
+ @echo Creating $@ ...
+ @sed -e '/^$$/d' -e 's,^,Test/,' $(test_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
+
+$(test_makefrag): $(test_response)
+ @echo Creating $@ ...
+ @sed 's,^,$(test_lib): ,' $< >$@
+
+-include $(test_makefrag)
+
+endif
+