-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add conformance testing DSL #826
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #826 +/- ##
==========================================
- Coverage 80.60% 77.74% -2.86%
==========================================
Files 140 134 -6
Lines 28209 32623 +4414
Branches 28209 32623 +4414
==========================================
+ Hits 22737 25363 +2626
- Misses 3641 5299 +1658
- Partials 1831 1961 +130 ☔ View full report in Codecov by Sentry. |
…ws version can match
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 looks good! Please do a documentation pass. It would be helpful to connect implementation sections to the part of the DSL spec they implement. Having an explanation of the motivation for top-level types like ModelValue
would also be nice.
src/lazy/binary/raw/v1_1/value.rs
Outdated
let ion_type = if self.encoded_value.header.ion_type_code == OpcodeType::TypedNull { | ||
let body = self.value_body(); | ||
ION_1_1_TYPED_NULL_TYPES[body[0] as usize] | ||
} else { | ||
IonType::Null | ||
}; | ||
return Ok(ValueRef::Null(ion_type)); |
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.
Why was this needed? ion_type()
should return the correctly interpreted type from the opcode and optional typed null byte. (return Ok(ValueRef::Null(self.ion_type()))
also appears below on line 227).
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.
tests/conformance_dsl/context.rs
Outdated
v => v, | ||
}; | ||
|
||
// Ok(Reader::new(AnyEncoding, data_slice)?.read_all_elements()?) |
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.
Old comment?
// Ok(Reader::new(AnyEncoding, data_slice)?.read_all_elements()?) | |
// Ok(Reader::new(AnyEncoding, data_slice)?.read_all_elements()?) |
tests/conformance_dsl/model.rs
Outdated
use std::collections::HashMap; | ||
|
||
#[derive(Debug, Clone, Eq, Hash, PartialEq)] | ||
pub(crate) enum SymTok { |
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 suggest spelling out the words:
pub(crate) enum SymTok { | |
pub(crate) enum SymbolToken { |
tests/conformance_tests.rs
Outdated
#[test_resources("ion-tests/conformance/core/string_symbol.ion")] | ||
#[test_resources("ion-tests/conformance/core/empty_document.ion")] | ||
#[test_resources("ion-tests/conformance/core/toplevel_produces.ion")] | ||
// #[test_resources("ion-tests/conformance/ivm.ion")] |
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.
// #[test_resources("ion-tests/conformance/ivm.ion")] | |
// #[test_resources("ion-tests/conformance/ivm.ion")] |
?
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.
Yea, I had commented this out because it currently doesn't pass due to the symbol syntax that's needed. Removing it for now.
…is not a fragment
// Handle retrieving the type for a typed null. | ||
if self.encoded_value.header.type_code() == OpcodeType::TypedNull { | ||
let body = self.value_body(); | ||
ION_1_1_TYPED_NULL_TYPES[body[0] as usize] | ||
} else { | ||
self.encoded_value.ion_type() | ||
} |
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.
Could you put this functionality in a self.read_null()
method instead of having it happen in ion_type()
?
There are three other raw value types besides LazyRawBinaryValue_1_1
:
LazyRawBinaryValue_1_0
LazyRawTextValue_1_1
LazyRawTextValue_1_0
Each of them has an ion_type()
method and I'm pretty sure at least some of them return IonType::Null
if the value is a null value, even if it's a typed null. The behavior you've implemented is probably more correct, but if we make this change here we'd need to make it in the other three places too.
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.
Added #828 to track this.
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.
ack, ty, I will follow up with that today.
Issue #, if available: n/a
Description of changes:
This PR adds an implementation of the conformance DSL, along with a runner for testing conformance tests during CI/CD, and a separate runner that can be used to target files more ad-hoc. The ion-tests submodule has also been updated in order to pull in the conformance tests, which also required some updates to the
test_resource
paths for 1.0.Most of the code is modeled directly after the grammar. Documents contain fragments and a continuation. Expectations, which are a subset of continuations, act as terminal nodes and trigger the evaluation of the test. Context tracks the fragments, version, and encoding, for the test's evaluation path.
CI/CD Runner
CLI Runner
Notes
I'll follow up after this PR to make errors reporting better. I also have some plans for refactoring and simplifying some of the implementation, post merge.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.