Skip to content

Commit 0ec81f3

Browse files
authored
Merge pull request #726 from common-workflow-language/more_wincompat
build on win-py36, & 32bits
2 parents d593ec1 + b85e212 commit 0ec81f3

13 files changed

+93
-61
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/wf/whale.txt test eol=lf

appveyor.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,41 @@ environment:
1414
PYTHON_VERSION: "2.7.x"
1515
PYTHON_ARCH: "64"
1616

17+
- PYTHON: "C:\\Python34"
18+
PYTHON_VERSION: "3.4.x"
19+
PYTHON_ARCH: "32"
20+
1721
- PYTHON: "C:\\Python34-x64"
1822
PYTHON_VERSION: "3.4.x"
1923
PYTHON_ARCH: "64"
2024

25+
- PYTHON: "C:\\Python35"
26+
PYTHON_VERSION: "3.5.x"
27+
PYTHON_ARCH: "32"
28+
2129
- PYTHON: "C:\\Python35-x64"
2230
PYTHON_VERSION: "3.5.x"
2331
PYTHON_ARCH: "64"
2432

33+
- PYTHON: "C:\\Python36"
34+
PYTHON_VERSION: "3.6.x"
35+
PYTHON_ARCH: "32"
36+
37+
- PYTHON: "C:\\Python36-x64"
38+
PYTHON_VERSION: "3.6.x"
39+
PYTHON_ARCH: "64"
2540

2641
install:
42+
- "%PYTHON%\\python.exe -m pip install -U wheel setuptools pip pytest mock"
2743
# Get the latest stable version of Node.js or io.js
2844
- ps: Install-Product node $env:nodejs_version
29-
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
3045

3146
build_script:
32-
- "%CMD_IN_ENV% python -m pip install -U setuptools pip"
33-
- "%CMD_IN_ENV% pip install pytest mock"
34-
- "%CMD_IN_ENV% pip install ."
47+
- "%PYTHON%\\python.exe -m pip install ."
3548

3649

3750
test_script:
38-
- "%CMD_IN_ENV% py.test --verbose -p no:cacheprovider"
51+
- "%PYTHON%\\python.exe -m pytest --verbose -p no:cacheprovider"
3952

4053
branches:
4154
only:

cwltool/utils.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# no imports from cwltool allowed
44

55
import os
6+
import platform
67
import shutil
78
import stat
89
from typing import Any, Callable, Dict, List, Text, Tuple, Union
@@ -60,15 +61,24 @@ def copytree_with_merge(src, dst, symlinks=False, ignore=None):
6061
shutil.copy2(s, d)
6162

6263

63-
# changes windowspath(only) appropriately to be passed to docker run command
64-
# as docker treat them as unix paths so convert C:\Users\foo to /C/Users/foo
6564
def docker_windows_path_adjust(path):
6665
# type: (Text) -> (Text)
66+
r"""
67+
Changes only windows paths so that the can be appropriately passed to the
68+
docker run command as as docker treats them as unix paths.
69+
70+
Example: 'C:\Users\foo to /C/Users/foo (Docker for Windows) or /c/Users/foo
71+
(Docker toolbox).
72+
"""
6773
if path is not None and onWindows():
68-
sp=path.split(':')
69-
if len(sp)==2:
70-
sp[0]=sp[0].capitalize() # Capitalizing windows Drive letters
71-
path=':'.join(sp)
74+
split = path.split(':')
75+
if len(split) == 2:
76+
if platform.win32_ver()[0] in ('7', '8'): # type: ignore
77+
split[0] = split[0].lower() # Docker toolbox uses lowecase windows Drive letters
78+
else:
79+
split[0] = split[0].capitalize()
80+
# Docker for Windows uses uppercase windows Drive letters
81+
path = ':'.join(split)
7282
path = path.replace(':', '').replace('\\', '/')
7383
return path if path[0] == '/' else '/' + path
7484
return path

tests/test_check.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
import cwltool.workflow
99
import pytest
1010
from cwltool.main import main
11-
from cwltool.utils import onWindows
1211

13-
from .util import get_data
12+
from .util import get_data, needs_docker
1413

1514

1615
class TestCheck(unittest.TestCase):
17-
@pytest.mark.skipif(onWindows(),
18-
reason="Instance of Cwltool is used, On windows that invoke a default docker Container")
16+
@needs_docker
1917
def test_output_checking(self):
2018
self.assertEquals(main([get_data('tests/wf/badout1.cwl')]), 1)
2119
self.assertEquals(main([get_data('tests/wf/badout2.cwl')]), 1)

tests/test_examples.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from io import StringIO
99

1010
from cwltool.errors import WorkflowException
11-
from cwltool.utils import onWindows
1211

1312
try:
1413
reload
@@ -25,8 +24,9 @@
2524
import cwltool.workflow
2625
import schema_salad.validate
2726
from cwltool.main import main
27+
from cwltool.utils import onWindows
2828

29-
from .util import get_data
29+
from .util import get_data, needs_docker
3030

3131
sys.argv = ['']
3232

@@ -603,9 +603,7 @@ def test_no_js_console(self):
603603
self.assertNotIn("[err] Error message", stderr)
604604

605605

606-
@pytest.mark.skipif(onWindows(),
607-
reason="Instance of cwltool is used, on Windows it invokes a default docker container"
608-
"which is not supported on AppVeyor")
606+
@needs_docker
609607
class TestCache(TestCmdLine):
610608
def test_wf_without_container(self):
611609
test_file = "hello-workflow.cwl"
@@ -614,13 +612,12 @@ def test_wf_without_container(self):
614612
self.assertIn("completed success", stderr)
615613
self.assertEquals(error_code, 0)
616614

617-
@pytest.mark.skipif(onWindows(),
618-
reason="Instance of cwltool is used, on Windows it invokes a default docker container"
619-
"which is not supported on AppVeyor")
615+
@needs_docker
620616
class TestChecksum(TestCmdLine):
621617

622618
def test_compute_checksum(self):
623-
f = cwltool.factory.Factory(compute_checksum=True, use_container=False)
619+
f = cwltool.factory.Factory(compute_checksum=True,
620+
use_container=onWindows())
624621
echo = f.make(get_data("tests/wf/cat-tool.cwl"))
625622
output = echo(file1={
626623
"class": "File",

tests/test_ext.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
import cwltool.workflow
1212
from cwltool.main import main
1313
from cwltool.utils import onWindows
14-
from .util import get_data
14+
from .util import get_data, needs_docker
1515

1616

17-
@pytest.mark.skipif(onWindows(),
18-
reason="Instance of Cwltool is used, On windows that invoke a default docker Container")
17+
@needs_docker
1918
class TestListing(unittest.TestCase):
2019
def test_missing_enable_ext(self):
2120
# Require that --enable-ext is provided.

tests/test_override.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
import pytest
99
import json
1010
from cwltool.main import main
11-
from cwltool.utils import onWindows
1211
from six import StringIO
1312

14-
from .util import get_data
13+
from .util import get_data, needs_docker
1514

1615

1716
class TestOverride(unittest.TestCase):
18-
@pytest.mark.skipif(onWindows(),
19-
reason="Instance of Cwltool is used, On windows that invoke a default docker Container")
17+
@needs_docker
2018
def test_overrides(self):
2119
sio = StringIO()
2220

tests/test_pack.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
from cwltool.load_tool import fetch_document, validate_document
1818
from cwltool.main import makeRelative, main, print_pack
1919
from cwltool.pathmapper import adjustDirObjs, adjustFileObjs
20-
from cwltool.utils import onWindows
21-
from .util import get_data
20+
from .util import get_data, needs_docker
2221

2322

2423
class TestPack(unittest.TestCase):
@@ -96,9 +95,7 @@ def _pack_idempotently(self, document):
9695
double_packed = json.loads(print_pack(document_loader, processobj, uri2, metadata))
9796
self.assertEqual(packed, double_packed)
9897

99-
@pytest.mark.skipif(onWindows(),
100-
reason="Instance of cwltool is used, on Windows it invokes a default docker container"
101-
"which is not supported on AppVeyor")
98+
@needs_docker
10299
def test_packed_workflow_execution(self):
103100
load_tool.loaders = {}
104101
test_wf = "tests/wf/count-lines1-wf.cwl"
@@ -108,7 +105,7 @@ def test_packed_workflow_execution(self):
108105
document_loader, avsc_names, processobj, metadata, uri = validate_document(
109106
document_loader, workflowobj, uri)
110107
packed = json.loads(print_pack(document_loader, processobj, uri, metadata))
111-
temp_packed_path = tempfile.mkstemp()[1]
108+
temp_packed_handle, temp_packed_path = tempfile.mkstemp()
112109
with open(temp_packed_path, 'w') as f:
113110
json.dump(packed, f)
114111
normal_output = StringIO()
@@ -120,11 +117,10 @@ def test_packed_workflow_execution(self):
120117
get_data(test_wf_job)],
121118
stdout=normal_output), 0)
122119
self.assertEquals(json.loads(packed_output.getvalue()), json.loads(normal_output.getvalue()))
120+
os.close(temp_packed_handle)
123121
os.remove(temp_packed_path)
124122

