Skip to content

Commit e2744ce

Browse files
committed
tests/run-tests.py: Autodetect if the target has unicode support.
The unicode tests are now run on all targets that enable unicode. And other unicode tests (namely `extmod/json_loads.py`) are now properly skipped if the target doesn't have unicode support. Signed-off-by: Damien George <damien@micropython.org>
1 parent 1db71f9 commit e2744ce

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

tests/feature_check/target_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
except NameError:
3434
float_prec = 0
3535

36-
print(platform, arch, thread, float_prec)
36+
print(platform, arch, thread, float_prec, len("α") == 1)

tests/run-tests.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,14 @@ def detect_test_platform(pyb, args):
301301
output = run_feature_check(pyb, args, "target_info.py")
302302
if output.endswith(b"CRASH"):
303303
raise ValueError("cannot detect platform: {}".format(output))
304-
platform, arch, thread, float_prec = str(output, "ascii").strip().split()
304+
platform, arch, thread, float_prec, unicode = str(output, "ascii").strip().split()
305305
if arch == "None":
306306
arch = None
307307
inlineasm_arch = detect_inline_asm_arch(pyb, args)
308308
if thread == "None":
309309
thread = None
310310
float_prec = int(float_prec)
311+
unicode = unicode == "True"
311312

312313
args.platform = platform
313314
args.arch = arch
@@ -316,6 +317,7 @@ def detect_test_platform(pyb, args):
316317
args.inlineasm_arch = inlineasm_arch
317318
args.thread = thread
318319
args.float_prec = float_prec
320+
args.unicode = unicode
319321

320322
print("platform={}".format(platform), end="")
321323
if arch:
@@ -326,6 +328,8 @@ def detect_test_platform(pyb, args):
326328
print(" thread={}".format(thread), end="")
327329
if float_prec:
328330
print(" float={}-bit".format(float_prec), end="")
331+
if unicode:
332+
print(" unicode", end="")
329333
print()
330334

331335

@@ -845,6 +849,9 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
845849
skip_tests.add("float/float_format_ints_doubleprec.py")
846850
skip_tests.add("float/float_parse_doubleprec.py")
847851

852+
if not args.unicode:
853+
skip_tests.add("extmod/json_loads.py") # tests loading a utf-8 character
854+
848855
if not has_complex:
849856
skip_tests.add("float/complex1.py")
850857
skip_tests.add("float/complex1_intbig.py")
@@ -870,6 +877,9 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
870877
if args.platform not in PC_PLATFORMS:
871878
skip_tests.add("basics/exception_chain.py") # warning is not printed
872879
skip_tests.add("micropython/meminfo.py") # output is very different to PC output
880+
skip_tests.add("unicode/file1.py") # requires local file access
881+
skip_tests.add("unicode/file2.py") # requires local file access
882+
skip_tests.add("unicode/file_invalid.py") # requires local file access
873883

874884
# Skip emitter-specific tests.
875885
skip_tests.update(emitter_tests_to_skip.get(args.emit, ()))
@@ -1357,6 +1367,8 @@ def main():
13571367
test_dirs += ("thread",)
13581368
if args.float_prec > 0:
13591369
test_dirs += ("float",)
1370+
if args.unicode:
1371+
test_dirs += ("unicode",)
13601372
port_specific_test_dir = "ports/{}".format(platform_to_port(args.platform))
13611373
if os.path.isdir(port_specific_test_dir):
13621374
test_dirs += (port_specific_test_dir,)
@@ -1365,7 +1377,6 @@ def main():
13651377
test_dirs += (
13661378
"import",
13671379
"io",
1368-
"unicode",
13691380
"cmdline",
13701381
)
13711382
else:

0 commit comments

Comments
 (0)