diff --git a/test/runner/utils.py b/test/runner/utils.py index 51acf3e999a88faf9f00190737d90316e7ba904a..97307ffd303e11d9c63fa57a562fe1af5c889ce5 100644 --- a/test/runner/utils.py +++ b/test/runner/utils.py @@ -20,11 +20,11 @@ def download(name, git_url, revision, target_path, show_progress=False): raise Exception(f'Downloading {url_file} file failed.') print(f"Extracting archive {archive_file}") - if path.isdir(target_path): + if path.exists(target_path): shutil.rmtree(target_path) return_code = subprocess.call( - ['unzip', '-q', '-d', target_path, archive_file]) + ['unzip', '-q', '-d', path.dirname(target_path), archive_file]) if return_code: raise Exception(f'Failed to unzip {archive_file} file') @@ -35,12 +35,12 @@ def download(name, git_url, revision, target_path, show_progress=False): def generate(name, url, revision, build_dir, test_subdir="test", show_progress=False, process_copy=None, source_path=None): dest_path = path.join(build_dir, name) makedirs(dest_path, exist_ok=True) - stamp_file = path.join(dest_path, f'{name}.stamp') + stamp_file = path.join(dest_path, f'{name}-{revision}.stamp') - if path.isfile(stamp_file): + if path.exists(stamp_file): return dest_path - temp_path = path.join(path.sep, 'tmp', name) + temp_path = path.join(path.sep, 'tmp', name, f'{name}-{revision}') if not path.exists(temp_path): download( @@ -51,7 +51,8 @@ def generate(name, url, revision, build_dir, test_subdir="test", show_progress=F show_progress ) - temp_path = path.join(temp_path, f'{name}-{revision}') + if path.exists(dest_path): + shutil.rmtree(dest_path) if process_copy is not None: process_copy( @@ -75,7 +76,8 @@ def generate(name, url, revision, build_dir, test_subdir="test", show_progress=F def copy(source_path, dest_path): try: - shutil.rmtree(dest_path) + if path.exists(dest_path): + shutil.rmtree(dest_path) shutil.copytree(source_path, dest_path) except Exception as e: print(e)