%r returns a representation of the object that is valid Python syntax.
For numbers and strings this representation is very compatible with
Unix shells, but for Windows, the quoting performed by Python will not
be compatible. For example the Windows path separator `\` will be
escaped as `\\`, which is not necessary for Windows and might make
some tests that try to match path fail.
Python 3.3 has `shlex.quote`, which was previously available as
`pipes.quote` in earlier Python versions. `pipes.quote` was indeed
used in several points of the `lit.cfg` file. For Windows, one need to
do their own quoting.
This change introduces `shell_quote` which uses `shlex.quote` or
`pipes.quote` in Unix depending on the Python version, and provides an
implementation of `shell_quote` for Windows. It replaces every usage
of `pipes.quotes` for `shell_quote`, and modifies the value of
`mcp_opt` to use `shell_quote` and not `%r`.
This should fix the test `Driver\working-directory.swift` in the
Windows Visual Studio 2017 builder.
Adds a -working-directory option which can be used to modify how
relative paths are resolved. It affects all other paths used in driver
options (controlled by a new ArgumentIsPath flag on options) as well as
the contents of output file maps and auxilliary file paths generated
implicitly by the compiler itself.
rdar://37713856