Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mkconcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,8 @@ def cleanup_script_files():
else:
# FIX: Safer wildcard removal.
# Avoid quoting the wildcard itself ('path/*'). Instead cd into directory and remove contents.
fclear.write(f'cd {shlex.quote(path_part)} && rm -f *\n')
# The subshell keeps the cd from carrying over to the next edge's line.
fclear.write(f'(cd {shlex.quote(path_part)} && rm -f *)\n')
writeedges = writeedges[writeedges.find(":")+1:]
i=i+1
fclear.close()
Expand Down
44 changes: 44 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import tempfile
import shutil
import os
import subprocess
import sys
import json
from pathlib import Path
Expand Down Expand Up @@ -211,6 +212,49 @@ def test_build_command_rejects_edge_label_with_multiple_sources(self):
self.assertNotEqual(result.exit_code, 0)
self.assertIn("Edge label 'shared' has more than one source", result.output)

@unittest.skipIf(os.name == "nt", "runs the generated bash scripts")
def test_build_command_posix_clear_empties_every_edge(self):
with self.runner.isolated_filesystem(temp_dir=self.temp_dir):
Path("src").mkdir()
for name in ["a.py", "b.py"]:
Path("src", name).write_text("import concore\n")
Path("workflow.graphml").write_text(
'<graphml xmlns:y="http://www.yworks.com/xml/graphml">\n'
'<graph id="G" edgedefault="directed">\n'
'<node id="n0"><data key="d0"><y:NodeLabel>A:a.py</y:NodeLabel></data></node>\n'
'<node id="n1"><data key="d0"><y:NodeLabel>B:b.py</y:NodeLabel></data></node>\n'
'<edge source="n0" target="n1"><data key="d1"><y:EdgeLabel>y</y:EdgeLabel></data></edge>\n'
'<edge source="n1" target="n0"><data key="d1"><y:EdgeLabel>u</y:EdgeLabel></data></edge>\n'
'<edge source="n1" target="n0"><data key="d1"><y:EdgeLabel>u2</y:EdgeLabel></data></edge>\n'
"</graph>\n"
"</graphml>\n"
)

result = self.runner.invoke(
cli,
[
"build",
"workflow.graphml",
"--source",
"src",
"--output",
"out",
"--type",
"posix",
],
)
self.assertEqual(result.exit_code, 0)

out = Path("out")
subprocess.run(["./build"], cwd=out, check=True, capture_output=True)
for edge in ["y", "u", "u2"]:
(out / edge / "data").write_text("[0, 1.0]")

cleared = subprocess.run(["./clear"], cwd=out, capture_output=True)
self.assertEqual(cleared.returncode, 0, cleared.stderr)
for edge in ["y", "u", "u2"]:
self.assertEqual(list((out / edge).iterdir()), [], edge)

def test_build_command_from_project_dir(self):
with self.runner.isolated_filesystem(temp_dir=self.temp_dir):
result = self.runner.invoke(cli, ["init", "test-project"])
Expand Down
Loading