-
Notifications
You must be signed in to change notification settings - Fork 133
Augment JSON ABI #1429
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
base: main
Are you sure you want to change the base?
Augment JSON ABI #1429
Conversation
eb44837 to
46c32f1
Compare
Documentation/ABI/JSON.md
Outdated
| <bug> ::= { | ||
| ["url": <string>,] ; the bug url | ||
| ["id": <string>,] ; the bug id | ||
| "title": <string> ; the human readable bug title |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"title" should be optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're write.. I thought I had seen it as required. My mistake.
BTW, nice catch.
Documentation/ABI/JSON.md
Outdated
| <tags> ::= <string> ; a string representation of a tag | ||
| <bug> ::= { | ||
| ["url": <string>,] ; the bug url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ["url": <string>,] ; the bug url | |
| ["url": <string>,] ; the bug URL |
(Nitpick)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK.
| var bugs: [Bug]? | ||
|
|
||
| /// The time limits associated with the test. | ||
| var timeLimit: Int? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var timeLimit: Int? | |
| var timeLimit: Double? |
Subsecond precision is possible, at least nominally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
| self.bugs = bugs | ||
| } | ||
| if #available(_clockAPI , *) { | ||
| if let seconds = test.timeLimit?.components.seconds { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if let seconds = test.timeLimit?.components.seconds { | |
| self.timeLimit = test.timeLimit | |
| .map(TimeValue.init) | |
| .map(Double.init) |
(Brain-compiled.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm.. that code delta looks wild. Our of curiosity, how does the TimeValue.init know to call the initializer with the value of test.timeLimit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean. It "knows" because TimeValue.init takes a single value which is the value passed to map() if test.timeLimit is not nil.
| /// | ||
| /// - Warning: Tags are not yet part of the JSON schema. | ||
| var _tags: [String]? | ||
| var tags: [String]? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var tags: [String]? | |
| /// | |
| /// @Metadata { | |
| /// @Available(Swift, introduced: 6.3) | |
| /// } | |
| var tags: [String]? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack
| var _tags: [String]? | ||
| var tags: [String]? | ||
|
|
||
| // The bugs associated with the test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // The bugs associated with the test. | |
| // The bugs associated with the test. | |
| /// | |
| /// @Metadata { | |
| /// @Available(Swift, introduced: 6.3) | |
| /// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack
| // The bugs associated with the test. | ||
| var bugs: [Bug]? | ||
|
|
||
| /// The time limits associated with the test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// The time limits associated with the test. | |
| /// The time limits associated with the test. | |
| /// | |
| /// @Metadata { | |
| /// @Available(Swift, introduced: 6.3) | |
| /// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack
95d2763 to
b3bda79
Compare
Documentation/ABI/JSON.md
Outdated
| <test-id> ::= <string> ; an opaque string representing the test case | ||
| <tag> ::= "." <string> ; a string representation of a tag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chore (blocking): Update to reflect actual behaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop the "." from the definition please! Even if it's mandated, this wouldn't be syntactically correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
Add tags, bug and timeLimit traits to the test ABI JSON data.
b3bda79 to
15034be
Compare
| ["url": <string>,] ; the bug URL | ||
| ["id": <string>,] ; the bug id | ||
| ["title": <string>] ; the human readable bug title | ||
| } ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } ; | |
| } |
The trailing semicolon introduces a comment, but none is here. (Nitpick!)
| switch kind { | ||
| case let .staticMember(name): | ||
| ".\(name)" | ||
| "\(name)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change, please revert. If you need a property that exposes name without the period, we can reasonably add one.
|
|
||
| /// This instance represented as a string, suitable for encoding. | ||
| private var _codableStringValue: String { | ||
| package var _codableStringValue: String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why package?
| let testTags = try #require(testRecord.tags) | ||
| #expect(testTags.count >= 1) | ||
| for tag in testTags { | ||
| #expect(!tag._codableStringValue.starts(with: ".")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to touch kind here directly, so I don't think any changes to Tag itself are necessary.
| /// @Metadata { | ||
| /// @Available(Swift, introduced: 6.3) | ||
| /// } | ||
| var tags: Set<Tag>? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var tags: Set<Tag>? | |
| var tags: [Tag]? |
No need for uniquing/hashing in the encoded form, so it's just overhead.
| self.bugs = bugs | ||
| } | ||
| if #available(_clockAPI , *) { | ||
| self.timeLimit = test.timeLimit.map(TimeValue.init).map(Double.init) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's informal house style to put the functional calls (e.g. .map()) on newlines if there's more than one, otherwise it can be hard to read the whole expression. (Nitpick.)
TO BE COMPLETED.
Add tags, bug and timeLimit traits to the ABI JSON data.
[One line description of your change]
Motivation:
[Explain here the context, and why you're making that change. What is the problem you're trying to solve.]
Modifications:
[Describe the modifications you've done.]
Checklist: