Skip to content

Commit b7402cf

Browse files
committed
Appveyor and Windows compat
1 parent a429b6b commit b7402cf

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

arca/_arca.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import hashlib
22
import json
3+
import platform
34
import re
45
from collections import defaultdict
56
from datetime import datetime
@@ -139,7 +140,22 @@ def validate_repo_url(self, repo: str):
139140
:raise ValueError: If the URL is not valid
140141
"""
141142
# that should match valid git repos
142-
if not isinstance(repo, str) or not re.match(r"^(https?|file)://[\w._\-/~]*[.git]?/?$", repo):
143+
valid = True
144+
145+
url_regex = re.compile(r"^https?://[\w._\-/~]*[.git]?/?$")
146+
147+
if not isinstance(repo, str):
148+
valid = False
149+
150+
if platform.system() == "Windows":
151+
if not url_regex.match(repo) and not re.match(r"file://(localhost)?/[a-zA-Z]:\\[\\\S|*\S]?.*", repo):
152+
valid = False
153+
154+
else:
155+
if not url_regex.match(repo) and not re.match(r"file://[\w._\-/~]*[.git]?/?$", repo):
156+
valid = False
157+
158+
if not valid:
143159
raise ValueError(f"{repo} is not a valid http[s] or file:// git repository.")
144160

145161
def repo_id(self, repo: str) -> str:

tests/common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import os
2-
2+
from pathlib import Path
33

44
if os.environ.get("TRAVIS", False):
55
BASE_DIR = "/home/travis/build/{}/test_loc".format(os.environ.get("TRAVIS_REPO_SLUG", "mikicz/arca"))
6+
elif os.environ.get("APPVEYOR", False):
7+
BASE_DIR = Path(os.environ["APPVEYOR_BUILD_FOLDER"]) / "test_loc"
68
else:
79
BASE_DIR = "/tmp/arca/test"
810

tests/conftest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import platform
12
import shutil
23
import tempfile
34
from pathlib import Path
@@ -16,7 +17,12 @@ def create_temp_repo(file) -> TempRepo:
1617
git_dir = Path(tempfile.mkdtemp())
1718
repo = Repo.init(str(git_dir))
1819

19-
return TempRepo(repo, git_dir, f"file://{git_dir}", "master", git_dir / file)
20+
file_url = f"file://{git_dir}"
21+
22+
if platform.system() == "Windows":
23+
file_url = f"file:///{git_dir}"
24+
25+
return TempRepo(repo, git_dir, file_url, "master", git_dir / file)
2026

2127

2228
@pytest.fixture()

tests/test_vagrant.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212

1313
def test_validation():
14-
if os.environ.get("TRAVIS", False):
15-
pytest.skip("Vagrant doesn't work on Travis")
14+
if os.environ.get("CI", False):
15+
pytest.skip("Vagrant doesn't work on CIs")
1616

1717
backend = VagrantBackend()
1818

@@ -54,7 +54,7 @@ def test_validation():
5454
# If you want to test that even init of the VM works, set ``destroy`` to True, it will destroy the previous one as well.
5555
# Set to ``False`` by default to bootup time and bandwidth.
5656
def test_vagrant(temp_repo_func, destroy=False):
57-
if os.environ.get("TRAVIS", False):
57+
if os.environ.get("CI", False):
5858
pytest.skip("Vagrant doesn't work on Travis")
5959

6060
backend = VagrantBackend(verbosity=2, use_registry_name="docker.io/mikicz/arca-test",

0 commit comments

Comments
 (0)