Gerrit Bot has uploaded this change for review.
debug: respect go test flags usage
The `go test` require the package list appear before any flag unknown to the `go test` command.
But `vscode-go` constructs arguments for the go test call with `testify` that doesn't respect the usage.
This PR fixes this problem by filling in the package list first.
Fixes: #1831
Change-Id: Ic2804cc1d061445ddcd95f8217282141627df778
GitHub-Last-Rev: fe6720d3b8ec55927db1a3df38bb44438afde503
GitHub-Pull-Request: golang/vscode-go#2428
---
M src/testUtils.ts
1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/src/testUtils.ts b/src/testUtils.ts
index e9a43b5..4df9e0b 100644
--- a/src/testUtils.ts
+++ b/src/testUtils.ts
@@ -427,11 +427,14 @@
addJSONFlag: boolean | undefined; // true if we add extra -json flag for stream processing.
} {
const args: Array<string> = ['test'];
+ const outArgs:Array<string> = ['test']; // command to show
// user-specified flags
const argsFlagIdx = testconfig.flags?.indexOf('-args') ?? -1;
const userFlags = argsFlagIdx < 0 ? testconfig.flags : testconfig.flags.slice(0, argsFlagIdx);
const userArgsFlags = argsFlagIdx < 0 ? [] : testconfig.flags.slice(argsFlagIdx);
+ args.push(...targets);
+
// flags to limit test time
if (testconfig.isBenchmark) {
args.push('-benchmem', '-run=^$');
@@ -469,21 +472,12 @@
// all other test run/benchmark flags
args.push(...targetArgs(testconfig));
- const outArgs = args.slice(0); // command to show
-
// if user set -v, set -json to emulate streaming test output
const addJSONFlag = (userFlags.includes('-v') || testconfig.goTestOutputConsumer) && !userFlags.includes('-json');
if (addJSONFlag) {
args.push('-json'); // this is not shown to the user.
}
- if (targets.length > 4) {
- outArgs.push('<long arguments omitted>');
- } else {
- outArgs.push(...targets);
- }
- args.push(...targets);
-
// ensure that user provided flags are appended last (allow use of -args ...)
// ignore user provided -run flag if we are already using it
if (args.indexOf('-run') > -1) {
@@ -491,10 +485,16 @@
}
args.push(...userFlags);
- outArgs.push(...userFlags);
-
args.push(...userArgsFlags);
- outArgs.push(...userArgsFlags);
+
+ // build outArgs
+ if (targets.length > 4) {
+ outArgs.push('<long arguments omitted>');
+ } else {
+ outArgs.push(...targets);
+ }
+
+ outArgs.push(...args.slice(targets.length + 1));
return {
args,
To view, visit change 425835. To unsubscribe, or for help writing mail filters, visit settings.
Congratulations on opening your first change. Thank you for your contribution!
Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.
Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.
Attention is currently required from: Hyang-Ah Hana Kim, Jamal Carvalho, Suzy Mueller.
Gerrit Bot uploaded patch set #2 to this change.
debug: respect go test flags usage
The `go test` require the package list appear before any flag unknown to the `go test` command.
But `vscode-go` constructs arguments for the go test call with `testify` that doesn't respect the usage.
This PR fixes this problem by filling in the package list first.
Fixes: [#1831](https://github.com/golang/vscode-go/issues/1831)
Change-Id: Ic2804cc1d061445ddcd95f8217282141627df778
GitHub-Last-Rev: fe6720d3b8ec55927db1a3df38bb44438afde503
GitHub-Pull-Request: golang/vscode-go#2428
---
M src/testUtils.ts
1 file changed, 29 insertions(+), 12 deletions(-)
To view, visit change 425835. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Suzy Mueller.
Patch set 2:Run-TryBot +1
Attention is currently required from: Hyang-Ah Hana Kim, Suzy Mueller.
Kokoro presubmit build finished with status: FAILURE
Logs at: https://source.cloud.google.com/results/invocations/2f3a2a0f-2c8f-42dc-87fc-35ad4ea6cd9a
Patch set 2:TryBot-Result -1
Attention is currently required from: Hyang-Ah Hana Kim, Suzy Mueller.
1 comment:
Patchset:
This would require updates to `/test/integration/test.test.ts`
```
8 failing
1) Test Go Test Args
default config:
AssertionError [ERR_ASSERTION]: actual command
+ expected - actual
-test ./... -timeout 30s
+test -timeout 30s ./...
2) Test Go Test Args
user flag [-v] enables -json flag:
AssertionError [ERR_ASSERTION]: actual command
+ expected - actual
-test ./... -timeout 30s -json -v
+test -timeout 30s -json ./... -v
3) Test Go Test Args
user flag [-json -v] prevents -json flag addition:
AssertionError [ERR_ASSERTION]: actual command
+ expected - actual
-test ./... -timeout 30s -json -v
+test -timeout 30s ./... -json -v
4) Test Go Test Args
user flag [-args] does not crash:
AssertionError [ERR_ASSERTION]: actual command
+ expected - actual
-test ./... -timeout 30s -args
+test -timeout 30s ./... -args
5) Test Go Test Args
user flag [-args -v] does not enable -json flag:
AssertionError [ERR_ASSERTION]: actual command
+ expected - actual
-test ./... -timeout 30s -args -v
+test -timeout 30s ./... -args -v
6) Test Go Test Args
specifying functions adds -run flags:
AssertionError [ERR_ASSERTION]: actual command
+ expected - actual
-test ./... -timeout 30s -run ^(TestA|TestB)$
+test -timeout 30s -run ^(TestA|TestB)$ ./...
7) Test Go Test Args
functions & benchmark adds -bench flags and skips timeout:
AssertionError [ERR_ASSERTION]: actual command
+ expected - actual
-test ./... -benchmem -run=^$ -bench ^(TestA|TestB)$
+test -benchmem -run=^$ -bench ^(TestA|TestB)$ ./...
8) Test Go Test Args
user -run flag is ignored when functions are provided:
AssertionError [ERR_ASSERTION]: actual command
+ expected - actual
-test ./... -timeout 30s -run ^(TestA|TestB)$
+test -timeout 30s -run ^(TestA|TestB)$ ./...
```
To view, visit change 425835. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Jamal Carvalho, Suzy Mueller.
Gerrit Bot uploaded patch set #3 to this change.
The following approvals got outdated and were removed: Run-TryBot+1 by Jamal Carvalho, TryBot-Result-1 by kokoro
debug: respect go test flags usage
The `go test` require the package list appear before any flag unknown to the `go test` command.
But `vscode-go` constructs arguments for the go test call with `testify` that doesn't respect the usage.
This PR fixes this problem by filling in the package list first.
Fixes: [#1831](https://github.com/golang/vscode-go/issues/1831)
Change-Id: Ic2804cc1d061445ddcd95f8217282141627df778
GitHub-Last-Rev: dd931e4023241e9168636822d72ecf33c00e3cd3
GitHub-Pull-Request: golang/vscode-go#2428
---
M src/testUtils.ts
M test/integration/test.test.ts
2 files changed, 45 insertions(+), 28 deletions(-)
To view, visit change 425835. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Jamal Carvalho, Suzy Mueller.
Patch set 3:Run-TryBot +1
Attention is currently required from: Jamal Carvalho, Suzy Mueller.
Kokoro presubmit build finished with status: FAILURE
Logs at: https://source.cloud.google.com/results/invocations/4ef79603-c794-4a3b-81b9-037bdd2dd747
Patch set 3:TryBot-Result -1
Attention is currently required from: Hyang-Ah Hana Kim, Jamal Carvalho, Suzy Mueller.
2 comments:
Patchset:
This would require updates to `/test/integration/test.test.ts` […]
Thank you. I have added the modifications to the test code.
Patchset:
Please help review my code again. Thank you.
To view, visit change 425835. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Jamal Carvalho, Suzy Mueller.
Gerrit Bot uploaded patch set #4 to this change.
The following approvals got outdated and were removed: Run-TryBot+1 by Hyang-Ah Hana Kim, TryBot-Result-1 by kokoro
debug: respect go test flags usage
The `go test` require the package list appear before any flag unknown to the `go test` command.
But `vscode-go` constructs arguments for the go test call with `testify` that doesn't respect the usage.
This PR fixes this problem by filling in the package list first.
Fixes: [#1831](https://github.com/golang/vscode-go/issues/1831)
Change-Id: Ic2804cc1d061445ddcd95f8217282141627df778
GitHub-Last-Rev: 42ec3e852d1540786c0091692ce0668e5fc131bc
GitHub-Pull-Request: golang/vscode-go#2428
---
M src/testUtils.ts
M test/integration/test.test.ts
2 files changed, 45 insertions(+), 28 deletions(-)
To view, visit change 425835. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Jamal Carvalho, Suzy Mueller.
1 comment:
Patchset:
I didn't notice an error in the original unit test, which has been fixed. Please help review again. Thank you.
To view, visit change 425835. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Suzy Mueller.
Patch set 4:Run-TryBot +1
Attention is currently required from: Hyang-Ah Hana Kim, Suzy Mueller.
Kokoro presubmit build finished with status: FAILURE
Logs at: https://source.cloud.google.com/results/invocations/b9782042-27cf-4c72-b039-03bd2ae738e6
Patch set 4:TryBot-Result -1
Attention is currently required from: Hyang-Ah Hana Kim, Jamal Carvalho, Suzy Mueller.
Gerrit Bot uploaded patch set #5 to this change.
The following approvals got outdated and were removed: Run-TryBot+1 by Jamal Carvalho, TryBot-Result-1 by kokoro
debug: respect go test flags usage
The `go test` require the package list appear before any flag unknown to the `go test` command.
But `vscode-go` constructs arguments for the go test call with `testify` that doesn't respect the usage.
This PR fixes this problem by filling in the package list first.
Fixes: [#1831](https://github.com/golang/vscode-go/issues/1831)
Change-Id: Ic2804cc1d061445ddcd95f8217282141627df778
GitHub-Last-Rev: 98a9bdb777b44fe3e34de12888140eaad1ea8c7a
GitHub-Pull-Request: golang/vscode-go#2428
---
M src/testUtils.ts
M test/integration/test.test.ts
2 files changed, 45 insertions(+), 28 deletions(-)
To view, visit change 425835. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Jamal Carvalho, Suzy Mueller.
1 comment:
Patchset:
Fixed code style issues. Thanks again for your review.
To view, visit change 425835. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Suzy Mueller.
1 comment:
Patchset:
Small lint failure. Please run prettier or add the formatting fix to testUtils.ts.
```
/workspace/src/testUtils.ts
430:16 error Insert `·` prettier/prettier
✖ 1 problem (1 error, 0 warnings)
1 error and 0 warnings potentially fixable with the `--fix` option.
```
To view, visit change 425835. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Jamal Carvalho, Suzy Mueller.
1 comment:
Patchset:
Small lint failure. Please run prettier or add the formatting fix to testUtils.ts. […]
Hi Jamal, I have fixed this error, does it happen again?
To view, visit change 425835. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Jamal Carvalho, Suzy Mueller.
1 comment:
Patchset:
Hi Jamal, I have fixed this error, does it happen again?
https://go-review.googlesource.com/c/vscode-go/+/425835/4..5/src/testUtils.ts#430
This is my fix record.
To view, visit change 425835. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Suzy Mueller.
Patch set 5:Run-TryBot +1
Attention is currently required from: Hyang-Ah Hana Kim, Suzy Mueller.
Kokoro presubmit build finished with status: SUCCESS
Logs at: https://source.cloud.google.com/results/invocations/00e33dfe-207f-4046-9cbb-1a3691ef327a
Patch set 5:TryBot-Result +1
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |