Skip to content

Commit c86d901

Browse files
authored
Merge pull request #28 from common-workflow-language/mkdtemp-lock
Add lock around mkdtemp, which seems to be thread-unsafe.
2 parents 41567af + 2fbf7b2 commit c86d901

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

.travis.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
sudo: false
22
language: python
3-
python:
4-
- 2.7
5-
# - 3.4
6-
- 3.5
7-
# - 3.6
8-
os:
9-
- linux
3+
4+
matrix:
5+
include:
6+
- os: linux
7+
python: 2.7
8+
- os: linux
9+
python: 3.5
10+
- os: osx
11+
language: generic
12+
python: 2.7
1013

1114
install:
1215
- pip install tox-travis

cwltest/__init__.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import logging
2121
import schema_salad.ref_resolver
2222
import time
23+
import threading
2324
from concurrent.futures import ThreadPoolExecutor
2425
from typing import Any, Dict, List, Text
2526

@@ -159,7 +160,11 @@ def compare(expected, actual): # type: (Any, Any) -> None
159160
raise CompareFail(str(e))
160161

161162

163+
templock = threading.Lock()
164+
162165
def run_test(args, i, tests): # type: (argparse.Namespace, int, List[Dict[str, str]]) -> TestResult
166+
global templock
167+
163168
out = {} # type: Dict[str,Any]
164169
outdir = outstr = outerr = test_command = None
165170
duration = 0.0
@@ -182,11 +187,12 @@ def run_test(args, i, tests): # type: (argparse.Namespace, int, List[Dict[str,
182187
test_command.extend([prefix, t[test_case_name]])
183188

184189
# Add prefixes if running on MacOSX so that boot2docker writes to /Users
185-
if 'darwin' in sys.platform and args.tool == 'cwltool':
186-
outdir = tempfile.mkdtemp(prefix=os.path.abspath(os.path.curdir))
187-
test_command.extend(["--tmp-outdir-prefix={}".format(outdir), "--tmpdir-prefix={}".format(outdir)])
188-
else:
189-
outdir = tempfile.mkdtemp()
190+
with templock:
191+
if 'darwin' in sys.platform and args.tool == 'cwltool':
192+
outdir = tempfile.mkdtemp(prefix=os.path.abspath(os.path.curdir))
193+
test_command.extend(["--tmp-outdir-prefix={}".format(outdir), "--tmpdir-prefix={}".format(outdir)])
194+
else:
195+
outdir = tempfile.mkdtemp()
190196
test_command.extend(["--outdir={}".format(outdir),
191197
"--quiet",
192198
t["tool"]])

tox.ini

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
envlist = py27-lint, py27-unit, py35-mypy
44
skipsdist = True
55

6-
[tox:travis]
7-
2.7 = py27
8-
3.5 = py35-mypy
6+
[travis]
7+
os =
8+
linux: py{27,35}-{lint,unit}, py35-mypy
9+
osx: py{27}-{lint,unit}
10+
python =
11+
2.7: py27
12+
3.5: py35-mypy
913

1014
[testenv]
1115
deps = -rrequirements.txt

0 commit comments

Comments
 (0)