-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat: turn entrypoint into gateway-conformance CLI #15
Conversation
1e6c3f2
to
aaa57f9
Compare
- add support for go test args to the entrypoint - update Go version to 1.20 - rename is-subdomain to subdomain-gateway-spec - add merged as argument to the extract-fixtures command - rename entrypoint as gateway-conformance - rename tests package from main to tests - rename build tag to no_subdomain_gateway_spec - add a utility function for accessing GATEWAY_CONFORMANCE_HOME
aaa57f9
to
591fd9e
Compare
10dc8f2
to
74b0079
Compare
const ( | ||
SubdomainGateway Spec = "subdomain-gateway" | ||
) |
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.
Maybe these could correspond to the keywords/tag that Robin told us about.
wip maturity = "wip" | ||
draft maturity = "draft" | ||
reliable maturity = "reliable" | ||
stable maturity = "stable" | ||
permanent maturity = "permanent" | ||
deprecated maturity = "deprecated" |
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 updated specs specify maturity level per spec: https://github.com/ipfs/specs/pull/382/files#diff-68949a04625be3a1b31a438f35a6e8daaeb881ffd4a1631e083b3b070222e2f9
tooling/specs/specs.go
Outdated
func (s Spec) IsEnabled() bool { | ||
if enabled, ok := specEnabled[s]; ok { | ||
return enabled | ||
} else { | ||
return s.IsMature() | ||
} | ||
} |
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 a spec wasn't enabled/disabled explicitly, we infer whether it's enabled or not based on its' maturity.
if err != nil { | ||
return err | ||
} | ||
if strings.HasPrefix(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.
If a spec is prefixed with +
, it should be enabled. This can be used to enable tests for specs that are disabled by default (those not mature enough).
For example, let's say spec fancy
has maturity wip
. If we run tests without any flags, then tests for fancy
would be skipped. If we used -specs=+fancy
, tests for fancy
would be executed AND all the tests that are enabled by default would be executed too.
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.
Should we keep these comments somewhere in the README?
} | ||
if strings.HasPrefix(name, "+") { | ||
enable = append(enable, spec) | ||
} else if strings.HasPrefix(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.
If a spec is prefixed with -
, it should be disabled. This can be used to disable tests for specs that are enabled by default (those mature enough).
For example, we can disable subdomain-gateway
tests while still testing all the other specs that are enabled by default by providing -specs=-subdomain-gateway
flag.
enable = append(enable, spec) | ||
} else if strings.HasPrefix(name, "-") { | ||
disable = append(disable, spec) | ||
} else { |
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 a spec is not prefixed with +
nor -
, we assume that the user wants to execute only that spec. Using flag -specs=subdomain-gateway
would disable ALL the specs and then enable subdomain-gateway
only.
tests/init.go
Outdated
var specsFlagValue specsFlag | ||
|
||
func init() { | ||
flag.Var(&specsFlagValue, "specs", "comma-separated list of specs to 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.
I implemented this as a single -specs
flag with differing behaviour based on prefixes but it might as well be three separate flags -only
, -enable
, -disable
. I like the conciseness of -specs
personally but I definitely can see an argument being made for verbosity of breaking it up.
cmd/gateway-conformance/main.go
Outdated
&cli.StringFlag{ | ||
Name: "specs", | ||
Usage: "A comma-separated list of specs to test", | ||
Value: "", | ||
Destination: &specs, |
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 thought about it and I think I'd prefer an interface that people can get used to. If we have separate flag for each spec (as it was here before), then we'd have to change that interface every time a new spec is added to the tests. I think it'd become quite overwhelming with the amount of different specs we might want to support. Also, it'd be harder to maintain as we'd have to remember to update the lists in all these places. In my opinion a single (or three) flags that take a list of specs will be easier to manage in a long run.
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 might be useful to add a command for listing all the specs!
//go:build !no_subdomain_gateway_spec | ||
// +build !no_subdomain_gateway_spec | ||
|
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.
Build tags are cool but I think they might not be powerful enough. E.g. if we had tests that are intersectional, then we'd have to create a new file for them. What I'm saying is, we could probably still achieve similar results but it'd be harder than if we used something that's available during runtime. The additional benefit is that with runtime exclusion, we can choose for the skipped tests to show up as skipped in the report. If we don't build a file, it's as if the tests never existed.
if SubdomainGateway.IsEnabled() { | ||
Run(t, tests) | ||
} |
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 added it like this for now for simplicity. What I imagine in the future is that each test case comes with a list of specs it tests. Before running the test case, we check if all the specs are enabled. If not, we skip that test case. Additionally, if a test case fails, we could link to the spec in the error message.
To not have to specify specs for each test case, we could wrap the encapsulating array in some class and store the defaults there.
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.
👍 we can piggy back on the SugarTest
I'm working on in
tests := SugarTests{ |
we can create a follow up task for this
@@ -34,7 +34,7 @@ jobs: | |||
xml: output.xml | |||
html: output.html | |||
markdown: output.md | |||
subdomain-gateway-spec: false | |||
specs: -subdomain-gateway | |||
args: -skip TestGatewayCar |
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.
Disabled it by test name here. I think it's still useful in a case like this. Kubo does support CARs so it wouldn't make sense to disable testing CAR spec altogether. All we want is to disable this single test because Kubo's implementation is wrong at the moment.
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.
👍 (needs doc)
I extracted file renames/moves to a separate commit so reviewing commit by commit might make the most sense: c67b7df?diff=split&w=1
Please note that the last commit introduces a different approach to test flags: 74b0079