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 ion-tests and start cataloging conformance issues. #911

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nirosys
Copy link
Contributor

@nirosys nirosys commented Feb 19, 2025

Issue #, if available: #902

Description of changes:
This PR adds a skip list to the conformance tests run during CI/CD, while also adding all of the current conformance tests to the generated unit tests.

The skip list is implemented to skip test files, which may contain multiple tests. This was done because tests are not required to have a name, and many of them do not. This means that a test file cannot be removed from the skip list until each test within passes. I'll be tracking all of the individual tests, and can post a more detailed list, which I will also be sharing with the team shortly. The comments captured in the skip list are mostly the first error to trigger the test failure. I'll keep them updated as I work through them, but the list I'll share will be the most accurate summary of issues.

In addition the conformance CLI has been updated to catch panics and recover, so that we can run all tests within a file even if one of the tests hits a todo!, or fatal error.

The CLI has also been updated to allow a -i option, which can be specified before any files in order to output the test results in an ion format for easier processing.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

codecov bot commented Feb 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.73%. Comparing base (a7c30d4) to head (8c40712).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #911      +/-   ##
==========================================
+ Coverage   77.53%   77.73%   +0.19%     
==========================================
  Files         137      137              
  Lines       34283    34283              
  Branches    34283    34283              
==========================================
+ Hits        26583    26651      +68     
+ Misses       5717     5655      -62     
+ Partials     1983     1977       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nirosys
Copy link
Contributor Author

nirosys commented Feb 19, 2025

Unit test failures on windows due to skip-list not allowing windows separators. As much as I try to forget windows exists.. it's still there.

@nirosys nirosys marked this pull request as ready for review February 19, 2025 10:00
@nirosys nirosys requested a review from zslayton February 19, 2025 10:00
Comment on lines +61 to +63
self.name_width = collection.iter().fold(0, |acc, d| {
std::cmp::max(acc, d.name.as_ref().map_or(0, |n| n.len()))
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice 👍

/// A test reporter that renders the results of all tests to the terminal in a human readable way,
/// mimicking the output of cargo test.
#[derive(Default)]
struct PlainReporter {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe PlainTextReporter?

.collect::<Vec<String>>();
let emit_ion = Some("-i") == options.get(0).map(|v| v.as_str());

let mut reporter: Box<dyn TestReporter> = if emit_ion {
Copy link
Contributor

Choose a reason for hiding this comment

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

This may not need to be Boxed? It seems like &mut dyn might work.

let old_hook = std::panic::take_hook();
// Limit the span that we've hijack'd the panic hook, so that if something goes wrong
// with the unit test outside of our conformance eval, we don't conflate the two.
std::panic::set_hook({
Copy link
Contributor

Choose a reason for hiding this comment

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

It's been so long since I tried to catch a panic that I didn't realize you could set a handler for the current thread. o_O

#[test_resources("ion-tests/conformance/ion_encoding/module/macro/template/*.ion")]
#[test_resources("ion-tests/conformance/ion_encoding/module/macro/trivial/*.ion")]
#[test_resources("ion-tests/conformance/system_macros/*.ion")]
#[test_resources("ion-tests/conformance/tdl/*")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this macro support ** syntax for nesting at any depth? (Or maybe you're enumerating the subdirectories to leave something out?)

println!("Testing: {}", file_name);
let collection = TestCollection::load(file_name).expect("unable to load test file");
// Test for skip list. Convert windows '\\' separators into '/' to match skiplist.
if !GLOBAL_CONFORMANCE_SKIPLIST.iter().any(|f| *f == file_name.replace("\\", "/")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This works; here's another place we solved the same issue differently:

// A copy of the `ELEMENT_GLOBAL_SKIP_LIST` in which each file name has been canonicalized for the
// current host machine. This makes it possible to compare names in the list with names of files
// on the host without worrying about differences in (for example) path separators.
static CANONICAL_FILE_NAMES: LazyLock<Vec<String>> = LazyLock::new(|| {
ELEMENT_GLOBAL_SKIP_LIST
.iter()
.filter_map(|filename| {
// Canonicalize the skip list file names so they're in the host OS' preferred format.
// This involves looking up the actual file; if canonicalization fails, the file could
// not be found/read which could mean the skip list is outdated.
fs::canonicalize(filename).ok()
})
.map(|filename| filename.to_string_lossy().into())
.collect()
});

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.

2 participants