Skip to content

Commit 144158d

Browse files
authored
Merge pull request #271 from Titas-Ghosh/fix-cli-default-exec-type
Fix default execution type in CLI and add test for run command
2 parents 9ecefc0 + af11b1d commit 144158d

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

concore_cli/cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import click
22
from rich.console import Console
3+
import os
34
import sys
45

56
from .commands.init import init_project
@@ -10,6 +11,7 @@
1011
from .commands.inspect import inspect_workflow
1112

1213
console = Console()
14+
DEFAULT_EXEC_TYPE = 'windows' if os.name == 'nt' else 'posix'
1315

1416
@click.group()
1517
@click.version_option(version='1.0.0', prog_name='concore')
@@ -31,7 +33,7 @@ def init(name, template):
3133
@click.argument('workflow_file', type=click.Path(exists=True))
3234
@click.option('--source', '-s', default='src', help='Source directory')
3335
@click.option('--output', '-o', default='out', help='Output directory')
34-
@click.option('--type', '-t', default='windows', type=click.Choice(['windows', 'posix', 'docker']), help='Execution type')
36+
@click.option('--type', '-t', default=DEFAULT_EXEC_TYPE, type=click.Choice(['windows', 'posix', 'docker']), help='Execution type')
3537
@click.option('--auto-build', is_flag=True, help='Automatically run build after generation')
3638
def run(workflow_file, source, output, type, auto_build):
3739
"""Run a concore workflow"""

tests/test_cli.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import unittest
22
import tempfile
33
import shutil
4+
import os
45
from pathlib import Path
56
from click.testing import CliRunner
67
from concore_cli.cli import cli
@@ -83,6 +84,23 @@ def test_run_command_from_project_dir(self):
8384
self.assertEqual(result.exit_code, 0)
8485
self.assertTrue(Path('out/src/concore.py').exists())
8586

87+
def test_run_command_default_type(self):
88+
with self.runner.isolated_filesystem(temp_dir=self.temp_dir):
89+
result = self.runner.invoke(cli, ['init', 'test-project'])
90+
self.assertEqual(result.exit_code, 0)
91+
92+
result = self.runner.invoke(cli, [
93+
'run',
94+
'test-project/workflow.graphml',
95+
'--source', 'test-project/src',
96+
'--output', 'out'
97+
])
98+
self.assertEqual(result.exit_code, 0)
99+
if os.name == 'nt':
100+
self.assertTrue(Path('out/build.bat').exists())
101+
else:
102+
self.assertTrue(Path('out/build').exists())
103+
86104
def test_run_command_existing_output(self):
87105
with self.runner.isolated_filesystem(temp_dir=self.temp_dir):
88106
result = self.runner.invoke(cli, ['init', 'test-project'])

0 commit comments

Comments
 (0)