|
|
|
|
|
|
|
|
import subprocess |
|
|
import subprocess |
|
|
import sys |
|
|
import sys |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ROOT = Path(__file__).parent.parent.absolute() |
|
|
ROOT = Path(__file__).parent.parent.absolute() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
) |
|
|
) |
|
|
if res.returncode != 0: |
|
|
if res.returncode != 0: |
|
|
print('- FAILED') |
|
|
print('- FAILED') |
|
|
print(f'Test failed with exit code [{res.returncode}]:\n{res.stdout.decode()}') |
|
|
|
|
|
|
|
|
print(f'Test failed with exit code ' |
|
|
|
|
|
f'[{res.returncode}]:\n{res.stdout.decode()}') |
|
|
else: |
|
|
else: |
|
|
print('- PASSED') |
|
|
print('- PASSED') |
|
|
return res.returncode == 0 |
|
|
return res.returncode == 0 |
|
|
|
|
|
|
|
|
return ret |
|
|
return ret |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def bootstrap_self(opts: TestOptions): |
|
|
|
|
|
# Copy the exe to another location, as windows refuses to let a binary be |
|
|
|
|
|
# replaced while it is executing |
|
|
|
|
|
new_exe = ROOT / '_ddslime.bootstrap-test.exe' |
|
|
|
|
|
shutil.copy2(opts.exe, new_exe) |
|
|
|
|
|
res = subprocess.run([ |
|
|
|
|
|
str(new_exe), |
|
|
|
|
|
'build', |
|
|
|
|
|
f'-FT{opts.toolchain}', |
|
|
|
|
|
]) |
|
|
|
|
|
if res.returncode != 0: |
|
|
|
|
|
print('The bootstrap test failed!', file=sys.stderr) |
|
|
|
|
|
return False |
|
|
|
|
|
print('Bootstrap test PASSED!') |
|
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main(argv: List[str]) -> int: |
|
|
def main(argv: List[str]) -> int: |
|
|
parser = argparse.ArgumentParser() |
|
|
parser = argparse.ArgumentParser() |
|
|
parser.add_argument( |
|
|
parser.add_argument( |
|
|
|
|
|
|
|
|
help='The ddslim toolchain to use while testing', |
|
|
help='The ddslim toolchain to use while testing', |
|
|
required=True, |
|
|
required=True, |
|
|
) |
|
|
) |
|
|
|
|
|
parser.add_argument( |
|
|
|
|
|
'--skip-bootstrap-test', |
|
|
|
|
|
action='store_true', |
|
|
|
|
|
help='Skip the self-bootstrap test', |
|
|
|
|
|
) |
|
|
args = parser.parse_args(argv) |
|
|
args = parser.parse_args(argv) |
|
|
|
|
|
|
|
|
opts = TestOptions(exe=Path(args.exe).absolute(), toolchain=args.toolchain) |
|
|
opts = TestOptions(exe=Path(args.exe).absolute(), toolchain=args.toolchain) |
|
|
|
|
|
|
|
|
|
|
|
if not args.skip_bootstrap_test and not bootstrap_self(opts): |
|
|
|
|
|
return 2 |
|
|
|
|
|
|
|
|
return run_tests(opts) |
|
|
return run_tests(opts) |
|
|
|
|
|
|
|
|
|
|
|
|