Skip to content

Commit

Permalink
fix: atomic values getting invalid spans (#327)
Browse files Browse the repository at this point in the history
- Fixed an issue where atomic values would be matched with all
trailing characters up until the next closing.
  • Loading branch information
V0ldek authored Oct 21, 2023
1 parent 45602e9 commit 8ebde5c
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 20 deletions.
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ updates:
- V0ldek
commit-message:
prefix: "dep:"
groups:
dev-deps:
dependency-type: development
deps:
dependency-type: production
update-types:
- patch
- minor

- package-ecosystem: cargo
directory: /crates/rsonpath-test-codegen
schedule:
Expand All @@ -23,6 +32,9 @@ updates:
- V0ldek
commit-message:
prefix: "chore(dep):"
groups:
test-deps:

- package-ecosystem: cargo
directory: /crates/rsonpath-test
schedule:
Expand All @@ -32,6 +44,9 @@ updates:
- V0ldek
commit-message:
prefix: "chore(dep):"
groups:
test-deps:

- package-ecosystem: cargo
directory: /fuzz
schedule:
Expand All @@ -41,6 +56,9 @@ updates:
- V0ldek
commit-message:
prefix: "chore(dep):"
groups:
test-deps:

- package-ecosystem: docker
directory: /.clusterfuzzlite
schedule:
Expand All @@ -50,6 +68,9 @@ updates:
- V0ldek
commit-message:
prefix: "chore(ci):"
groups:
clusterfuzzlite-deps:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand All @@ -59,3 +80,5 @@ updates:
- V0ldek
commit-message:
prefix: "chore(ci):"
groups:
ci-deps:
19 changes: 10 additions & 9 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ build-all profile="dev": (build-lib profile) (build-bin profile) (gen-tests)
doc $RUSTDOCFLAGS="--cfg docsrs":
cargo +nightly doc --open --package rsonpath-lib --all-features -Z rustdoc-scrape-examples

# Run the codegen for rsonpath-test, generating the E2E tests and JSONs.
gen-tests:
RSONPATH_ENABLE_TEST_CODEGEN=1 cargo build --package rsonpath-test

Expand Down Expand Up @@ -96,19 +97,19 @@ test-unit:

# Run the classifier tests on default features.
test-classifier:
cargo test --test classifier_correctness_tests -q
cargo test -p rsonpath-lib classifier_correctness -q

# Run the main engine end-to-end tests on default features.
test-engine: (gen-tests)
cargo test -p rsonpath-test --tests -q

# Run the input tests on default features.
test-input:
cargo test --test input_implementation_tests -q
cargo test --test input_implementation -q

# Run the query tests on default features.
test-parser:
cargo test --test query_parser_tests -q
cargo test --test query_parser -q

# Run all tests, including real dataset tests, on the feature powerset of the project.
test-full: (gen-tests)
Expand Down Expand Up @@ -146,15 +147,15 @@ test-book:

@add-test name:
f=`echo {{name}} | sed s/-/_/g` && \
cp ./crates/rsonpath-lib/tests/documents/toml/test_template_inline.toml ./crates/rsonpath-lib/tests/documents/toml/$f.toml && \
echo "Test template initialised at crates/rsonpath-lib/tests/documents/toml/$f.toml"
cp ./crates/rsonpath-test/documents/toml/test_template_inline.toml ./crates/rsonpath-test/documents/toml/$f.toml && \
echo "Test template initialised at crates/rsonpath-test/documents/toml/$f.toml"

@add-test-large name:
f=`echo {{name}} | sed s/-/_/g` && \
cp ./crates/rsonpath-lib/tests/documents/toml/test_template_large.toml ./crates/rsonpath-lib/tests/documents/toml/$f.toml && \
echo "Test template initialised at crates/rsonpath-lib/tests/documents/toml/$f.toml" && \
echo "{}" > ./crates/rsonpath-lib/tests/documents/json/large/$f.json && \
echo "Put your large JSON document as contents of crates/rsonpath-lib/tests/documents/json/large/$f.json"
cp ./crates/rsonpath-test/documents/toml/test_template_large.toml ./crates/rsonpath-test/documents/toml/$f.toml && \
echo "Test template initialised at crates/rsonpath-test/documents/toml/$f.toml" && \
echo "{}" > ./crates/rsonpath-test/documents/json/large/$f.json && \
echo "Put your large JSON document as contents of crates/rsonpath-test/documents/json/large/$f.json"

# === INSTALL ===

Expand Down
1 change: 0 additions & 1 deletion base.json

This file was deleted.

9 changes: 0 additions & 9 deletions bench.nu

This file was deleted.

2 changes: 1 addition & 1 deletion crates/rsonpath-lib/src/engine/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ where
}

if !self.is_list && self.automaton.has_transition_to_accepting(self.state) {
classifier.turn_colons_on(idx);
classifier.turn_colons_and_commas_on(idx);
} else {
classifier.turn_colons_off();
}
Expand Down
37 changes: 37 additions & 0 deletions crates/rsonpath-test/documents/toml/long_number.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Define the JSON input for all query test cases.
[input]
# Short description of the input structure.
description = "Simple object with a long number value"
# Set to true only if your specific test input is fully compressed (no extraneous whitespace).
is_compressed = false

# Inline JSON document.
[input.source]
json_string = '''
{
"a": {
"b": null
},
"c": null,
"d": 4571735769194290270,
"e": "abcdefghijklmnopqrstuvwxyz"
}
'''

# Define queries to test on the input.
[[queries]]
# Valid JSONPath query string.
query = "$..*"
# Short descritpion of the query semantics.
description = "select all subdocuments"

[queries.results]
# Number of expected matches.
count = 5
# Byte locations of spans of all matches, in order.
spans = [[11, 36], [26, 30], [47, 51], [62, 81], [92, 120]]
# Stringified values of all matches, verbatim as in the input,
# in the same order as above.
nodes = ['''{
"b": null
}''', 'null', 'null', '4571735769194290270', '"abcdefghijklmnopqrstuvwxyz"']

0 comments on commit 8ebde5c

Please sign in to comment.