feat: junit report directory#413
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #413 +/- ##
=======================================
Coverage 98.11% 98.11%
=======================================
Files 80 80
Lines 6471 6487 +16
=======================================
+ Hits 6349 6365 +16
Misses 122 122 ☔ View full report in Codecov by Sentry. |
sebastianpfischer
left a comment
There was a problem hiding this comment.
The coverage report is not generated correctly anymore
| # filter flags | ||
| flags = [ | ||
| o | ||
| for o in self.params |
There was a problem hiding this comment.
Please change the naming from o to param. Same for some of the other loops below, it's best to give descriptive names instead of single character names
There was a problem hiding this comment.
Ok, i will fix names
| step_report: Optional[Path] = None, | ||
| pattern_inject: Optional[str] = None, | ||
| failfast: bool = False, | ||
| junit_path: str = "reports", |
There was a problem hiding this comment.
update docstring for junit_path
There was a problem hiding this comment.
ok, i will fix it
| reports_path = project_folder / "reports" | ||
| junit_report_path = reports_path / junit_report_name | ||
| reports_path.mkdir(exist_ok=True) | ||
| report_path = Path(junit_path) |
There was a problem hiding this comment.
Somehow you broke the old behaviour.
If I run
pykiso -c .\examples\dummy.yaml --junit
the report is now created at the location where pykiso has been started. Before those files where in the
"reports" folder. I would expect that same behaviour if user dont specify any path...
Something like this
pykiso -c .\examples\dummy.yaml --junit customname.xml doesnt work at all.
pykiso --help also doesnt show the optional flag.
There was a problem hiding this comment.
ok, i fixed it
| reports_path = project_folder / "reports" | ||
| junit_report_path = reports_path / junit_report_name | ||
| reports_path.mkdir(exist_ok=True) | ||
| report_path = junit_path |
There was a problem hiding this comment.
do we need the renaming ?
Just proceed with junit_path instead of report_path
There was a problem hiding this comment.
ok, i will rename it
| @@ -0,0 +1,107 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
There was a problem hiding this comment.
Remove this folder and all its contents
There was a problem hiding this comment.
ok, i will remove it
|
@Pog3k, if you merge it before I do, please squash the PR before |
|
Sorry, I start reading the PR, I do not understand what you try to do. Could you please explain it to me? |
| junit_report_path = reports_path / junit_report_name | ||
| reports_path.mkdir(exist_ok=True) | ||
| report_path = junit_path | ||
| full_report_path = Path.cwd() / report_path |
There was a problem hiding this comment.
That would not work if I drop the location, I will get a absolute path instead
There was a problem hiding this comment.
what do you mean ?
I mean I looks weird but if report_path is an abspath Path.cwd() gets ignored...
tested on windows and linux
There was a problem hiding this comment.
Really, cool, still please comment on top, because yes, it looks really weird ^^
There was a problem hiding this comment.
Code documentation, like mention above, still missing
| and flag.is_flag | ||
| and not isinstance(flag.flag_value, bool) | ||
| ] | ||
| junit_prefixes = { |
There was a problem hiding this comment.
Could this somehow be made generic?
It feels weird to have a class named CommandWithOptionalFlagValues (very generic name) that only handles one specific flag name --junit
Co-authored-by: Sebastian Clerson <58192998+sebclrsn@users.noreply.github.com>
Co-authored-by: Sebastian Clerson <58192998+sebclrsn@users.noreply.github.com>
| class CommandWithOptionalFlagValues(click.Command): | ||
| def parse_args(self, ctx, args): | ||
| """Translate any flag `--junit=value` as flag `--junit` with changed flag_value=value""" | ||
| # filter flags | ||
| flags = [ | ||
| flag | ||
| for flag in self.params | ||
| if isinstance(flag, click.Option) | ||
| and flag.is_flag | ||
| and not isinstance(flag.flag_value, bool) | ||
| ] | ||
| junit_prefixes = { | ||
| flag_str: flag | ||
| for flag in flags | ||
| for flag_str in flag.opts | ||
| if flag_str.startswith("--junit") | ||
| } | ||
|
|
||
| for index, arg in enumerate(args): | ||
| arg = arg.split("=") | ||
| if len(arg) < 2: | ||
| continue | ||
| junit_prefixes[arg[0]].flag_value = arg[1] | ||
| args[index] = arg[0] | ||
| result_args = super(CommandWithOptionalFlagValues, self).parse_args(ctx, args) | ||
| return result_args |
There was a problem hiding this comment.
To make this generic:
| class CommandWithOptionalFlagValues(click.Command): | |
| def parse_args(self, ctx, args): | |
| """Translate any flag `--junit=value` as flag `--junit` with changed flag_value=value""" | |
| # filter flags | |
| flags = [ | |
| flag | |
| for flag in self.params | |
| if isinstance(flag, click.Option) | |
| and flag.is_flag | |
| and not isinstance(flag.flag_value, bool) | |
| ] | |
| junit_prefixes = { | |
| flag_str: flag | |
| for flag in flags | |
| for flag_str in flag.opts | |
| if flag_str.startswith("--junit") | |
| } | |
| for index, arg in enumerate(args): | |
| arg = arg.split("=") | |
| if len(arg) < 2: | |
| continue | |
| junit_prefixes[arg[0]].flag_value = arg[1] | |
| args[index] = arg[0] | |
| result_args = super(CommandWithOptionalFlagValues, self).parse_args(ctx, args) | |
| return result_args | |
| class CommandWithOptionalFlagValues(click.Command): | |
| def parse_args(self, ctx, args): | |
| """Translate any flag `--junit=value` as flag `--junit` with changed flag_value=value""" | |
| # filter flags | |
| flags = [ | |
| flag | |
| for flag in self.params | |
| if isinstance(flag, click.Option) | |
| and flag.is_flag | |
| and not isinstance(flag.flag_value, bool) | |
| ] | |
| for arg_index, arg in enumerate(args): | |
| arg = arg.split("=") | |
| if len(arg) != 2: | |
| continue | |
| arg_name, arg_value = arg | |
| for flag in flags: | |
| if arg_name in flag.opts: | |
| flag.flag_value = arg_value | |
| args[arg_index] = arg_name | |
| break | |
| result_args = super(CommandWithOptionalFlagValues, self).parse_args(ctx, args) | |
| return result_args |
Co-authored-by: Sebastian Clerson <58192998+sebclrsn@users.noreply.github.com>
Co-authored-by: Sebastian Clerson <58192998+sebclrsn@users.noreply.github.com>
sebclrsn
left a comment
There was a problem hiding this comment.
Just add an entry in the what's new that explains these changes and we're good to go, e.g.:
The ``--junit`` option can now be provided with a value, indicating the folder or file where the report should be written, e.g. ``pykiso -c my_config.yaml --junit=./reports/my_config.xml``.
This is now the preferred way of setting the JUnit reports path, and providing only ``--junit`` will progressively be deprecated in the future.
| return paths | ||
|
|
||
|
|
||
| class CommandWithOptionalFlagValues(click.Command): |
There was a problem hiding this comment.
Documentation, types missing.
Also documentation of the code too.
| junit_report_path = reports_path / junit_report_name | ||
| reports_path.mkdir(exist_ok=True) | ||
| report_path = junit_path | ||
| full_report_path = Path.cwd() / report_path |
There was a problem hiding this comment.
Code documentation, like mention above, still missing
Because, it is easier and more clear for the teams, without adding new arguments of pykiso |
sebclrsn
left a comment
There was a problem hiding this comment.
Just apply the code comments for understanding and we're good to go
Co-authored-by: Sebastian Clerson <58192998+sebclrsn@users.noreply.github.com>
Co-authored-by: Sebastian Clerson <58192998+sebclrsn@users.noreply.github.com>
Co-authored-by: Sebastian Clerson <58192998+sebclrsn@users.noreply.github.com>
Co-authored-by: Sebastian Clerson <58192998+sebclrsn@users.noreply.github.com>
No description provided.