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

feat: turn entrypoint into gateway-conformance CLI #15

Merged
merged 6 commits into from
Mar 21, 2023

Conversation

galargh
Copy link
Contributor

@galargh galargh commented Mar 16, 2023

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

@galargh galargh mentioned this pull request Mar 16, 2023
@galargh galargh force-pushed the feat/gateway-conformance-cli branch 11 times, most recently from 1e6c3f2 to aaa57f9 Compare March 17, 2023 19:00
- 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
@galargh galargh force-pushed the feat/gateway-conformance-cli branch from aaa57f9 to 591fd9e Compare March 17, 2023 19:10
@galargh galargh force-pushed the feat/gateway-conformance-cli branch from 10dc8f2 to 74b0079 Compare March 19, 2023 13:36
Comment on lines +27 to +29
const (
SubdomainGateway Spec = "subdomain-gateway"
)
Copy link
Contributor Author

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.

Comment on lines +8 to +13
wip maturity = "wip"
draft maturity = "draft"
reliable maturity = "reliable"
stable maturity = "stable"
permanent maturity = "permanent"
deprecated maturity = "deprecated"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 41 to 47
func (s Spec) IsEnabled() bool {
if enabled, ok := specEnabled[s]; ok {
return enabled
} else {
return s.IsMature()
}
}
Copy link
Contributor Author

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, "+") {
Copy link
Contributor Author

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.

Copy link
Contributor

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, "-") {
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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")
Copy link
Contributor Author

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.

Comment on lines 88 to 92
&cli.StringFlag{
Name: "specs",
Usage: "A comma-separated list of specs to test",
Value: "",
Destination: &specs,
Copy link
Contributor Author

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.

Copy link
Contributor Author

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!

Comment on lines 1 to 3
//go:build !no_subdomain_gateway_spec
// +build !no_subdomain_gateway_spec

Copy link
Contributor Author

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.

Comment on lines +59 to +61
if SubdomainGateway.IsEnabled() {
Run(t, tests)
}
Copy link
Contributor Author

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.

Copy link
Contributor

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

,
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
Copy link
Contributor Author

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.

@galargh galargh changed the title wip: turn entrypoint into gateway-conformance CLI feat: turn entrypoint into gateway-conformance CLI Mar 20, 2023
@galargh galargh marked this pull request as ready for review March 20, 2023 10:48
Copy link
Contributor

@laurentsenta laurentsenta left a comment

Choose a reason for hiding this comment

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

👍 (needs doc)

@laurentsenta laurentsenta mentioned this pull request Mar 20, 2023
29 tasks
@galargh galargh merged commit 5e12216 into feat/entrypoint Mar 21, 2023
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.

2 participants