## This is minimal MicroPython variant of run-tests script, which uses# .exp files as generated by run-tests --write-exp. It is useful to run# testsuite on systems which have neither CPython3 nor unix shell.# This script is intended to be run by the same interpreter executable# which is to be tested, so should use minimal language functionality.#import usys as sysimport uos as ostests = ["basics", "micropython", "float", "import", "io", " misc", "unicode", "extmod", "unix"]if sys.platform == "win32":MICROPYTHON = "micropython.exe"else:MICROPYTHON = "micropython"def should_skip(test):if test.startswith("native"):return Trueif test.startswith("viper"):return Truetest_count = 0passed_count = 0skip_count = 0for suite in tests:# print("Running in: %s" % suite)if sys.platform == "win32":# dir /b prints only contained filenames, one on a line# http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/dir.mspxr = os.system("dir /b %s/*.py >tests.lst" % suite)else:r = os.system("ls %s/*.py | xargs -n1 basename >tests.lst" % suite)assert r == 0with open("tests.lst") as f:testcases = f.readlines()testcases = [l[:-1] for l in testcases]assert testcases, "No tests found in dir '%s', which is implausible" % suite# print(testcases)for t in testcases:if t == "native_check.py":continueqtest = "%s/%s" % (suite, t)if should_skip(t):print("skip " + qtest)skip_count += 1continueexp = Nonetry:f = open(qtest + ".exp")exp = f.read()f.close()except OSError:passif exp is not None:# print("run " + qtest)r = os.system(MICROPYTHON + " %s >.tst.out" % qtest)if r == 0:f = open(".tst.out")out = f.read()f.close()else:out = "CRASH"if out == "SKIP\n":print("skip " + qtest)skip_count += 1else:if out == exp:print("pass " + qtest)passed_count += 1else:print("FAIL " + qtest)test_count += 1else:skip_count += 1print("%s tests performed" % test_count)print("%s tests passed" % passed_count)if test_count != passed_count:print("%s tests failed" % (test_count - passed_count))if skip_count:print("%s tests skipped" % skip_count)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。