Fix corefx altjit test jobs
authorBruce Forstall <brucefo@microsoft.com>
Tue, 17 Jul 2018 21:32:33 +0000 (14:32 -0700)
committerBruce Forstall <brucefo@microsoft.com>
Tue, 17 Jul 2018 23:33:10 +0000 (16:33 -0700)
Recently, the corefx build switched from using the VS installed msbuild
to using "dotnet msbuild" for doing builds. This changed the way
command-line parsing was handled.

If we continue to pass the WithoutCategories argument on the command-line,
it ends up requiring an extraordinary number of "escape" backslashes
to preserve exactly the right number of backslashes that will be passed
through to the actual invocation of msbuild. That seems complex and also
not robust to future change.

Instead, construct a response file with the simple required string,
that will be passed directly through to msbuild.

Commit migrated from https://github.com/dotnet/coreclr/commit/aa64317656921a35a4c2b0a30873f780a81ff75a

src/coreclr/tests/scripts/run-corefx-tests.py

index a45f5d6..944b8eb 100644 (file)
@@ -361,20 +361,36 @@ def main(args):
 
     # If we're doing altjit testing, then don't run any tests that don't work with altjit.
     if ci_arch is not None and (ci_arch == 'x86_arm_altjit' or ci_arch == 'x64_arm64_altjit'):
-        # The property value we need to specify is a semicolon separated list of two values,
-        # so the two values must be enclosed in double quotes. Without the quotes, msbuild
-        # thinks the item after the semicolon is a different named property. Also, the double
-        # quotes need preceeding backslashes or else run.exe (invoked from build-tests.cmd)
-        # will eat them. They need to be double backslashes so Python preserves the backslashes.
-        without_categories = '/p:WithoutCategories=\\"IgnoreForCI;XsltcExeRequired\\"'
+        # The property value we need to specify for the WithoutCategories property is a semicolon
+        # separated list of two values, so the two values must be enclosed in double quotes, namely:
+        #
+        #  /p:WithoutCategories="IgnoreForCI;XsltcExeRequired"
+        #
+        # Without the quotes, msbuild interprets the semicolon as separating two name/value pairs,
+        # which is incorrect (and causes an error).
+        #
+        # If we pass this on the command-line, it requires an extraordinary number of backslashes
+        # to prevent special Python, dotnet CLI, CMD, and other command-line processing, as the command
+        # filters through batch files, the RUN tool, dotnet CLI, and finally gets to msbuild. To avoid
+        # this, and make it simpler and hopefully more resilient to scripting changes, we create an
+        # msbuild response file with the required text and pass the response file on to msbuild.
+
+        without_categories_filename = os.path.join(fx_root, 'msbuild_commands.rsp')
+        without_categories_string = '/p:WithoutCategories="IgnoreForCI;XsltcExeRequired"'
+        with open(without_categories_filename, "w") as without_categories_file:
+            without_categories_file.write(without_categories_string)
+        without_categories = "-- @%s" % without_categories_filename
+
+        log('Response file %s contents:' % without_categories_filename)
+        log('%s' % without_categories_string)
+        log('[end response file contents]')
     else:
-        without_categories = '/p:WithoutCategories=IgnoreForCI'
+        without_categories = '-- /p:WithoutCategories=IgnoreForCI'
 
     command = ' '.join((
         command,
         config_args,
         '-SkipTests' if no_run_tests else '',
-        '--',
         without_categories
     ))