Skip to content

Commit

Permalink
Fixes caught by testsuite on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo committed Jun 23, 2021
1 parent 5ad03a6 commit d8cc0be
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion testsuite/drivers/alr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions testsuite/drivers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import os
import platform
import shutil
import stat


# Return the entries (sorted) under a given folder, both folders and files
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions testsuite/tests/pin/conflicting-remote/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d8cc0be

Please sign in to comment.