quote-stress-test: offer to test quoting arguments for MSYS2 sh
It is unfortunate that we need to quote arguments differently on Windows, depending whether we build a command-line for MSYS2's `sh` or for other Windows executables. We already have a test helper to verify the latter, with this patch we can also verify the former. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
@ -67,12 +67,13 @@ static int quote_stress_test(int argc, const char **argv)
|
|||||||
* were passed in.
|
* were passed in.
|
||||||
*/
|
*/
|
||||||
char special[] = ".?*\\^_\"'`{}()[]<>@~&+:;$%"; // \t\r\n\a";
|
char special[] = ".?*\\^_\"'`{}()[]<>@~&+:;$%"; // \t\r\n\a";
|
||||||
int i, j, k, trials = 100, skip = 0;
|
int i, j, k, trials = 100, skip = 0, msys2 = 0;
|
||||||
struct strbuf out = STRBUF_INIT;
|
struct strbuf out = STRBUF_INIT;
|
||||||
struct argv_array args = ARGV_ARRAY_INIT;
|
struct argv_array args = ARGV_ARRAY_INIT;
|
||||||
struct option options[] = {
|
struct option options[] = {
|
||||||
OPT_INTEGER('n', "trials", &trials, "Number of trials"),
|
OPT_INTEGER('n', "trials", &trials, "Number of trials"),
|
||||||
OPT_INTEGER('s', "skip", &skip, "Skip <n> trials"),
|
OPT_INTEGER('s', "skip", &skip, "Skip <n> trials"),
|
||||||
|
OPT_BOOL('m', "msys2", &msys2, "Test quoting for MSYS2's sh"),
|
||||||
OPT_END()
|
OPT_END()
|
||||||
};
|
};
|
||||||
const char * const usage[] = {
|
const char * const usage[] = {
|
||||||
@ -82,12 +83,18 @@ static int quote_stress_test(int argc, const char **argv)
|
|||||||
|
|
||||||
argc = parse_options(argc, argv, NULL, options, usage, 0);
|
argc = parse_options(argc, argv, NULL, options, usage, 0);
|
||||||
|
|
||||||
|
setenv("MSYS_NO_PATHCONV", "1", 0);
|
||||||
|
|
||||||
for (i = 0; i < trials; i++) {
|
for (i = 0; i < trials; i++) {
|
||||||
struct child_process cp = CHILD_PROCESS_INIT;
|
struct child_process cp = CHILD_PROCESS_INIT;
|
||||||
size_t arg_count, arg_offset;
|
size_t arg_count, arg_offset;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
argv_array_clear(&args);
|
argv_array_clear(&args);
|
||||||
|
if (msys2)
|
||||||
|
argv_array_pushl(&args, "sh", "-c",
|
||||||
|
"printf %s\\\\0 \"$@\"", "skip", NULL);
|
||||||
|
else
|
||||||
argv_array_pushl(&args, "test-run-command",
|
argv_array_pushl(&args, "test-run-command",
|
||||||
"quote-echo", NULL);
|
"quote-echo", NULL);
|
||||||
arg_offset = args.argc;
|
arg_offset = args.argc;
|
||||||
|
|||||||
Reference in New Issue
Block a user