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

split fully qualified name into name + module path (reported as classname) #30

Merged
merged 1 commit into from
Jun 16, 2020
Merged

split fully qualified name into name + module path (reported as classname) #30

merged 1 commit into from
Jun 16, 2020

Conversation

MalteSchledjewski
Copy link
Contributor

GitLab apparently needs a classnameattribute.

I propose that the fully qualified name is split at the last :: into {classname}::{name}

This requires bachp/junit-report-rs#5 to be merged.

@MalteSchledjewski MalteSchledjewski marked this pull request as ready for review May 12, 2020 21:37
@MalteSchledjewski
Copy link
Contributor Author

junit-report v0.3 was released so this should build now

@johnterickson
Copy link
Owner

Sorry I missed this @MalteSchledjewski ! I am adding some more tests (#31). Once that merges, could you merge and update tests as needed? This looks like a great contribution - I just want to be extra safe :)

duration,
exec_time,
} => {
let current_test_suite = current_suite
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
let current_test_suite = current_suite
let current_suite = current_suite
.as_mut()
.expect("Test event found outside of suite!");

@@ -137,16 +149,20 @@ fn parse<T: BufRead>(
}
TestEvent::Ok { name } => {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
TestEvent::Ok { name } => {
TestEvent::Ok { name } => {
assert!(tests.remove(&name));
let (name, module_path) = split_name(&name);
*current_suite = current_suite.clone().add_testcase(
TestCase::success(&name, duration).set_classname(module_path.as_str()),
);
}
TestEvent::Failed { name, stdout } => {
assert!(tests.remove(&name));
let (name, module_path) = split_name(&name);
*current_suite = current_suite.clone().add_testcase(
TestCase::failure(&name, duration, "cargo test", &stdout)
.set_classname(module_path.as_str()),
);
}

@johnterickson johnterickson merged commit 585c64b into johnterickson:master Jun 16, 2020
@johnterickson
Copy link
Owner

meh I can just make the tweaks myself :)

Thanks for your contribution!

@MalteSchledjewski Can you try this out E2E in your scenario with:

cargo install --git ...

If that looks good, I'll push to crates.io

@MalteSchledjewski
Copy link
Contributor Author

591339a works like a charm

@johnterickson
Copy link
Owner

Thanks @MalteSchledjewski I just published:
https://crates.io/crates/cargo2junit

@darxriggs
Copy link

Could you set the classname attribute only when it is available or maybe to a default value like default?
Having only src/main.rs and src/lib.rs without further modules there is no path:: prefix in the JSON output.
This results in classname="" in the XML output which prevents navigating the test cases in Jenkins.

@johnterickson
Copy link
Owner

@darxriggs I made an issue over here: #34

Is this something you'd want to contribute? I use Azure DevOps Pipelines so I'm unable to have a fast inner loop in testing it out.

@darxriggs
Copy link

I am sorry to say that for the foreseeable future I have no plans to work on this.

Currently I am using a simple workaround by just removing the empty classname attribute from the results file like this sed -i -e 's/classname=""//' results.xml. Having it removed, Jenkins properly shows the results. This might easily be implemented as a test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants