Skip to content

Commit bc002a7

Browse files
author
Hugo Barrera
authored
Merge pull request pimutils#879 from pimutils/archlinux
Run tests and CI on ArchLinux image
2 parents f549b1d + 12c8609 commit bc002a7

File tree

7 files changed

+97
-40
lines changed

7 files changed

+97
-40
lines changed

.builds/archlinux.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
image: archlinux
2+
packages:
3+
- docker
4+
- docker-compose
5+
# Build dependencies:
6+
- python-pip
7+
- python-wheel
8+
# Runtime dependencies:
9+
- python-atomicwrites
10+
- python-click
11+
- python-click-log
12+
- python-click-threading
13+
- python-requests
14+
- python-requests-toolbelt
15+
# Test dependencies:
16+
- python-hypothesis
17+
- python-pytest-cov
18+
- python-pytest-localserver
19+
sources:
20+
- https://github.com/pimutils/vdirsyncer
21+
environment:
22+
BUILD: test
23+
CI: true
24+
CODECOV_TOKEN: b834a3c5-28fa-4808-9bdb-182210069c79
25+
REQUIREMENTS: release
26+
# TODO: ETESYNC_TESTS
27+
tasks:
28+
- setup: |
29+
cd vdirsyncer
30+
sudo systemctl start docker
31+
sudo python setup.py install
32+
DAV_SERVER="radicale xandikos" make -e install-servers
33+
- test: |
34+
cd vdirsyncer
35+
# Non-system python is used for packages:
36+
export PATH=$PATH:~/.local/bin/
37+
make -e ci-test
38+
DAV_SERVER=radicale make -e ci-test-storage
39+
DAV_SERVER=xandikos make -e ci-test-storage

test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
hypothesis>=5.0.0,<6.0.0
1+
hypothesis>=5.0.0,<7.0.0
22
pytest
33
pytest-cov
44
pytest-localserver

tests/storage/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
from urllib.parse import quote as urlquote
55
from urllib.parse import unquote as urlunquote
66

7-
import hypothesis.strategies as st
87
import pytest
9-
from hypothesis import given
8+
from hypothesis import settings
109

1110
from .. import assert_item_equals
1211
from .. import EVENT_TEMPLATE
@@ -299,10 +298,14 @@ def test_metadata(self, requires_metadata, s):
299298
assert rv == x
300299
assert isinstance(rv, str)
301300

302-
@given(value=st.one_of(
303-
st.none(),
304-
printable_characters_strategy
305-
))
301+
@pytest.mark.parametrize(
302+
"value",
303+
[None]
304+
+ [
305+
printable_characters_strategy.example()
306+
for _ in range(settings.get_profile(settings._current_profile).max_examples)
307+
],
308+
)
306309
def test_metadata_normalization(self, requires_metadata, s, value):
307310
x = s.get_meta('displayname')
308311
assert x == normalize_meta_value(x)

tests/system/cli/test_discover.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import json
22
from textwrap import dedent
33

4-
import hypothesis.strategies as st
5-
from hypothesis import given
4+
import pytest
65

76
from vdirsyncer import exceptions
87
from vdirsyncer.storage.base import Storage
@@ -176,7 +175,15 @@ def test_null_collection_with_named_collection(tmpdir, runner):
176175
assert 'HAHA' in bar.read()
177176

178177

179-
@given(a_requires=st.booleans(), b_requires=st.booleans())
178+
@pytest.mark.parametrize(
179+
"a_requires,b_requires",
180+
[
181+
(True, True),
182+
(True, False),
183+
(False, True),
184+
(False, False),
185+
]
186+
)
180187
def test_collection_required(a_requires, b_requires, tmpdir, runner,
181188
monkeypatch):
182189

tests/system/cli/test_sync.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
import hypothesis.strategies as st
66
import pytest
7-
from hypothesis import example
8-
from hypothesis import given
7+
from hypothesis import settings
98

109

1110
def test_simple_run(tmpdir, runner):
@@ -271,13 +270,7 @@ def get_cfg():
271270
}
272271

273272