125-
@pytest.mark.skipif(onWindows(),
126-
reason="Instance of cwltool is used, on Windows it invokes a default docker container"
127-
"which is not supported on AppVeyor")
123+
@needs_docker
128124
def test_preserving_namespaces(self):
129125
test_wf = "tests/wf/formattest.cwl"
130126
test_wf_job = "tests/wf/formattest-job.json"
@@ -134,7 +130,7 @@ def test_preserving_namespaces(self):
134130
document_loader, workflowobj, uri)
135131
packed = json.loads(print_pack(document_loader, processobj, uri, metadata))
136132
assert "$namespaces" in packed
137-
temp_packed_path = tempfile.mkstemp()[1]
133+
temp_packed_handle, temp_packed_path = tempfile.mkstemp()
138134
with open(temp_packed_path, 'w') as f:
139135
json.dump(packed, f)
140136
normal_output = StringIO()
@@ -146,4 +142,5 @@ def test_preserving_namespaces(self):
146142
get_data(test_wf_job)],
147143
stdout=normal_output), 0)
148144
self.assertEquals(json.loads(packed_output.getvalue()), json.loads(normal_output.getvalue()))
145+
os.close(temp_packed_handle)
149146
os.remove(temp_packed_path)

tests/test_relax_path_checks.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import pytest
44
from tempfile import NamedTemporaryFile
55

6+
from .util import needs_docker
67
from cwltool.main import main
7-
from cwltool.utils import onWindows
88

99

1010
class ToolArgparse(unittest.TestCase):
@@ -26,8 +26,7 @@ class ToolArgparse(unittest.TestCase):
2626
baseCommand: [cat]
2727
'''
2828

29-
@pytest.mark.skipif(onWindows(),
30-
reason="Instance of Cwltool is used, On windows that invoke a default docker Container")
29+
@needs_docker
3130
def test_spaces_in_input_files(self):
3231
with NamedTemporaryFile(mode='w', delete=False) as f:
3332
f.write(self.script)

tests/test_toolargparse.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
from tempfile import NamedTemporaryFile
55

66
from cwltool.main import main
7-
from cwltool.utils import onWindows
87

9-
from .util import get_data
8+
from .util import get_data, needs_docker
109

1110
class ToolArgparse(unittest.TestCase):
1211
script = '''
@@ -66,8 +65,7 @@ class ToolArgparse(unittest.TestCase):
6665
outputs: []
6766
'''
6867

69-
@pytest.mark.skipif(onWindows(),
70-
reason="Instance of Cwltool is used, On windows that invoke a default docker Container")
68+
@needs_docker
7169
def test_help(self):
7270
with NamedTemporaryFile(mode='w', delete=False) as f:
7371
f.write(self.script)
@@ -79,8 +77,7 @@ def test_help(self):
7977
get_data('tests/echo.cwl')]), 0)
8078

8179

82-
@pytest.mark.skipif(onWindows(),
83-
reason="Instance of Cwltool is used, On windows that invoke a default docker Container")
80+
@needs_docker
8481
def test_bool(self):
8582
with NamedTemporaryFile(mode='w', delete=False) as f:
8683
f.write(self.script2)

0 commit comments

Comments
 (0)