From 324bef6b700d0e117e6e5103f591a4ebeea72c14 Mon Sep 17 00:00:00 2001 From: Siddhanth Gupta Date: Wed, 4 Nov 2026 14:17:53 +0530 Subject: [PATCH 1/2] fix(mkconcore): copy concore_literal_eval.m and concore_literal_serialize.m for .m nodes concore_read.m, concore_write.m, concore_initval.m and concore_default_maxtime.m call these helpers since the wire-format change, but mkconcore never copied them into out/src, so .m nodes got empty reads. Add them to the list of copied runtime files. --- mkconcore.py | 8 ++++++++ tests/test_cli.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/mkconcore.py b/mkconcore.py index a1f44ef..a7cd94d 100644 --- a/mkconcore.py +++ b/mkconcore.py @@ -732,6 +732,14 @@ def cleanup_script_files(): with open(outdir+"/src/concore_oport.m","w") as fcopy: fcopy.write(fsource.read()) fsource.close() + fsource = open(CONCOREPATH+"/concore_literal_eval.m") + with open(outdir+"/src/concore_literal_eval.m","w") as fcopy: fcopy.write(fsource.read()) + fsource.close() + + fsource = open(CONCOREPATH+"/concore_literal_serialize.m") + with open(outdir+"/src/concore_literal_serialize.m","w") as fcopy: fcopy.write(fsource.read()) + fsource.close() + if concoretype=="docker": fsource = open(CONCOREPATH+"/import_concoredocker.m") else: diff --git a/tests/test_cli.py b/tests/test_cli.py index b95c60d..9562965 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1016,6 +1016,34 @@ def test_inspect_invalid_graphml_exits_nonzero(self): self.assertEqual(result.exit_code, 1) self.assertIn("Not a valid GraphML file", result.output) + def test_build_command_m_node_copies_literal_helpers(self): + with self.runner.isolated_filesystem(temp_dir=self.temp_dir): + result = self.runner.invoke(cli, ["init", "test-project"]) + self.assertEqual(result.exit_code, 0) + + Path("test-project/src/script.py").rename("test-project/src/script.m") + workflow_path = Path("test-project/workflow.graphml") + content = workflow_path.read_text() + workflow_path.write_text(content.replace("N1:script.py", "N1:script.m")) + + result = self.runner.invoke( + cli, + [ + "build", + "test-project/workflow.graphml", + "--source", + "test-project/src", + "--output", + "out", + "--type", + "posix", + ], + ) + self.assertEqual(result.exit_code, 0) + # concore_read.m / concore_write.m call these helpers + self.assertTrue(Path("out/src/concore_literal_eval.m").exists()) + self.assertTrue(Path("out/src/concore_literal_serialize.m").exists()) + def test_watch_file_instead_of_dir_exits_nonzero(self): with self.runner.isolated_filesystem(temp_dir=self.temp_dir): Path("notes.txt").write_text("hi") From 28afdd24154d2b121219c14edf17fac01db039ac Mon Sep 17 00:00:00 2001 From: Siddhanth Gupta Date: Sat, 14 Nov 2026 11:17:34 +0530 Subject: [PATCH 2/2] test: cover posix, windows and docker studies with MATLAB nodes Generate demo/sampleM.graphml for each target and check that both literal helpers end up in src/, that no copied runtime file (concore_*.m, import_concore.m) calls a concore_* function missing from src/, and that the build script still copies src/concore_*.m into the node folder. Refs #648 --- tests/test_mkconcore_matlab_runtime.py | 67 ++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/test_mkconcore_matlab_runtime.py diff --git a/tests/test_mkconcore_matlab_runtime.py b/tests/test_mkconcore_matlab_runtime.py new file mode 100644 index 0000000..a11d65d --- /dev/null +++ b/tests/test_mkconcore_matlab_runtime.py @@ -0,0 +1,67 @@ +import re +import subprocess +import sys +from pathlib import Path + +import pytest + +REPO = Path(__file__).resolve().parents[1] + +# The script that copies src/concore_*.m into each node folder, per target type. +BUILD_SCRIPT = {"posix": "build", "windows": "build.bat", "docker": "build"} + +# A call such as concore_literal_eval(x) in the body of a .m file. +CALL = re.compile(r"\b(concore_\w+)\s*\(") + + +@pytest.fixture(params=sorted(BUILD_SCRIPT)) +def generated_study(request, tmp_path): + """Generate demo/sampleM.graphml (MATLAB/Octave nodes) for one target type.""" + out = tmp_path / "out" + subprocess.run( + [ + sys.executable, + "mkconcore.py", + "demo/sampleM.graphml", + "demo", + str(out), + request.param, + ], + cwd=REPO, + check=True, + capture_output=True, + ) + return request.param, out + + +def _called_concore_functions(path): + body = "\n".join( + line + for line in path.read_text().splitlines() + if not line.lstrip().startswith(("%", "#")) + ) + return set(CALL.findall(body)) + + +def test_every_concore_function_called_by_a_copied_file_is_copied(generated_study): + target, out = generated_study + src = out / "src" + # concore_read.m and concore_write.m depend on these two (#648) + for helper in ("concore_literal_eval.m", "concore_literal_serialize.m"): + assert (src / helper).exists(), f"{target}: {helper} not copied into src/" + + runtime_files = sorted(src.glob("concore_*.m")) + [src / "import_concore.m"] + + missing = { + f"{path.name} calls {name}" + for path in runtime_files + for name in _called_concore_functions(path) + if not (src / f"{name}.m").exists() + } + assert not missing, f"{target}: not copied into src/: {sorted(missing)}" + + +def test_build_script_copies_all_concore_m_files_into_the_node(generated_study): + target, out = generated_study + # The wildcard is what carries every file above from src/ into the node folder. + assert "concore_*.m" in (out / BUILD_SCRIPT[target]).read_text()