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
20 changes: 16 additions & 4 deletions concore_cli/commands/_process_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,31 @@
import os


# Runtime files mkconcore.py copies into a node folder, one set per language.
RUNTIME_FILES = (
"concore.py",
"concoredocker.py",
"concore.hpp",
"concoredocker.hpp",
"concore.java",
"concoredocker.java",
"concore.v",
"concoredocker.v",
"concore_read.m",
)


def has_concore_markers(cwd):
"""True only if `cwd` looks like an actual concore-generated node
working directory, i.e. it contains the runtime files mkconcore.py
copies into every generated study (concore.iport/oport plus the
runtime module itself)."""
runtime module for the node's language)."""
if not cwd:
return False
try:
if not os.path.isfile(os.path.join(cwd, "concore.iport")):
return False
return os.path.isfile(os.path.join(cwd, "concore.py")) or os.path.isfile(
os.path.join(cwd, "concoredocker.py")
)
return any(os.path.isfile(os.path.join(cwd, name)) for name in RUNTIME_FILES)
except OSError:
return False

Expand Down
12 changes: 12 additions & 0 deletions tests/test_process_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import os

import pytest

from concore_cli.commands._process_match import has_concore_markers, is_concore_process


Expand All @@ -23,6 +25,16 @@ def test_true_with_docker_runtime_file(self, tmp_path):
(tmp_path / "concoredocker.py").write_text("")
assert has_concore_markers(str(tmp_path)) is True

@pytest.mark.parametrize(
"runtime_file",
["concore.hpp", "concore.java", "concore.v", "concore_read.m"],
)
def test_true_for_non_python_nodes(self, tmp_path, runtime_file):
# C++, Java, Verilog and MATLAB nodes never get concore.py
(tmp_path / "concore.iport").write_text("{}")
(tmp_path / runtime_file).write_text("")
assert has_concore_markers(str(tmp_path)) is True

def test_false_without_iport(self, tmp_path):
(tmp_path / "concore.py").write_text("")
assert has_concore_markers(str(tmp_path)) is False
Expand Down
Loading