/
julian-talay
/
libnode
Обзор
Документация
Войти
/
julian-talay
/
libnode
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
scripts/test.py
42 строки
1 KB
NoboKani
finish support node v20.9.0
20 ноя 2023, 15:17
20 ноя 2023, 15:17
07e2016
Код
Авторство
О чём код?
assert __name__ == "__main__" import sys import os import subprocess import shutil from . import config os.chdir('test') shutil.rmtree('build', ignore_errors=True) os.mkdir('build') os.chdir('build') if sys.platform == 'win32': subprocess.check_call(['cmake', '-G', 'Visual Studio 16 2019', '-A', ('Win32' if config.x86 else 'x64'), '-S', '..']) else: subprocess.check_call(['cmake', '-G', 'Unix Makefiles', '-DCMAKE_BUILD_TYPE=Release', '-S', '..']) subprocess.check_call(['cmake', '--build', '.', '--config', 'Release']) tests = [ # executable args expected_output ["process_argv", [], ["hello node", "exit code: 0"]], ["simple", ["console.log(require('http').STATUS_CODES[418])"], ["I'm a Teapot", "exit code: 0"]], ["simple", ["process.exit(12)"], ["exit code: 12"]], ["simple", ["invalid javascript"], ["napi_run_script failed", "exit code: 1"]], ] failed = False for test in tests: [exec_name, args, expected_output] = test exec_path = f'Release\\{exec_name}.exe' if sys.platform == 'win32' else f'./{exec_name}' output = subprocess.check_output([exec_path] + args).decode().strip().splitlines() if output != expected_output: print("Assertion Failed. Expected:", expected_output, "Actual:", output) failed = True if failed == False: print(exec_name + " " + " ".join(args) + " - Completed") if failed: exit(1)