Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

feat: added testFlags option - #1877

Merged
Ramya Rao (ramya-rao-a) merged 4 commits into
microsoft:masterfrom
johan-lejdung:master
Sep 4, 2018
Merged

feat: added testFlags option#1877
Ramya Rao (ramya-rao-a) merged 4 commits into
microsoft:masterfrom
johan-lejdung:master

Conversation

@johan-lejdung

Copy link
Copy Markdown
Contributor

I tested it out locally and it worked fine and all tests except rungodoc passed but it looked like I had to do some setup for that to pass to that is most likely the reason.

@msftclas

Microsoft Contribution License Agreements (msftclas) commented Aug 26, 2018

Copy link
Copy Markdown

CLA assistant check
All CLA requirements met.

@johan-lejdung

Johan Lejdung (johan-lejdung) commented Aug 26, 2018

Copy link
Copy Markdown
Contributor Author

Resolves: #1842

Comment thread src/testUtils.ts Outdated
}

let buildTags: string = testconfig.goConfig['buildTags'];
let buildTags: string = testconfig.goConfig['testTags'];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe we should fallback to using buildTags if no testTags are provided to ensure we are not breaking anybody else's use case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Of course!

Comment thread package.json Outdated
"type": "string",
"default": "",
"description": "The Go build tags to use for all commands that support a `-tags '...'` argument",
"description": "The Go build tags to use for all commands, excluding `go test` (see testTags), that support a `-tags '...'` argument",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

buildtags will still be used for compiling the test files which will be using go test
So we should probably change this to excluding when tests are run or something to that effect

@ramya-rao-a Ramya Rao (ramya-rao-a) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

Comment thread src/testUtils.ts Outdated
}

let buildTags: string = testconfig.goConfig['buildTags'];
let testTags: string = (testconfig.goConfig.has("testTags")) ? testconfig.goConfig['testTags'] : testconfig.goConfig['buildTags'];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We need to use single quotes, else the linter breaks the build.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oops!

Comment thread package.json Outdated
"type": "string",
"default": "",
"description": "The Go build tags to use for all commands that support a `-tags '...'` argument",
"description": "The Go build tags to use for all commands, excluding when running tests (see testTags), that support a `-tags '...'` argument",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The description now is a little confusing. Can we move the exclude statement to the end? How about the below?

The Go build tags to use for all commands that support a -tags '...'argument. When running tests,go.testTags will be used instead if it was set.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That does sound better :)

@johan-lejdung

Copy link
Copy Markdown
Contributor Author

The test with the multiple flags seems to be failing as well, not sure why since it's implemented just like buildTags. I will look at it later this weekend.

@ramya-rao-a

Copy link
Copy Markdown
Contributor

The testTags are to be used when running the tests. The unit tests are using the check function that is used to only compile the files and not run tests. Therefore, the check method will only use the build tags and will never use the test tags.

That's the reason for the failures

@johan-lejdung

Copy link
Copy Markdown
Contributor Author

Ah, thanks! Will get it sorted out today. Haven't had a second look yet, sorry for the delay :)

@ramya-rao-a

Copy link
Copy Markdown
Contributor

No problem, take your time.

@johan-lejdung

Copy link
Copy Markdown
Contributor Author

I removed the test for fallback on buildTags. The reason was that this line would evaluate to true even though 'testTags' was equal to ''.

First I chose to modify the check to

let testTags: string = testconfig.goConfig['testTags'].length > 1 ? testconfig.goConfig['testTags'] : testconfig.goConfig['buildTags'];

But that would create a weird dependency on buildTags, and remove the useCase we are looking to create; where you wanted tests to run without any tags but let it build the files with some tags.

Not sure how to solve the backwards compatibility problem actually since an unset config evaluated to an empty string and not undefined.

@johan-lejdung

Johan Lejdung (johan-lejdung) commented Sep 2, 2018

Copy link
Copy Markdown
Contributor Author

Ehm, getting weird errors Expected 3 arguments, but got 2.
on

return testCurrentFile(config1, []).then((result: boolean) => {

The function definition is as follows:

export function testCurrentFile(goConfig: vscode.WorkspaceConfiguration, args: string[]): Thenable<boolean>

Any ideas?

@ramya-rao-a

Copy link
Copy Markdown
Contributor

Ehm, getting weird errors Expected 3 arguments, but got 2.

Merge from the master branch to fix that.

@ramya-rao-a

Copy link
Copy Markdown
Contributor

and remove the useCase we are looking to create; where you wanted tests to run without any tags but let it build the files with some tags.

We had a similar case with the go.testFlags setting. We ended up supported null as a valid value. See below:

screen shot 2018-09-02 at 2 50 04 am

@johan-lejdung

Copy link
Copy Markdown
Contributor Author

That should do it!

@johan-lejdung

Copy link
Copy Markdown
Contributor Author

When can I expect this to get released? :)

@ramya-rao-a
Ramya Rao (ramya-rao-a) merged commit eae427d into microsoft:master Sep 4, 2018
@ramya-rao-a

Copy link
Copy Markdown
Contributor

Johan Lejdung (@johan-lejdung) A release should be some time next week. Until then, you can use the beta version of the extension to use this feature. See https://github.com/Microsoft/vscode-go/wiki/Use-the-beta-version-of-the-latest-Go-extension

Thanks for working on this!

@johan-lejdung

Copy link
Copy Markdown
Contributor Author

@Rhionin

Copy link
Copy Markdown

Bless you for building this! I've been dying for this feature!

@johan-lejdung

Copy link
Copy Markdown
Contributor Author

That's really nice to hear ☺️

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants