Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable --test-result-base to be set via a colcon mixin argument #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions colcon_test_result/verb/test_result.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright 2016-2019 Dirk Thomas
# Licensed under the Apache License, Version 2.0

import argparse
from contextlib import suppress
import os
import sys
Expand All @@ -27,7 +26,6 @@ def __init__(self): # noqa: D107
def add_arguments(self, *, parser): # noqa: D102
parser.add_argument(
'--test-result-base',
type=_argparse_existing_dir,
default='build',
help='The base path for all test results (default: build)')
parser.add_argument(
Expand Down Expand Up @@ -55,6 +53,8 @@ def add_arguments(self, *, parser): # noqa: D102
help='Same as --delete without an interactive confirmation')

def main(self, *, context): # noqa: D102
_verify_dir_exists(context.args.test_result_base)

all_files = set() \
if (context.args.delete or context.args.delete_yes) else None
all_results = list(get_test_results(
Expand Down Expand Up @@ -109,11 +109,11 @@ def main(self, *, context): # noqa: D102
return 1 if summary.error_count or summary.failure_count else 0


def _argparse_existing_dir(path):
def _verify_dir_exists(path):
if not os.path.exists(path):
raise argparse.ArgumentTypeError("Path '%s' does not exist" % path)
raise RuntimeError("Path '%s' does not exist" % path)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not os.path.isdir(path):
raise argparse.ArgumentTypeError("Path '%s' is not a directory" % path)
raise RuntimeError("Path '%s' is not a directory" % path)
return path


Expand Down
1 change: 0 additions & 1 deletion test/spell_check.words
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apache
argparse
basepath
classname
colcon
Expand Down