[tests,runtime] A kludge to make 2.0 tests using CodeDOM work
authorMarek Habersack <grendel@twistedcode.net>
Fri, 25 Mar 2011 13:19:48 +0000 (14:19 +0100)
committerMarek Habersack <grendel@twistedcode.net>
Fri, 25 Mar 2011 13:19:48 +0000 (14:19 +0100)
When running the 2.0 test suite some assemblies will invoke mcs via
CodeDOM and the new mcs process will find the MONO_PATH variable in its
environment pointing to the net_2_0 library which will cause the runtime
to attempt to load the 2.0 corlib into 4.0 process and thus mcs will
fail. At the same time, we must not touch MONO_PATH when running outside
the test suite, thus the kludge.

mcs/build/tests.make
mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs

index 9476cc583c2442c5803ec04fb9f244f0cdcdfb2c..2b273818ac7d87205cba5b27781f0adda1ecdcbc 100644 (file)
@@ -84,7 +84,7 @@ endif
 ## FIXME: i18n problem in the 'sed' command below
 run-test-lib: test-local
        ok=:; \
-       PATH="$(TEST_RUNTIME_WRAPPERS_PATH):$(PATH)" 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; \
+       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; \
        $(TEST_HARNESS_POSTPROC) ; $$ok
 
 ## Instructs compiler to compile to target .net execution, it can be usefull in rare cases when runtime detection is not possible
index 9b5cb86a53a609450710457c6a30f2c58cfc01a9..9af828e19dd2ec8cc2393cc39f0a77a35ba47772 100644 (file)
@@ -178,11 +178,32 @@ namespace Mono.CSharp
 
                        mcsOutput = new StringCollection ();
                        mcsOutMutex = new Mutex ();
-/*
+#if !NET_4_0
+                       /*
+                        * !:. KLUDGE WARNING .:!
+                        *
+                        * When running the 2.0 test suite some assemblies will invoke mcs via
+                        * CodeDOM and the new mcs process will find the MONO_PATH variable in its
+                        * environment pointing to the net_2_0 library which will cause the runtime
+                        * to attempt to load the 2.0 corlib into 4.0 process and thus mcs will
+                        * fail. At the same time, we must not touch MONO_PATH when running outside
+                        * the test suite, thus the kludge.
+                        *
+                        * !:. KLUDGE WARNING .:!
+                        */
+                       if (Environment.GetEnvironmentVariable ("MONO_TESTS_IN_PROGRESS") != null) {
+                               string monoPath = Environment.GetEnvironmentVariable ("MONO_PATH");
+                               if (!String.IsNullOrEmpty (monoPath)) {
+                                       monoPath = monoPath.Replace ("/class/lib/net_2_0", "/class/lib/net_4_0");
+                                       mcs.StartInfo.EnvironmentVariables ["MONO_PATH"] = monoPath;
+                               }
+                       }
+#endif
+/*                    
                        string monoPath = Environment.GetEnvironmentVariable ("MONO_PATH");
-                       if (monoPath == null)
+                       if (monoPath != null)
                                monoPath = String.Empty;
-                       
+
                        string privateBinPath = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath;
                        if (privateBinPath != null && privateBinPath.Length > 0)
                                monoPath = String.Format ("{0}:{1}", privateBinPath, monoPath);