diff --git a/concore_cli/commands/_process_match.py b/concore_cli/commands/_process_match.py index e803eb1..f1b143e 100644 --- a/concore_cli/commands/_process_match.py +++ b/concore_cli/commands/_process_match.py @@ -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 diff --git a/tests/test_process_match.py b/tests/test_process_match.py index 9f39649..b218d19 100644 --- a/tests/test_process_match.py +++ b/tests/test_process_match.py @@ -9,6 +9,8 @@ import os +import pytest + from concore_cli.commands._process_match import has_concore_markers, is_concore_process @@ -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