Skip to content

Commit 3b8f55c

Browse files
committed
Skip comparison tests with no consensus
Simplify `compare/compare_test.go` by skipping tests with no consensus, which were the source of the previous unknowns in the test. Based on advice from cburgmer/json-path-comparison#153#issuecomment-3374075044. While at it, upgrade `golangci-lint` to v2.5.0 and tweak its configuration to scan `compare/compare_test.go` and fix the long lines it complains about. Also have the `test-compare` target run the tests verbosely, and run the CI tests on Go 1.25.
1 parent 11c4071 commit 3b8f55c

File tree

6 files changed

+29
-24
lines changed

6 files changed

+29
-24
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test and Lint
1+
name: Test and Lint
22
on:
33
push:
44
branches-ignore: [wip/**]
@@ -7,7 +7,7 @@ jobs:
77
strategy:
88
matrix:
99
os: [[🐧, Ubuntu], [🍎, macOS], [🪟, Windows]]
10-
go: ["1.24", "1.23"]
10+
go: ["1.25", "1.24", "1.23"]
1111
name: ${{ matrix.os[0] }} Test Go ${{ matrix.go }} on ${{ matrix.os[1] }}
1212
runs-on: ${{ matrix.os[1] }}-latest
1313
steps:

.golangci.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
version: "2"
2+
run:
3+
build-tags:
4+
- compare
25
linters:
36
default: all
47
disable:

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ All notable changes to this project will be documented in this file. It uses the
77
[Semantic Versioning]: https://semver.org/spec/v2.0.0.html
88
"Semantic Versioning 2.0.0"
99

10+
## [v0.10.2] — Unreleased
11+
12+
### 📔 Notes
13+
14+
* Upgraded to `golangci-lint` v2.5.0.
15+
* Removed unused constant from `parser/lex.go`
16+
1017
## [v0.10.1] — 2025-09-16
1118

1219
### 🐞 Bug Fixes

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ compare/regression_suite.yaml:
1313
curl -so "$@" https://raw.githubusercontent.com/cburgmer/json-path-comparison/refs/heads/master/regression_suite/regression_suite.yaml
1414

1515
test-compare: compare/regression_suite.yaml
16-
GOTOOLCHAIN=local ${GO} test -tags=compare ./compare -count=1
16+
GOTOOLCHAIN=local ${GO} test -v -tags=compare ./compare -count=1
1717

1818
test-all: compare/regression_suite.yaml
1919
GOTOOLCHAIN=local ${GO} test -tags=compare ./... -count=1
@@ -47,7 +47,7 @@ brew-lint-depends:
4747

4848
.PHONY: debian-lint-depends # Install linting tools on Debian
4949
debian-lint-depends:
50-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/bin v2.4.0
50+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/bin v2.5.0
5151

5252
.PHONY: install-generators # Install Go code generators
5353
install-generators:

compare/compare_test.go

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,42 +55,38 @@ func TestConsensus(t *testing.T) {
5555
t.Parallel()
5656

5757
skip := map[string]string{
58-
"array_slice_with_step_and_leading_zeros": "leading zeros disallowed integers; see RFC 9535 sections 2.3.3.1, 2.3.4.1",
59-
"dot_notation_with_number_on_object": "leading digits disallowed in shorthand names; see RFC 9535 section 2.5.1.1",
60-
"dot_notation_with_dash": "dash disallowed in shorthand hames; see RFC 9535 section 2.5.1.1",
58+
"array_slice_with_step_and_leading_zeros": "RFC 9535 § 2.3.3.1, 2.3.4.1: leading zeros disallowed in integers",
59+
"dot_notation_with_number_on_object": "RFC 9535 § 2.5.1.1: leading digits disallowed in shorthand names",
60+
"dot_notation_with_dash": "RFC 9535 § 2.5.1.1: dash disallowed in shorthand hames",
6161
}
6262

6363
for _, q := range queries(t) {
6464
t.Run(q.ID, func(t *testing.T) {
6565
t.Parallel()
6666

67+
// Skip tests with no consensus.
68+
// https://github.com/cburgmer/json-path-comparison/pull/153#issuecomment-3374075044
69+
if q.Consensus == nil {
70+
t.Skip("No consensus")
71+
}
72+
73+
// Skip tests where the consensus NOT_SUPPORTED.
6774
if q.Consensus == "NOT_SUPPORTED" {
6875
t.Skip(q.Consensus)
6976
}
7077

78+
// Skip tests that violate RFC 9535.
7179
if r, ok := skip[q.ID]; ok {
7280
t.Skip(r)
7381
}
7482

7583
path, err := jsonpath.Parse(q.Selector)
76-
// XXX Why is consensus empty?
77-
if q.Consensus != nil {
78-
require.NoError(t, err)
79-
}
80-
if err != nil {
81-
// XXX Why is there an error? TODOs?
82-
assert.Nil(t, path)
83-
return
84-
}
84+
require.NoError(t, err)
8585
result := []any(path.Select(q.Document))
8686

87-
switch {
88-
case q.Ordered:
87+
if q.Ordered {
8988
assert.Equal(t, q.Consensus, result)
90-
case q.Consensus == nil:
91-
// XXX What to do here?
92-
// assert.Empty(t, result)
93-
default:
89+
} else {
9490
assert.ElementsMatch(t, q.Consensus, result)
9591
}
9692
})

parser/lex.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ const (
4848
hex = 16
4949

5050
// Token literals.
51-
nullByte = 0x00
52-
backslash = '\\'
51+
nullByte = 0x00
5352

5453
// blanks selects blank space characters.
5554
blanks = uint64(1<<'\t' | 1<<'\n' | 1<<'\r' | 1<<' ')

0 commit comments

Comments
 (0)