From 995934e3b81577a6ba9e45bf85a9aca8a4c49c64 Mon Sep 17 00:00:00 2001 From: bhuvan-somisetty Date: Sat, 17 Oct 2026 13:58:17 +0530 Subject: [PATCH] fix: skip runtime files when detecting node source in concore watch --- concore_cli/commands/watch.py | 5 ++++- tests/test_cli.py | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/concore_cli/commands/watch.py b/concore_cli/commands/watch.py index 9b20164..a834f60 100644 --- a/concore_cli/commands/watch.py +++ b/concore_cli/commands/watch.py @@ -192,12 +192,15 @@ def _read_edge_files(edge_path): return results +_RUNTIME_FILES = {"import_concore.m", "ConcoreJavaRuntimeCore.java"} + + def _detect_source(node_path): for ext in ("*.py", "*.m", "*.cpp", "*.v", "*.sh", "*.java"): matches = list(node_path.glob(ext)) for m in matches: # skip concore library copies - if m.name.startswith("concore"): + if m.name.startswith("concore") or m.name in _RUNTIME_FILES: continue return m.name return "—" diff --git a/tests/test_cli.py b/tests/test_cli.py index 70441f6..029eb6e 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -918,6 +918,21 @@ def test_watch_file_instead_of_dir_exits_nonzero(self): self.assertEqual(result.exit_code, 1) self.assertIn("is not a directory", result.output) + def test_watch_skips_runtime_files_when_detecting_source(self): + from concore_cli.commands.watch import _detect_source + + cases = { + "pidM.m": ["import_concore.m", "concore_read.m"], + "Plant.java": ["ConcoreJavaRuntimeCore.java", "concoredocker.java"], + } + for source, runtime_files in cases.items(): + with self.subTest(source=source): + node = Path(self.temp_dir) / source.split(".")[0] + node.mkdir() + for name in [source] + runtime_files: + (node / name).write_text("") + self.assertEqual(_detect_source(node), source) + if __name__ == "__main__": unittest.main()