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

Update junit-report requirement from 0.7 to 0.8 #229

Merged
merged 8 commits into from
Sep 12, 2022
Merged
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
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ indent_size = 4
indent_style = space
indent_size = 2

[*.xml]
indent_style = space
indent_size = 2

[Makefile]
indent_style = tab
indent_size = 4
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ All user visible changes to `cucumber` crate will be documented in this file. Th

- `CARGO_MANIFEST_DIR` being detected in compile time. ([todo])

### Security updated

- `junit-report` crate to 0.8 version to fix [RUSTSEC-2022-0048]. ([#229], [#226])

[#226]: /../../issues/226
[#229]: /../../pull/229
[todo]: /../../commit/todo
[RUSTSEC-2022-0048]: https://rustsec.org/advisories/RUSTSEC-2022-0048.html



Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ serde_json = { version = "1.0.18", optional = true }
Inflector = { version = "0.11", default-features = false, optional = true }

# "output-junit" feature dependencies.
junit-report = { version = "0.7", optional = true }
junit-report = { version = "0.8", optional = true }

[dev-dependencies]
derive_more = "0.99.17"
Expand Down
12 changes: 6 additions & 6 deletions src/writer/junit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//!
//! [1]: https://llg.cubic.org/docs/junit

use std::{fmt::Debug, io, mem, path::Path, time::SystemTime};
use std::{fmt::Debug, io, mem, time::SystemTime};

use async_trait::async_trait;
use junit_report::{
Expand All @@ -23,7 +23,7 @@ use crate::{
event, parser,
writer::{
self,
basic::{coerce_error, Coloring},
basic::{coerce_error, trim_path, Coloring},
discard,
out::WritableString,
Ext as _, Verbosity,
Expand Down Expand Up @@ -116,7 +116,7 @@ where
&feat.name,
feat.path
.as_deref()
.and_then(Path::to_str)
.and_then(|p| p.to_str().map(trim_path))
.map(|path| format!(": {path}"))
.unwrap_or_default(),
))
Expand Down Expand Up @@ -225,7 +225,7 @@ impl<W: Debug, Out: io::Write> JUnit<W, Out> {
format!(
"Feature{}",
path.to_str()
.map(|p| format!(": {p}"))
.map(|p| format!(": {}", trim_path(p)))
.unwrap_or_default(),
),
"Parser Error",
Expand All @@ -236,7 +236,7 @@ impl<W: Debug, Out: io::Write> JUnit<W, Out> {
"Feature: {}{}:{}",
err.path
.as_deref()
.and_then(Path::to_str)
.and_then(|p| p.to_str().map(trim_path))
.map(|p| format!("{p}:"))
.unwrap_or_default(),
err.pos.line,
Expand Down Expand Up @@ -335,7 +335,7 @@ impl<W: Debug, Out: io::Write> JUnit<W, Out> {
sc.name,
feat.path
.as_ref()
.and_then(|p| p.to_str())
.and_then(|p| p.to_str().map(trim_path))
.map(|path| format!("{path}:"))
.unwrap_or_default(),
sc.position.line,
Expand Down
11 changes: 7 additions & 4 deletions tests/junit.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{fs, io::Read as _};

use cucumber::{given, then, when, writer, World as _};
use regex::Regex;
use regex::RegexBuilder;
use tempfile::NamedTempFile;

#[given(regex = r"(\d+) secs?")]
Expand All @@ -27,11 +27,14 @@ async fn main() {

// Required to strip out non-deterministic parts of output, so we could
// compare them well.
let non_deterministic = Regex::new(
let non_deterministic = RegexBuilder::new(
"time(stamp)?=\"[^\"]+\"\
|([^\"\\n\\s]*)[/\\\\]([A-z1-9-_]*)\\.(feature|rs)(:\\d+:\\d+)?\
|\\s?\n",
|: [^\\.\\s]*\\.(feature|rs)(:\\d+:\\d+)?\
|^\\s+\
|\\s?\\n",
)
.multi_line(true)
.build()
.unwrap();

assert_eq!(
Expand Down
40 changes: 20 additions & 20 deletions tests/junit/correct.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<testsuites>
<testsuite id="0" name="Errors" package="testsuite/Errors" tests="1" errors="0" failures="1" hostname="localhost" timestamp="2022-03-29T07:22:01.580122Z" time="0">
<testcase name="Feature: /tests/features/wait/invalid.feature" time="0">
<failure type="Parser Error" message="Failed to parse feature: Could not parse feature file: /tests/features/wait/invalid.feature" />
<testcase name="Feature: tests/features/wait/invalid.feature" time="0">
<failure type="Parser Error" message="Failed to parse feature: Could not parse feature file: tests/features/wait/invalid.feature"/>
</testcase>
</testsuite>
<testsuite id="1" name="Feature: Basic: /tests/features/wait/rule.feature" package="testsuite/Feature: Basic: /tests/features/wait/rule.feature" tests="2" errors="0" failures="1" hostname="localhost" timestamp="2022-03-29T07:22:01.574719Z" time="0.000673">
<testcase name="Scenario: 1 sec: /tests/features/wait/rule.feature:6:3" time="0">
<skipped />
<testsuite id="1" name="Feature: Basic: tests/features/wait/rule.feature" package="testsuite/Feature: Basic: tests/features/wait/rule.feature" tests="2" errors="0" failures="1" hostname="localhost" timestamp="2022-03-29T07:22:01.574719Z" time="0.000673">
<testcase name="Scenario: 1 sec: tests/features/wait/rule.feature:6:3" time="0">
<skipped/>
</testcase>
<testcase name="Rule: rule: Scenario: 2 secs: /tests/features/wait/rule.feature:14:5" time="0.000673">
<testcase name="Rule: rule: Scenario: 2 secs: tests/features/wait/rule.feature:14:5" time="0.000673">
<failure type="Step Panicked" message="Step panicked. Captured output: Too much!"><![CDATA[ Scenario: 2 secs
✔> Given 1 sec
✔ Given 2 secs
Expand All @@ -25,11 +25,11 @@
]]></failure>
</testcase>
</testsuite>
<testsuite id="2" name="Feature: Basic: /tests/features/wait/nested/rule.feature" package="testsuite/Feature: Basic: /tests/features/wait/nested/rule.feature" tests="2" errors="0" failures="1" hostname="localhost" timestamp="2022-03-29T07:22:01.576081Z" time="0.000137">
<testcase name="Scenario: 1 sec: /tests/features/wait/nested/rule.feature:6:3" time="0">
<skipped />
<testsuite id="2" name="Feature: Basic: tests/features/wait/nested/rule.feature" package="testsuite/Feature: Basic: tests/features/wait/nested/rule.feature" tests="2" errors="0" failures="1" hostname="localhost" timestamp="2022-03-29T07:22:01.576081Z" time="0.000137">
<testcase name="Scenario: 1 sec: tests/features/wait/nested/rule.feature:6:3" time="0">
<skipped/>
</testcase>
<testcase name="Rule: rule: Scenario: 2 secs: /tests/features/wait/nested/rule.feature:14:5" time="0.000137">
<testcase name="Rule: rule: Scenario: 2 secs: tests/features/wait/nested/rule.feature:14:5" time="0.000137">
<failure type="Step Panicked" message="Step panicked. Captured output: Too much!"><![CDATA[ Scenario: 2 secs
✔> Given 1 sec
✔ Given 2 secs
Expand All @@ -45,59 +45,59 @@
]]></failure>
</testcase>
</testsuite>
<testsuite id="3" name="Feature: Outline: /tests/features/wait/outline.feature" package="testsuite/Feature: Outline: /tests/features/wait/outline.feature" tests="4" errors="0" failures="0" hostname="localhost" timestamp="2022-03-29T07:22:01.576909Z" time="0.00034">
<testcase name="Scenario: wait: /tests/features/wait/outline.feature:14:5" time="0.000085">
<testsuite id="3" name="Feature: Outline: tests/features/wait/outline.feature" package="testsuite/Feature: Outline: tests/features/wait/outline.feature" tests="4" errors="0" failures="0" hostname="localhost" timestamp="2022-03-29T07:22:01.576909Z" time="0.00034">
<testcase name="Scenario: wait: tests/features/wait/outline.feature:14:5" time="0.000085">
<system-out><![CDATA[ Scenario Outline: wait
✔ Given 2 secs
✔ When 2 secs
✔ Then 2 secs
]]></system-out>
</testcase>
<testcase name="Scenario: wait: /tests/features/wait/outline.feature:15:5" time="0.000081">
<testcase name="Scenario: wait: tests/features/wait/outline.feature:15:5" time="0.000081">
<system-out><![CDATA[ Scenario Outline: wait
✔ Given 1 secs
✔ When 1 secs
✔ Then 1 secs
]]></system-out>
</testcase>
<testcase name="Scenario: wait: /tests/features/wait/outline.feature:16:5" time="0.000093">
<testcase name="Scenario: wait: tests/features/wait/outline.feature:16:5" time="0.000093">
<system-out><![CDATA[ Scenario Outline: wait
✔ Given 1 secs
✔ When 1 secs
✔ Then 1 secs
]]></system-out>
</testcase>
<testcase name="Scenario: wait: /tests/features/wait/outline.feature:21:5" time="0.000081">
<testcase name="Scenario: wait: tests/features/wait/outline.feature:21:5" time="0.000081">
<system-out><![CDATA[ Scenario Outline: wait
✔ Given 5 secs
✔ When 5 secs
✔ Then 5 secs
]]></system-out>
</testcase>
</testsuite>
<testsuite id="4" name="Feature: Rule Outline: /tests/features/wait/rule_outline.feature" package="testsuite/Feature: Rule Outline: /tests/features/wait/rule_outline.feature" tests="4" errors="0" failures="0" hostname="localhost" timestamp="2022-03-29T07:22:01.576911Z" time="0.000336">
<testcase name="Rule: To them all: Scenario: wait: /tests/features/wait/rule_outline.feature:11:7" time="0.000082">
<testsuite id="4" name="Feature: Rule Outline: tests/features/wait/rule_outline.feature" package="testsuite/Feature: Rule Outline: tests/features/wait/rule_outline.feature" tests="4" errors="0" failures="0" hostname="localhost" timestamp="2022-03-29T07:22:01.576911Z" time="0.000336">
<testcase name="Rule: To them all: Scenario: wait: tests/features/wait/rule_outline.feature:11:7" time="0.000082">
<system-out><![CDATA[ Scenario Outline: wait
✔ Given 2 secs
✔ When 2 secs
✔ Then 2 secs
]]></system-out>
</testcase>
<testcase name="Rule: To them all: Scenario: wait: /tests/features/wait/rule_outline.feature:12:7" time="0.000086">
<testcase name="Rule: To them all: Scenario: wait: tests/features/wait/rule_outline.feature:12:7" time="0.000086">
<system-out><![CDATA[ Scenario Outline: wait
✔ Given 1 secs
✔ When 1 secs
✔ Then 1 secs
]]></system-out>
</testcase>
<testcase name="Rule: To them all: Scenario: wait: /tests/features/wait/rule_outline.feature:13:7" time="0.000086">
<testcase name="Rule: To them all: Scenario: wait: tests/features/wait/rule_outline.feature:13:7" time="0.000086">
<system-out><![CDATA[ Scenario Outline: wait
✔ Given 1 secs
✔ When 1 secs
✔ Then 1 secs
]]></system-out>
</testcase>
<testcase name="Rule: To them all: Scenario: wait: /tests/features/wait/rule_outline.feature:14:7" time="0.000082">
<testcase name="Rule: To them all: Scenario: wait: tests/features/wait/rule_outline.feature:14:7" time="0.000082">
<system-out><![CDATA[ Scenario Outline: wait
✔ Given 5 secs
✔ When 5 secs
Expand Down