From af11b1d2e82e258a43c056a0367710fc930b4109 Mon Sep 17 00:00:00 2001 From: Titas-Ghosh Date: Thu, 12 Feb 2026 02:47:42 +0530 Subject: [PATCH] Fix default execution type in CLI and add test for run command --- concore_cli/cli.py | 4 +++- tests/test_cli.py | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/concore_cli/cli.py b/concore_cli/cli.py index 49c78cb..6e9ed07 100644 --- a/concore_cli/cli.py +++ b/concore_cli/cli.py @@ -1,5 +1,6 @@ import click from rich.console import Console +import os import sys from .commands.init import init_project @@ -10,6 +11,7 @@ from .commands.inspect import inspect_workflow console = Console() +DEFAULT_EXEC_TYPE = 'windows' if os.name == 'nt' else 'posix' @click.group() @click.version_option(version='1.0.0', prog_name='concore') @@ -31,7 +33,7 @@ def init(name, template): @click.argument('workflow_file', type=click.Path(exists=True)) @click.option('--source', '-s', default='src', help='Source directory') @click.option('--output', '-o', default='out', help='Output directory') -@click.option('--type', '-t', default='windows', type=click.Choice(['windows', 'posix', 'docker']), help='Execution type') +@click.option('--type', '-t', default=DEFAULT_EXEC_TYPE, type=click.Choice(['windows', 'posix', 'docker']), help='Execution type') @click.option('--auto-build', is_flag=True, help='Automatically run build after generation') def run(workflow_file, source, output, type, auto_build): """Run a concore workflow""" diff --git a/tests/test_cli.py b/tests/test_cli.py index a90cc3f..6aa7810 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,6 +1,7 @@ import unittest import tempfile import shutil +import os from pathlib import Path from click.testing import CliRunner from concore_cli.cli import cli @@ -83,6 +84,23 @@ def test_run_command_from_project_dir(self): self.assertEqual(result.exit_code, 0) self.assertTrue(Path('out/src/concore.py').exists()) + def test_run_command_default_type(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) + + result = self.runner.invoke(cli, [ + 'run', + 'test-project/workflow.graphml', + '--source', 'test-project/src', + '--output', 'out' + ]) + self.assertEqual(result.exit_code, 0) + if os.name == 'nt': + self.assertTrue(Path('out/build.bat').exists()) + else: + self.assertTrue(Path('out/build').exists()) + def test_run_command_existing_output(self): with self.runner.isolated_filesystem(temp_dir=self.temp_dir): result = self.runner.invoke(cli, ['init', 'test-project'])