Merge pull request #825 from mannaandpoem/dev_compatible_with_windows_path

fixbug: compatible with windows path
This commit is contained in:
geekan 2024-02-02 15:49:13 +08:00 committed by GitHub
commit 6d60d3210a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

View file

@ -93,7 +93,7 @@ class DependencyFile:
root = self._filename.parent
try:
key = Path(filename).relative_to(root)
key = Path(filename).relative_to(root).as_posix()
except ValueError:
key = filename
return set(self._dependencies.get(str(key), {}))

View file

@ -6,6 +6,7 @@
@File : test_incremental_dev.py
"""
import os
import shutil
import subprocess
import time
@ -45,6 +46,7 @@ PROJECT_NAMES = [
]
@pytest.mark.skip
def test_simple_add_calculator():
result = get_incremental_dev_result(IDEAS[0], PROJECT_NAMES[0])
log_and_check_result(result)
@ -115,10 +117,14 @@ def get_incremental_dev_result(idea, project_name, use_review=True):
if not project_path.exists():
# If the project does not exist, extract the project file
try:
# Use the tar command to extract the .zip file
subprocess.run(["tar", "-xf", f"{project_path}.zip", "-C", str(project_path.parent)], check=True)
if shutil.which("unzip"):
subprocess.run(["unzip", f"{project_path}.zip", "-d", str(project_path.parent)], check=True)
elif shutil.which("tar"):
subprocess.run(["tar", "-xf", f"{project_path}.zip", "-C", str(project_path.parent)], check=True)
logger.info(f"Extracted project {project_name} successfully.")
except FileNotFoundError as e:
raise FileNotFoundError(f"Neither 'unzip' nor 'tar' command found. Error: {e}")
except subprocess.CalledProcessError as e:
# If the extraction fails, throw an exception
raise Exception(f"Failed to extract project {project_name}. Error: {e}")
check_or_create_base_tag(project_path)