Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
integrate the new CLI app in the Fix executable
In order to pass the behave tests, the main executable has to show the behavior provided by the CLI app
also fixed a few behave issues
  • Loading branch information
arnemertz committed Aug 1, 2021
1 parent d5ddcb4 commit e21ec4c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 16 deletions.
4 changes: 3 additions & 1 deletion behave/fix_cli.feature
@@ -1,5 +1,7 @@
Feature: Fix CLI behavior

@wip
@skip
Scenario: Show usage when called without arguments
When we call Fix without arguments
Then it prints usage information
Expand All @@ -12,7 +14,7 @@ Feature: Fix CLI behavior
And it prints a list of available commands
And terminates with exit code 0


@skip
Scenario Outline: Show error when called with an unknown argument
When we call Fix with argument list "<args>"
Then it prints "fix: '<arg1>' is not a fix command. See 'fix --help'."
Expand Down
13 changes: 4 additions & 9 deletions behave/steps/fix_cli.py
Expand Up @@ -4,11 +4,6 @@
fix_executable = '../cmake-build-debug/bin/fix'


@given(u'nothing')
def nothing(context):
pass


def _start_fix_with_args(context, args):
context.fix = pexpect.spawn(fix_executable, args=args)

Expand All @@ -31,7 +26,7 @@ def check_output(context, output):
@then(u'it prints usage information')
def check_usage(context):
usage = "usage: fix [--help] <command> [<args>]"
check_output(usage)
check_output(context, usage)


@then(u'it prints a list of available commands')
Expand All @@ -41,10 +36,10 @@ def check_commands(context):
setstatus Set the status of an issue
list List all existing issues
show Show a specific issue
"""
check_output(command_list)
""".replace("\n", "\r\n")
check_output(context, command_list)


@then(u'terminates with exit code {ec:d}')
def check_output(context, ec):
def check_exit_code(context, ec):
assert (context.fix.wait() == ec)
10 changes: 10 additions & 0 deletions build_scripts/run-behave.sh
@@ -0,0 +1,10 @@
#! /usr/bin/bash

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

pushd "${SCRIPT_DIR}/../behave" > /dev/null || exit

# run all scenarios that are not tagged @skip AND all that are tagged @wip
docker4c run behave -t ~skip,wip

popd > /dev/null || exit
1 change: 0 additions & 1 deletion cmake/Conan.cmake
Expand Up @@ -17,7 +17,6 @@ macro(run_conan)
REQUIRES
${CONAN_EXTRA_REQUIRES}
catch2/2.13.6
fmt/8.0.1
OPTIONS
${CONAN_EXTRA_OPTIONS}
BASIC_SETUP
Expand Down
5 changes: 3 additions & 2 deletions src/CMakeLists.txt
@@ -1,12 +1,13 @@
# Generic test that uses conan libs

add_subdirectory(fix_cli)

add_executable(fix main.cpp)
target_link_libraries(
fix
PRIVATE
project_options
project_warnings
CONAN_PKG::fmt
fix_cli
)

add_subdirectory(fix_cli)
9 changes: 6 additions & 3 deletions src/main.cpp
@@ -1,6 +1,9 @@
#include <fmt/format.h>
#include <iostream>

int main() {
std::cout << fmt::format("Hello, {}", "fix!");
#include "fix_cli/app.hpp"

int main(int argc, char* argv[]) {
fix::cli::app app{std::cout};
const std::vector<std::string_view> args(argv, std::next(argv, argc));
app.run(args);
}

0 comments on commit e21ec4c

Please sign in to comment.