Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make tests available as JSON and as CSV (RFC 4180) #79

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

cabo
Copy link
Member

@cabo cabo commented Sep 1, 2023

Makefile assumes that editing happens in CSV
make new-tests.csv can be called manually after an edit to the JSON

Makefile assumes that editing happens in CSV
json-to-csv.rb can be called manually after an edit to the JSON
@chrysn
Copy link
Member

chrysn commented Sep 1, 2023

Running make gives me

ruby csv-to-json.rb tests.csv | diff tests.json -
<internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- cbor-cri (LoadError)
        from <internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from csv-to-json.rb:1:in `<main>'

I suppose there is something I should gem install here?

Copy link

@babongo babongo left a comment

Choose a reason for hiding this comment

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

in my local setting (*) I bump into this error:

➜  tests git:(tests-csv) make
ruby csv-to-json.rb tests.csv | diff tests.json -
csv-to-json.rb:39: syntax error, unexpected in, expecting when
  in ["base", baseuri, basecri_di...
csv-to-json.rb:43: syntax error, unexpected in, expecting end
  in ["ok", uri_in, cri_in_diag, ...
csv-to-json.rb:51: syntax error, unexpected end, expecting end-of-input
  end
1,713d0
< {
<   "base-uri": "coaps://foo:4711/pa/th?query#frag",
[...]

which I'm having a bit of trouble decoding...

(*) Darwin Kernel Version 22.5.0: Mon Apr 24 20:53:19 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T6020 arm64

Copy link

@babongo babongo left a comment

Choose a reason for hiding this comment

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

I have updated ruby to 3.2, fetched 0bd3157 and now I got the same as @chrysn :

➜  tests git:(tests-csv) make
ruby csv-to-json.rb tests.csv | diff tests.json -
<internal:/opt/homebrew/Cellar/ruby/3.2.2_1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- cbor-diagnostic (LoadError)
	from <internal:/opt/homebrew/Cellar/ruby/3.2.2_1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from csv-to-json.rb:1:in `<main>'
1,713d0

@cabo
Copy link
Member Author

cabo commented Sep 1, 2023

gem install cbor-diag

Or now just:

bundle

@chrysn
Copy link
Member

chrysn commented Apr 5, 2024

Building still fails for me, but this time it seems to be other dependencies -- I'll focus on the CSV in further testing, and ignore the build process.

@chrysn
Copy link
Member

chrysn commented Apr 5, 2024

Next step: cabo will push an update where everything is in its current shape. CSV will be the source of truth, JSON will stay provided for those who can't process CSV easily.

"uri-from-cri": "//a%2Ea",
"resolved-cri": "82218163612e61",
"resolved-uri": "coaps://a%2Eb",
"invalid": "The dot ('.') is unreserved, and thus never percent encoded, and thus (when used with a delimiter) not legal in the strings of the host"
Copy link
Member

Choose a reason for hiding this comment

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

How does this fare under the CSV-JSON conversion?

| Key Name | Description |
| --- | --- |
| `type` | kind of test: `ok`, `rt` (round-trip), `red` (normalized on roundtrip); special value `base` |
| `uri` | a URI reference |
Copy link
Member

Choose a reason for hiding this comment

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

AIU this is optional; in cases when a CRI reference can not be expressed as a URI reference (or the test author didn't care about URIs in this scenario), it is often empty. Is this distinguished from the empty URI reference?

Comment on lines +35 to +37

(Note that, with these settings, no quote character is used at all for
the extant examples.)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
(Note that, with these settings, no quote character is used at all for
the extant examples.)

There is an example with …;|a;a|;… in the latest version.

@chrysn chrysn mentioned this pull request May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants