-
Notifications
You must be signed in to change notification settings - Fork 5
[TRUNK-14658] Add relative test file support #616
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
base: main
Are you sure you want to change the base?
[TRUNK-14658] Add relative test file support #616
Conversation
Adds two pieces of logic: - Falls back to checking the test case classname for a path as well - Convert relative paths to absolute paths, browsing through non-hidden folders in the repository. These two cover the ways vitest differs from every other test suite we've encountered.
Merging to
|
Okay, I have retrieved the file changes and diffs for this pull request. It seems like the main changes are related to how file paths are handled within the junit test results, specifically for vitest. Here's a summary of the changes:
Based on these changes, it seems like the pull request is primarily focused on improving the handling of file paths in JUnit XML reports, especially for test frameworks like vitest that may use relative paths or unconventional naming schemes. The addition of Given that the tests are reported as flaky, and the changes touch file path handling, it's possible that the flakiness is related to how the tests interact with the file system or how they resolve file paths. It's also possible that the To investigate further, I would suggest the following:
Without access to the test logs, it's difficult to pinpoint the exact cause of the flakiness. However, by focusing on the file path handling logic and the new test case, you should be able to narrow down the possibilities and identify the root cause. Is this helpful? Click the 👍/👎 buttons below to let us know! Icons by Icons8 |
|
This reverts commit 54ccca6.
#[test] | ||
fn validate_suboptimal_junits() { | ||
let temp_dir = tempdir().unwrap(); | ||
let temp_dir = TempDir::with_prefix("not-hidden").unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here, intentional?
use crate::junit::validator::validate; | ||
use crate::{junit::validator::validate, repo::BundleRepo}; | ||
|
||
let temp_dir = TempDir::with_prefix("not-hidden").unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here.
context/src/junit/bindings.rs
Outdated
<testsuites> | ||
<testsuite name="testsuite" time="0.002"> | ||
<testcase file="test.java" line="5" timestamp="2023-10-01T12:00:00Z" classname="test" name="test_variant_truncation1" time="0.001"> | ||
<testcase file="/test.java" line="5" timestamp="2023-10-01T12:00:00Z" classname="test" name="test_variant_truncation1" time="0.001"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will generate a new test case id for customers. We need to not have the /
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoop, these are a result of a bad regex when I reverted the absolute path logic. Fixed.
context/src/junit/parser.rs
Outdated
<testcase file="/test.java" line="5" classname="test" name="test_variant_truncation1" time="0.001"> | ||
<failure message="Test failed" type="java.lang.AssertionError"> | ||
<![CDATA[Expected: <true> but was: <false>]]> | ||
</failure> | ||
</testcase> | ||
<testcase file="test.java" name="test_variant_truncation2" time="0.001"> | ||
<testcase file="/test.java" name="test_variant_truncation2" time="0.001"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comments here, we should not be modifying the file value in these cases (as they will generate new test ids).
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #616 +/- ##
==========================================
+ Coverage 73.19% 74.06% +0.87%
==========================================
Files 69 70 +1
Lines 15690 16130 +440
==========================================
+ Hits 11484 11947 +463
+ Misses 4206 4183 -23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been thinking through this logic a bit more. I'm wondering if it would be good to store this simplified file path in a separate place. One concern I have is with accidentally generating new test IDs. Modifying file path means that we end up modifying those IDs and lose test history. If we keep the original file and instead store the simplified path separately, we can primarily use it for codeowners + visibility in the UI and it would remove that concern.
I feel like that runs counter to what our original goal was. Our original goal was to handle vitest's annoying habit of:
If we don't do the filepath work, it's really easy to mistake the classname attribute (since every other framework uses it to store, uh, class names), so we'd have to try and find a file that matches the classname. All in all, if we want to minimise the risk of changing files, I could change this logic to use the |
I should have been more explicit here. I'm not suggesting putting this in classname. I'm suggesting we store it somewhere else completely. We would keep classname, file, etc as is, but also have a new field called something like "detected_file". This would live in the internal_bin representation and would be used for display / code owners reason. |
I see, you're proposing we start by just detecting the file and putting it in a separate field, then as separate work use that to display/validate? |
Exactly. That way we have a much higher tolerance for getting this wrong. It is a "best guess" after all. |
…hat for validation. Also changes the filename logic to just check that we are getting a file with an extension when we use classname, as it's overloaded with non-file uses by other test frameworks
Adds two pieces of logic: