This removes the constraint of only allowing the copy option on Cygwin systems. Now any system can configure this option.pull/174/head
parent
b2ef6d2e09
commit
574945f010
@ -0,0 +1,61 @@
|
||||
"""Test yadm.alt-copy"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'cygwin',
|
||||
[pytest.param(True, marks=pytest.mark.deprecated), False],
|
||||
ids=['cygwin', 'no-cygwin'])
|
||||
@pytest.mark.parametrize(
|
||||
'compatibility', [True, False], ids=['compat', 'no-compat'])
|
||||
@pytest.mark.parametrize(
|
||||
'setting, expect_link, pre_existing', [
|
||||
(None, True, None),
|
||||
(True, False, None),
|
||||
(False, True, None),
|
||||
(True, False, 'link'),
|
||||
(True, False, 'file'),
|
||||
],
|
||||
ids=[
|
||||
'unset',
|
||||
'true',
|
||||
'false',
|
||||
'pre-existing symlink',
|
||||
'pre-existing file',
|
||||
])
|
||||
@pytest.mark.usefixtures('ds1_copy')
|
||||
def test_alt_copy(
|
||||
runner, yadm_y, paths, tst_sys,
|
||||
setting, expect_link, pre_existing,
|
||||
compatibility, cygwin):
|
||||
"""Test yadm.alt-copy"""
|
||||
|
||||
option = 'yadm.cygwin-copy' if cygwin else 'yadm.alt-copy'
|
||||
|
||||
if setting is not None:
|
||||
os.system(' '.join(yadm_y('config', option, str(setting))))
|
||||
|
||||
if compatibility:
|
||||
expected_content = f'test_alt_copy##{tst_sys}'
|
||||
else:
|
||||
expected_content = f'test_alt_copy##os.{tst_sys}'
|
||||
|
||||
alt_path = paths.work.join('test_alt_copy')
|
||||
if pre_existing == 'symlink':
|
||||
alt_path.mklinkto(expected_content)
|
||||
elif pre_existing == 'file':
|
||||
alt_path.write('wrong content')
|
||||
|
||||
env = os.environ.copy()
|
||||
if compatibility:
|
||||
env['YADM_COMPATIBILITY'] = '1'
|
||||
|
||||
run = runner(yadm_y('alt'), env=env)
|
||||
assert run.success
|
||||
assert run.err == ''
|
||||
assert 'Linking' in run.out
|
||||
|
||||
assert alt_path.read() == expected_content
|
||||
assert alt_path.islink() == expect_link
|
@ -1,71 +0,0 @@
|
||||
"""Test yadm.cygwin_copy"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'compatibility', [True, False], ids=['compat', 'no-compat'])
|
||||
@pytest.mark.parametrize(
|
||||
'setting, is_cygwin, expect_link, pre_existing', [
|
||||
(None, False, True, None),
|
||||
(True, False, True, None),
|
||||
(False, False, True, None),
|
||||
(None, True, True, None),
|
||||
(True, True, False, None),
|
||||
(False, True, True, None),
|
||||
(True, True, False, 'link'),
|
||||
(True, True, False, 'file'),
|
||||
],
|
||||
ids=[
|
||||
'unset, non-cygwin',
|
||||
'true, non-cygwin',
|
||||
'false, non-cygwin',
|
||||
'unset, cygwin',
|
||||
'true, cygwin',
|
||||
'false, cygwin',
|
||||
'pre-existing symlink',
|
||||
'pre-existing file',
|
||||
])
|
||||
@pytest.mark.usefixtures('ds1_copy')
|
||||
def test_cygwin_copy(
|
||||
runner, yadm_y, paths, cygwin_sys, tst_sys,
|
||||
setting, is_cygwin, expect_link, pre_existing,
|
||||
compatibility):
|
||||
"""Test yadm.cygwin_copy"""
|
||||
|
||||
if setting is not None:
|
||||
os.system(' '.join(yadm_y('config', 'yadm.cygwin-copy', str(setting))))
|
||||
|
||||
if compatibility:
|
||||
expected_content = f'test_cygwin_copy##{tst_sys}'
|
||||
else:
|
||||
expected_content = f'test_cygwin_copy##os.{tst_sys}'
|
||||
|
||||
alt_path = paths.work.join('test_cygwin_copy')
|
||||
if pre_existing == 'symlink':
|
||||
alt_path.mklinkto(expected_content)
|
||||
elif pre_existing == 'file':
|
||||
alt_path.write('wrong content')
|
||||
|
||||
uname_path = paths.root.join('tmp').mkdir()
|
||||
if is_cygwin:
|
||||
uname = uname_path.join('uname')
|
||||
uname.write(f'#!/bin/sh\necho "{cygwin_sys}"\n')
|
||||
uname.chmod(0o777)
|
||||
if compatibility:
|
||||
expected_content = f'test_cygwin_copy##{cygwin_sys}'
|
||||
else:
|
||||
expected_content = f'test_cygwin_copy##os.{cygwin_sys}'
|
||||
env = os.environ.copy()
|
||||
env['PATH'] = ':'.join([str(uname_path), env['PATH']])
|
||||
if compatibility:
|
||||
env['YADM_COMPATIBILITY'] = '1'
|
||||
|
||||
run = runner(yadm_y('alt'), env=env)
|
||||
assert run.success
|
||||
assert run.err == ''
|
||||
assert 'Linking' in run.out
|
||||
|
||||
assert alt_path.read() == expected_content
|
||||
assert alt_path.islink() == expect_link
|
Loading…
Reference in new issue