Skip to content

Conversation

@jmarrec
Copy link
Collaborator

@jmarrec jmarrec commented Dec 9, 2025

Pull request overview

Demonstration

git@github.com:voxpupuli/json-schema.git
cd json-schema/lib
gvim test.rb

test.rb

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   |

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

@jmarrec jmarrec self-assigned this Dec 9, 2025
@jmarrec jmarrec added severity - Normal Bug component - CLI Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. component - Ruby bindings labels 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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

@jmarrec jmarrec requested a review from shorowit December 9, 2025 10:05
@github-actions
Copy link

github-actions bot commented Dec 9, 2025

🧪 Test Results Dashboard

Summary

Metric Value
Total Tests 4156
Passed 4146
Failed 10
Errors 0
Skipped 0
Success Rate 99.8%
Generated 2025-12-12 18:05:27 UTC

⚠️ Minor Issues Detected

🔍 Failed Tests (10 failures)

Linux-c++ (10 failures)

OpenStudioCLI.Classic.test_measure_manager.OpenStudioCLI.Classic.test_measure_manager (run1)

Error Message:

Failed

Full Details:

No details available
CLITest-test_bundle-bundle.CLITest-test_bundle-bundle (run1)

Error Message:

Failed

Full Details:

No details available
CLITest-test_bundle-bundle_git.CLITest-test_bundle-bundle_git (run1)

Error Message:

Failed

Full Details:

No details available
CLITest-test_bundle-bundle_native_embedded.CLITest-test_bundle-bundle_native_embedded (run1)

Error Message:

Failed

Full Details:

No details available
CLITest-test_bundle-bundle.CLITest-test_bundle-bundle (run3)

Error Message:

Failed

Full Details:

No details available
CLITest-test_bundle-bundle_git.CLITest-test_bundle-bundle_git (run3)

Error Message:

Failed

Full Details:

No details available
CLITest-test_bundle-bundle_native_embedded.CLITest-test_bundle-bundle_native_embedded (run3)

Error Message:

Failed

Full Details:

No details available
CLITest-test_bundle-bundle.CLITest-test_bundle-bundle (run2)

Error Message:

Failed

Full Details:

No details available
CLITest-test_bundle-bundle_git.CLITest-test_bundle-bundle_git (run2)

Error Message:

Failed

Full Details:

No details available
CLITest-test_bundle-bundle_native_embedded.CLITest-test_bundle-bundle_native_embedded (run2)

Error Message:

Failed

Full Details:

No details available

📊 Test Run Information

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   |
```
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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'

@ci-commercialbuildings
Copy link
Collaborator

ci-commercialbuildings commented Dec 12, 2025

CI Results for 8f0f77f:

Copy link
Contributor

@shorowit shorowit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed that the gem now runs.

@anchapin anchapin merged commit 160ffa4 into develop Dec 12, 2025
3 of 6 checks passed
@anchapin anchapin deleted the 5546_json_schema branch December 12, 2025 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component - CLI component - Ruby bindings Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. severity - Normal Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

json-schema gem is broken

5 participants