274-
hack = 0
275-
276-
277-
# XXX: https://github.com/pimutils/vdirsyncer/issues/617
278-
@pytest.mark.skipif(sys.platform == 'darwin',
279-
reason='This test inexplicably fails')
280-
@given(collections=st.sets(
273+
collections_strategy = st.sets(
281274
st.text(
282275
st.characters(
283276
blacklist_characters=set(
@@ -290,18 +283,28 @@ def get_cfg():
290283
max_size=50
291284
),
292285
min_size=1
293-
))
294-
@example(collections=['persönlich'])
295-
@example(collections={'a', 'A'})
296-
@example(collections={'\ufffe'})
286+
)
287+
288+
289+
# XXX: https://github.com/pimutils/vdirsyncer/issues/617
290+
@pytest.mark.skipif(sys.platform == 'darwin',
291+
reason='This test inexplicably fails')
292+
@pytest.mark.parametrize(
293+
"collections",
294+
[
295+
('persönlich',),
296+
('a', 'A',),
297+
('\ufffe',),
298+
] + [
299+
collections_strategy.example()
300+
for _ in range(settings.get_profile(settings._current_profile).max_examples)
301+
]
302+
)
297303
def test_create_collections(collections, tmpdir, runner):
298304
# Hypothesis calls this tests in a way that fixtures are not reset, to tmpdir is the
299305
# same for each call.
300306
# This horrible hack creates a new subdirectory on each run, effectively giving us a
301307
# new tmpdir each run.
302-
global hack
303-
hack += 1
304-
tmpdir = tmpdir / f"sub{hack}"
305308

306309
runner.write_with_general(dedent('''
307310
[pair foobar]

tests/unit/cli/test_fetchparams.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from contextlib import contextmanager
2+
from unittest.mock import patch
3+
14
import hypothesis.strategies as st
25
import pytest
36
from hypothesis import given
@@ -17,6 +20,17 @@ def strategy(x):
1720
return calls
1821

1922

23+
@contextmanager
24+
def dummy_strategy():
25+
def strategy(x):
26+
calls.append(x)
27+
return x
28+
29+
calls = []
30+
with patch.dict(STRATEGIES, {"mystrategy": strategy}):
31+
yield calls
32+
33+
2034
@pytest.fixture
2135
def value_cache(monkeypatch):
2236
_cache = {}
@@ -45,10 +59,9 @@ def test_key_conflict(monkeypatch, mystrategy):
4559

4660

4761
@given(s=st.text(), t=st.text(min_size=1))
48-
def test_fuzzing(s, t, mystrategy):
49-
config = expand_fetch_params({
50-
f'{s}.fetch': ['mystrategy', t]
51-
})
62+
def test_fuzzing(s, t):
63+
with dummy_strategy():
64+
config = expand_fetch_params({f"{s}.fetch": ["mystrategy", t]})
5265

5366
assert config[s] == t
5467

tests/unit/sync/test_status.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
import hypothesis.strategies as st
2-
import pytest
32
from hypothesis import assume
43
from hypothesis import given
54

65
from vdirsyncer.sync.status import SqliteStatus
76

87

9-
@pytest.fixture(params=[
10-
SqliteStatus
11-
])
12-
def new_status(request):
13-
return request.param
14-
15-
168
status_dict_strategy = st.dictionaries(
179
st.text(),
1810
st.tuples(*(
@@ -26,11 +18,11 @@ def new_status(request):
2618

2719

2820
@given(status_dict=status_dict_strategy)
29-
def test_legacy_status(new_status, status_dict):
21+
def test_legacy_status(status_dict):
3022
hrefs_a = {meta_a['href'] for meta_a, meta_b in status_dict.values()}
3123
hrefs_b = {meta_b['href'] for meta_a, meta_b in status_dict.values()}
3224
assume(len(hrefs_a) == len(status_dict) == len(hrefs_b))
33-
status = new_status()
25+
status = SqliteStatus()
3426
status.load_legacy_status(status_dict)
3527
assert dict(status.to_legacy_status()) == status_dict
3628

0 commit comments

Comments
 (0)