From d8cc0be3390c83afe3d99f6d1043ce0cfc3366cb Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Wed, 23 Jun 2021 14:13:52 +0200 Subject: [PATCH] Fixes caught by testsuite on Windows --- testsuite/drivers/alr.py | 2 +- testsuite/drivers/helpers.py | 14 ++++++++++++++ testsuite/tests/pin/conflicting-remote/test.py | 6 +++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/testsuite/drivers/alr.py b/testsuite/drivers/alr.py index 42aca985b..1ead09c01 100644 --- a/testsuite/drivers/alr.py +++ b/testsuite/drivers/alr.py @@ -277,7 +277,7 @@ def alr_pin(crate, version="", path="", url="", commit="", branch="", elif url != "" and commit != "": pin_line = f"{crate} = {{ url = '{url}', commit = '{commit}' }}" elif url != "" and branch != "": - pin_line = f'{crate} = {{ url = "{url}", branch = "{branch}" }}' + pin_line = f"{crate} = {{ url = '{url}', branch = '{branch}' }}" elif url != "": pin_line = f"{crate} = {{ url = '{url}' }}" else: diff --git a/testsuite/drivers/helpers.py b/testsuite/drivers/helpers.py index a60c1969f..ddabc7d2b 100644 --- a/testsuite/drivers/helpers.py +++ b/testsuite/drivers/helpers.py @@ -7,6 +7,8 @@ import os import platform +import shutil +import stat # Return the entries (sorted) under a given folder, both folders and files @@ -106,6 +108,18 @@ def git_head(path="."): return head_commit.decode() +def git_blast(path): + """ + Change permissions prior to deletion, as otherwise Windows is uncapable + of removing git checkouts + """ + for dirpath, dirnames, filenames in os.walk(path): + os.chmod(dirpath, stat.S_IRWXU) + for filename in filenames: + os.chmod(os.path.join(dirpath, filename), stat.S_IRWXU) + shutil.rmtree(path) + + def init_git_repo(path): """ Initialize and commit everything inside a folder, returning the HEAD commit diff --git a/testsuite/tests/pin/conflicting-remote/test.py b/testsuite/tests/pin/conflicting-remote/test.py index 211230978..bbcf65283 100644 --- a/testsuite/tests/pin/conflicting-remote/test.py +++ b/testsuite/tests/pin/conflicting-remote/test.py @@ -4,7 +4,7 @@ from drivers.alr import run_alr, alr_pin, alr_unpin, init_local_crate from drivers.asserts import assert_eq, assert_match -from drivers.helpers import git_head, init_git_repo, touch +from drivers.helpers import git_blast, git_head, init_git_repo, touch from re import escape import os @@ -45,13 +45,13 @@ def should_work(commit="", branch=""): p = run_alr("pin") assert_match(escape("yyy file:../yyy") + ".*\n" + escape("zzz file:alire/cache/pins/zzz") + ".*" + - escape("pin__conflicting-remote/zzz"), + escape(url), p.out) # Clean up for next trial os.chdir("..") os.chdir("..") - shutil.rmtree("nest") + git_blast("nest") # In this function we will test conflicts that should be detected