From 7ecf1c3bd76d603e32749acbe12677511acbfff1 Mon Sep 17 00:00:00 2001 From: Mateusz Masiarz Date: Mon, 29 Jan 2024 12:45:00 +0100 Subject: [PATCH] Fix running OI's ingen.sh in export (#176) * Fix running OI's ingen.sh in export * Fix typo * Bump version for release --- src/sinol_make/__init__.py | 2 +- src/sinol_make/commands/export/__init__.py | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/sinol_make/__init__.py b/src/sinol_make/__init__.py index ffd66293..ade9cd03 100644 --- a/src/sinol_make/__init__.py +++ b/src/sinol_make/__init__.py @@ -9,7 +9,7 @@ from sinol_make import util, oiejq -__version__ = "1.5.19" +__version__ = "1.5.20" def configure_parsers(): diff --git a/src/sinol_make/commands/export/__init__.py b/src/sinol_make/commands/export/__init__.py index 45e2d72f..fd882ec5 100644 --- a/src/sinol_make/commands/export/__init__.py +++ b/src/sinol_make/commands/export/__init__.py @@ -35,17 +35,22 @@ def get_generated_tests(self): if not ingen_exists(self.task_id): return [] - working_dir = paths.get_cache_path('export', 'tests') - if os.path.exists(working_dir): - shutil.rmtree(working_dir) - os.makedirs(working_dir) + temp_package = paths.get_cache_path('export', 'tests') + if os.path.exists(temp_package): + shutil.rmtree(temp_package) + os.makedirs(temp_package) + in_dir = os.path.join(temp_package, 'in') + prog_dir = os.path.join(temp_package, 'prog') + os.makedirs(in_dir) + shutil.copytree(os.path.join(os.getcwd(), 'prog'), prog_dir) ingen_path = get_ingen(self.task_id) + ingen_path = os.path.join(prog_dir, os.path.basename(ingen_path)) ingen_exe = compile_ingen(ingen_path, self.args, self.args.weak_compilation_flags) - if not run_ingen(ingen_exe, working_dir): + if not run_ingen(ingen_exe, in_dir): util.exit_with_error('Failed to run ingen.') - tests = glob.glob(os.path.join(working_dir, f'{self.task_id}*.in')) + tests = glob.glob(os.path.join(in_dir, f'{self.task_id}*.in')) return [package_util.extract_test_id(test, self.task_id) for test in tests] def copy_package_required_files(self, target_dir: str): @@ -85,7 +90,7 @@ def copy_package_required_files(self, target_dir: str): if len(tests_to_copy) > 0: print(util.warning(f'Found {len(tests_to_copy)} tests that are not generated by ingen.')) for test in tests_to_copy: - print(util.warning(f'Coping {os.path.basename(test[1])}...')) + print(util.warning(f'Copying {os.path.basename(test[1])}...')) shutil.copy(test[1], os.path.join(target_dir, test[0], os.path.basename(test[1]))) def clear_files(self, target_dir: str):