From ba810ce83d392daeaa0c69af5549d020436a5ac7 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sun, 5 Apr 2020 22:51:58 +0430 Subject: [PATCH] [tests] Replace space with colon in batch mode --- test/shaping/run-tests.py | 17 ++++++----------- util/hb-shape.cc | 7 +++++-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/test/shaping/run-tests.py b/test/shaping/run-tests.py index 71d520f6b..f4fe3f4a1 100755 --- a/test/shaping/run-tests.py +++ b/test/shaping/run-tests.py @@ -1,10 +1,11 @@ #!/usr/bin/env python3 -import sys, os, subprocess, hashlib, tempfile, shutil +import sys, os, subprocess, hashlib def cmd(command): + print (command) global process - process.stdin.write ((' '.join (command) + '\n').encode ("utf-8")) + process.stdin.write ((':'.join (command) + '\n').encode ("utf-8")) process.stdin.flush () return process.stdout.readline().decode ("utf-8").strip () @@ -97,21 +98,15 @@ for filename in args: print ('%s "%s" %s %s --unicodes %s' % (hb_shape, fontfile, ' '.join(extra_options), options, unicodes)) - # hack to support fonts with space on run-tests.py, after several other tries... - if ' ' in fontfile: - new_fontfile = os.path.join (tempfile.gettempdir (), 'tmpfile') - shutil.copyfile(fontfile, new_fontfile) - fontfile = new_fontfile - if "--font-funcs=ft" in options and not have_freetype: skips += 1 continue if "--font-funcs=ot" in options or not have_freetype: - glyphs1 = cmd ([hb_shape, "--font-funcs=ot", fontfile] + extra_options + ["--unicodes", unicodes] + options) + glyphs1 = cmd ([hb_shape, fontfile, "--font-funcs=ot"] + extra_options + ["--unicodes", unicodes] + options) else: - glyphs1 = cmd ([hb_shape, "--font-funcs=ft", fontfile] + extra_options + ["--unicodes", unicodes] + options) - glyphs2 = cmd ([hb_shape, "--font-funcs=ot", fontfile] + extra_options + ["--unicodes", unicodes] + options) + glyphs1 = cmd ([hb_shape, fontfile, "--font-funcs=ft"] + extra_options + ["--unicodes", unicodes] + options) + glyphs2 = cmd ([hb_shape, fontfile, "--font-funcs=ot"] + extra_options + ["--unicodes", unicodes] + options) if glyphs1 != glyphs2 and glyphs_expected != '*': print ("FT funcs: " + glyphs1, file=sys.stderr) diff --git a/util/hb-shape.cc b/util/hb-shape.cc index bab5cba17..78488f476 100644 --- a/util/hb-shape.cc +++ b/util/hb-shape.cc @@ -170,12 +170,15 @@ main (int argc, char **argv) argc = 0; char *p = buf, *e; args[argc++] = p; - while ((e = strchr (p, ' ')) && argc < (int) (int) ARRAY_LENGTH (args)) + unsigned start_offset = 0; + while ((e = strchr (p + start_offset, ':')) && argc < (int) ARRAY_LENGTH (args)) { *e++ = '\0'; - while (*e == ' ') + while (*e == ':') e++; args[argc++] = p = e; + /* Skip 2 first bytes on first argument if is Windows path, "C:\..." */ + start_offset = argc == 2 && p[0] != '\0' && p[0] != ':' && p[1] == ':' && (p[2] == '\\' || p[2] == '/') ? 2 : 0; } ret |= driver.main (argc, args); fflush (stdout);