Ignore non-standard tests from JSONPath CTS

This commit is contained in:
Fabrice Reix 2025-11-18 08:42:50 +01:00 committed by hurl-bot
parent e81eecdc0f
commit 6fed3975b3
No known key found for this signature in database
GPG Key ID: 1283A2B4A0DCAF8D
1 changed files with 16 additions and 3 deletions

View File

@ -30,6 +30,16 @@ use crate::jsonpath2::{
parser::{ParseError, ParseErrorKind},
};
/// Tests to ignore in the CTS suite
/// They may apply to some existing implementations such as jsonpath.com (JSONPath Plus engine)
/// but they are not standard compliant.
const IGNORED_TESTS: &[&str] = &[
"filter, non-singular existence, multiple",
// $[?(@[0, 0, 'a'])]
// The union selector cannot be used directly as a boolean predicate.
// The standard-compliant expression is $[?(@[0] || @['a'])]
];
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct TestCase {
name: String,
@ -259,9 +269,10 @@ fn load_testcases() -> Vec<TestCase> {
fn run() {
let testcases = load_testcases();
// TODO: Remove Limit when spec is fully implemented
let testcases = testcases.iter().take(106);
let testcases = testcases.iter().take(107);
let count_total = testcases.len();
let testcases = testcases.filter(|tc| !IGNORED_TESTS.contains(&tc.name.as_str()));
let count_ignored = count_total - testcases.clone().count();
let errors = testcases
.map(|test_case| test_case.run())
.collect::<Vec<Result<(), TestCaseError>>>()
@ -271,7 +282,8 @@ fn run() {
if !errors.is_empty() {
let count_failed = errors.len();
let count_passed = count_total - count_failed;
let count_passed = count_total - count_ignored - count_failed;
let mut s = String::new();
for error in &errors {
s.push_str(&error.to_string());
@ -281,6 +293,7 @@ fn run() {
s.push_str(format!("Total: {count_total}\n").as_str());
s.push_str(format!("Passed: {count_passed}\n").as_str());
s.push_str(format!("Failed: {count_failed}\n").as_str());
s.push_str(format!("Ignore: {count_ignored}\n").as_str());
panic!("{}", s);
}
}