Fix #5546 - Adjust overrride of Dir.glob so that it finds json_schema attributes#5548
Merged
Conversation
jmarrec
commented
Dec 9, 2025
Comment on lines
+670
to
+671
| # Without this 'path/**/*.rb' will match 'path/sub/file.rb' but not 'path/file.rb', cf #5546 | ||
| flags = flags | File::FNM_PATHNAME |
Collaborator
Author
There was a problem hiding this comment.
Can't be fooled by the amount of code change, massive pain to diagnose and fix.
<broken record>We should drop the embedded shenanigans!</broken record>
Contributor
🧪 Test Results DashboardSummary
|
| Run | XML File | Status |
|---|---|---|
| run1 | results.xml |
✅ Found |
| run3 | results.xml |
✅ Found |
| run2 | results.xml |
✅ Found |
… attributes
```
git@github.com:voxpupuli/json-schema.git
cd json-schema/lib
gvim test.rb
```
**test.rb**
```ruby
files = [
"json-schema/attributes/format.rb",
"json-schema/attributes/formats/custom.rb"
]
match_all_patterns = [
"json-schema/**/*.rb",
"json-schema/attributes/**/*.rb",
]
match_only_single_patterns = [
"json-schema/attributes/*.rb",
"json-schema/attributes/*/*.rb",
]
puts "| Pattern | File | Matches | Matches (FNM_PATHNAME) | Expected |"
puts "|--------------------------------|------------------------------------------|----------|------------------------|----------|"
match_all_patterns.each do |pattern|
files.each do |f|
matches = File.fnmatch(pattern, f)
matches_pathname = File.fnmatch(pattern, f, File::FNM_PATHNAME)
expected = Dir.glob(pattern).include?(f)
puts "| #{pattern.ljust(30)} | #{f.ljust(40)} | #{matches.to_s.center(8)} | #{matches_pathname.to_s.center(22)} | #{expected.to_s.center(8)} |"
end
end
match_only_single_patterns.each do |pattern|
files.each do |f|
matches = File.fnmatch(pattern, f)
matches_pathname = File.fnmatch(pattern, f, File::FNM_PATHNAME)
expected = Dir.glob(pattern).include?(f)
puts "| #{pattern.ljust(30)} | #{f.ljust(40)} | #{matches.to_s.center(8)} | #{matches_pathname.to_s.center(22)} | #{expected.to_s.center(8)} |"
end
end
```
```
$ruby test.rb
| Pattern | File | Matches | Matches (FNM_PATHNAME) | Expected |
|--------------------------------|------------------------------------------|----------|------------------------|----------|
| json-schema/**/*.rb | json-schema/attributes/format.rb | true | true | true |
| json-schema/**/*.rb | json-schema/attributes/formats/custom.rb | true | true | true |
| json-schema/attributes/**/*.rb | json-schema/attributes/format.rb | false | true | true |
| json-schema/attributes/**/*.rb | json-schema/attributes/formats/custom.rb | true | true | true |
| json-schema/attributes/*.rb | json-schema/attributes/format.rb | true | true | true |
| json-schema/attributes/*.rb | json-schema/attributes/formats/custom.rb | true | false | false |
| json-schema/attributes/*/*.rb | json-schema/attributes/format.rb | false | false | false |
| json-schema/attributes/*/*.rb | json-schema/attributes/formats/custom.rb | true | true | true |
```
d18db0d to
708b0a1
Compare
jmarrec
commented
Dec 9, 2025
Comment on lines
+245
to
+269
| def test_json_schema | ||
| require 'json-schema' | ||
|
|
||
| schema = { | ||
| "type" => "object", | ||
| "required" => ["a"], | ||
| "properties" => { | ||
| "a" => { | ||
| "type" => "integer" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| data_valid = { "a" => 5 } | ||
| JSON::Validator.validate(schema, data_valid) | ||
|
|
||
| data_invalid = { "a" => "taco" } | ||
|
|
||
| error = assert_raises(JSON::Schema::ValidationError) do | ||
| # "The property '#/a' of type String did not match the following type: integer" | ||
| JSON::Validator.validate!(schema, data_invalid) | ||
| end | ||
| assert_match(/The property '#\/a' of type string did not match the following type: integer/, error.message) | ||
|
|
||
| end |
Collaborator
Author
There was a problem hiding this comment.
As @shorowit pointed out, a test is an excellent idea...
Before fix
1) Error:
EmbeddedRuby_Test#test_json_schema:
NoMethodError: undefined method `validate' for nil:NilClass
:/ruby/3.2.0/gems/json-schema-4.3.1/lib/json-schema/schema/validator.rb:25:in `block in validate'
:/ruby/3.2.0/gems/json-schema-4.3.1/lib/json-schema/schema/validator.rb:23:in `each'
:/ruby/3.2.0/gems/json-schema-4.3.1/lib/json-schema/schema/validator.rb:23:in `validate'
:/ruby/3.2.0/gems/json-schema-4.3.1/lib/json-schema/schema.rb:32:in `validate'
:/ruby/3.2.0/gems/json-schema-4.3.1/lib/json-schema/validator.rb:115:in `validate'
:/ruby/3.2.0/gems/json-schema-4.3.1/lib/json-schema/validator.rb:259:in `validate!'
:/ruby/3.2.0/gems/json-schema-4.3.1/lib/json-schema/validator.rb:243:in `validate'
/home/julien/Software/Others/OpenStudio/src/cli/test/test_embedded_ruby.rb:259:in `test_json_schema'
Collaborator
|
CI Results for 8f0f77f:
|
shorowit
approved these changes
Dec 12, 2025
shorowit
left a comment
Contributor
There was a problem hiding this comment.
Confirmed that the gem now runs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request overview
json-schemagem is broken #5546Demonstration
test.rb
Pull Request Author
src/model/test)src/energyplus/Test)src/osversion/VersionTranslator.cpp)Labels:
IDDChangeAPIChangePull Request - Ready for CIso that CI builds your PRReview Checklist
This will not be exhaustively relevant to every PR.