Skip to content

Commit

Permalink
Use tempfile to create temp directories used during testing of CWL tr…
Browse files Browse the repository at this point in the history
…anslator
  • Loading branch information
james-strauss-uwa committed Aug 10, 2020
1 parent 54cbb7e commit 5d29079
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions daliuge-translator/test/dropmake/test_pg_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,21 +173,22 @@ def test_cwl_translate(self):
import uuid
import zipfile
import subprocess
import tempfile

output_list = []

cwl_output = "/tmp/cwloutput/"
shutil.rmtree(cwl_output, ignore_errors=True)
os.mkdir(cwl_output)
# create a temporary directory to contain files created during test
cwl_output = tempfile.mkdtemp()

# create a temporary directory to contain a clone of EAGLE_test_repo
direct = tempfile.mkdtemp()

direct = "/tmp/EAGLE_test_repo"
shutil.rmtree(direct, ignore_errors=True)
REPO = "https://github.com/ICRAR/EAGLE_test_repo"
git.Git("/tmp/").clone(REPO)
git.Git(direct).clone(REPO)

cwl_dir = os.getenv("CWL_GRAPHS", "SP-602")

graph_dir = direct + "/" + cwl_dir + "/"
graph_dir = direct + "/EAGLE_test_repo/" + cwl_dir + "/"
for subdir, dirs, files in os.walk(graph_dir):
for file in files:
f = os.path.join(subdir, file)
Expand Down Expand Up @@ -215,3 +216,9 @@ def test_cwl_translate(self):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
self.assertEqual(p.returncode, 0, b'stdout:\n' + stdout + b'\nstderr:\n' + stderr)

# delete the clone of EAGLE_test_repo
shutil.rmtree(direct, ignore_errors=True)

# delete the temporary output directory
shutil.rmtree(cwl_output, ignore_errors=True)

0 comments on commit 5d29079

Please sign in to comment.