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

testscript: add Config.Files #258

Merged
merged 1 commit into from
Jun 11, 2024
Merged

Conversation

rogpeppe
Copy link
Owner

This makes it possible to pass an arbitrary set of testscript files to be run instead of just a directory, making it possible for the testscript command to pass its command line arguments directly.

In order to check that all the files are actually tested, we need to make the test harness implement independent subtest failure, and it's useful to see the name of the test too so that we can see the name disambiguation logic at work, which makes for changes to some of the other tests too.

Note that the name deduping logic is somewhat improved from similar logic in cmd/testscript, in that it is always guaranteed to produce unique names even in the presence of filenames that look like deduped names.

@rogpeppe rogpeppe requested a review from mvdan June 10, 2024 21:29
rogpeppe added a commit that referenced this pull request Jun 10, 2024
It's bugged me for a long time that the error messages printed
by the `testscript` command do not refer to the actual files
passed to the command, but instead to a temporary
file created for the purposes of the command.

This change alters the testscript command so that it
avoids creating an extra copy of the script file, instead
using the new ability of the testscript package to interpret
explicitly provided files instead.

Gratifyingly, this also simplifies the logic quite a bit.

Note: this is dependent on #258, so should not be reviewed
until that lands.
@rogpeppe rogpeppe force-pushed the 047-testscript-config-files branch from b6450f9 to 92199db Compare June 10, 2024 21:52
rogpeppe added a commit that referenced this pull request Jun 10, 2024
It's bugged me for a long time that the error messages printed
by the `testscript` command do not refer to the actual files
passed to the command, but instead to a temporary
file created for the purposes of the command.

This change alters the testscript command so that it
avoids creating an extra copy of the script file, instead
using the new ability of the testscript package to interpret
explicitly provided files instead.

Gratifyingly, this also simplifies the logic quite a bit.

Note: this is dependent on #258, so should not be reviewed
until that lands.
Copy link
Contributor

@abhinav abhinav left a comment

Choose a reason for hiding this comment

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

(Don't mind me. Just a drive-by review.)

Excellent! I've been meaning to open an issue to request something like.

Comment on lines 338 to 341
for i := 1; ; i++ {
if !names[name] {
break
}
Copy link
Contributor

Choose a reason for hiding this comment

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

optional: this can be collapsed.

Suggested change
for i := 1; ; i++ {
if !names[name] {
break
}
for i := 1; names[name]; i++ {

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

Comment on lines 13 to 18
FAIL: $WORK/y/bar.txtar:1: told to exit with code 1
** RUN bar#1#1 **
> echoandexit 1 '' 'bar#1#1 failure'
[stderr]
bar#1#1 failure
FAIL: $WORK/y/bar#1.txtar:1: told to exit with code 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
FAIL: $WORK/y/bar.txtar:1: told to exit with code 1
** RUN bar#1#1 **
> echoandexit 1 '' 'bar#1#1 failure'
[stderr]
bar#1#1 failure
FAIL: $WORK/y/bar#1.txtar:1: told to exit with code 1
FAIL: $WORK${/}y${/}bar.txtar:1: told to exit with code 1
** RUN bar#1#1 **
> echoandexit 1 '' 'bar#1#1 failure'
[stderr]
bar#1#1 failure
FAIL: $WORK${/}y${/}bar#1.txtar:1: told to exit with code 1

Copy link
Owner Author

Choose a reason for hiding this comment

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

close, but needs cmpenv. done, thanks!

@rogpeppe rogpeppe force-pushed the 047-testscript-config-files branch 2 times, most recently from 9bd33c2 to 699fae6 Compare June 11, 2024 07:56
@@ -136,6 +137,11 @@ type Params struct {
// Dir is interpreted relative to the current test directory.
Dir string

// Files holds a set of script files. If Dir is empty and this
Copy link
Collaborator

Choose a reason for hiding this comment

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

say filenames to be clearer?

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

This makes it possible to pass an arbitrary set of testscript
files to be run instead of just a directory, making it possible
for the testscript command to pass its command line arguments
directly.

In order to check that all the files are actually tested, we need
to make the test harness implement independent subtest failure,
and it's useful to see the name of the test too so that we
can see the name disambiguation logic at work, which
makes for changes to some of the other tests too.

Note that the name deduping logic is somewhat improved from
similar logic in cmd/testscript, in that it is always guaranteed
to produce unique names even in the presence of filenames
that look like deduped names.
@rogpeppe rogpeppe force-pushed the 047-testscript-config-files branch from 699fae6 to f01ab65 Compare June 11, 2024 08:12
@rogpeppe rogpeppe merged commit b143f3f into master Jun 11, 2024
6 checks passed
rogpeppe added a commit that referenced this pull request Jun 11, 2024
It's bugged me for a long time that the error messages printed
by the `testscript` command do not refer to the actual files
passed to the command, but instead to a temporary
file created for the purposes of the command.

This change alters the testscript command so that it
avoids creating an extra copy of the script file, instead
using the new ability of the testscript package to interpret
explicitly provided files instead.

Gratifyingly, this also simplifies the logic quite a bit.

Note: this is dependent on #258, so should not be reviewed
until that lands.
rogpeppe added a commit that referenced this pull request Jun 11, 2024
It's bugged me for a long time that the error messages printed
by the `testscript` command do not refer to the actual files
passed to the command, but instead to a temporary
file created for the purposes of the command.

This change alters the testscript command so that it
avoids creating an extra copy of the script file, instead
using the new ability of the testscript package to interpret
explicitly provided files instead.

Gratifyingly, this also simplifies the logic quite a bit.

Note: this is dependent on #258, so should not be reviewed
until that lands.
rogpeppe added a commit that referenced this pull request Jun 11, 2024
It's bugged me for a long time that the error messages printed
by the `testscript` command do not refer to the actual files
passed to the command, but instead to a temporary
file created for the purposes of the command.

This change alters the testscript command so that it
avoids creating an extra copy of the script file, instead
using the new ability of the testscript package to interpret
explicitly provided files instead.

Gratifyingly, this also simplifies the logic quite a bit.

Note: this is dependent on #258, so should not be reviewed
until that lands.
rogpeppe added a commit that referenced this pull request Jun 11, 2024
It's bugged me for a long time that the error messages printed
by the `testscript` command do not refer to the actual files
passed to the command, but instead to a temporary
file created for the purposes of the command.

This change alters the testscript command so that it
avoids creating an extra copy of the script file, instead
using the new ability of the testscript package to interpret
explicitly provided files instead.

Gratifyingly, this also simplifies the logic quite a bit.

Note: this is dependent on #258, so should not be reviewed
until that lands.
dmathieu referenced this pull request in open-telemetry/opentelemetry-go-contrib Sep 24, 2024
…#6147)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/rogpeppe/go-internal](https://redirect.github.com/rogpeppe/go-internal)
| `v1.12.0` -> `v1.13.1` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2frogpeppe%2fgo-internal/v1.13.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2frogpeppe%2fgo-internal/v1.13.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2frogpeppe%2fgo-internal/v1.12.0/v1.13.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2frogpeppe%2fgo-internal/v1.12.0/v1.13.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>rogpeppe/go-internal
(github.com/rogpeppe/go-internal)</summary>

###
[`v1.13.1`](https://redirect.github.com/rogpeppe/go-internal/releases/tag/v1.13.1)

[Compare
Source](https://redirect.github.com/rogpeppe/go-internal/compare/v1.13.0...v1.13.1)

#### What's Changed

- testscript: fix ptyName() returning /dev/pts/4294967296 on s390x by
[@&#8203;anthonyfok](https://redirect.github.com/anthonyfok) in
[https://github.com/rogpeppe/go-internal/pull/246](https://redirect.github.com/rogpeppe/go-internal/pull/246)
- all: Move away from ioutil by
[@&#8203;abhinav](https://redirect.github.com/abhinav) in
[https://github.com/rogpeppe/go-internal/pull/248](https://redirect.github.com/rogpeppe/go-internal/pull/248)
- testscript/doc: add `go` to the list of testscript commands by
[@&#8203;rudifa](https://redirect.github.com/rudifa) in
[https://github.com/rogpeppe/go-internal/pull/249](https://redirect.github.com/rogpeppe/go-internal/pull/249)
- testscript: Add Chdir method to change directory by
[@&#8203;abhinav](https://redirect.github.com/abhinav) in
[https://github.com/rogpeppe/go-internal/pull/247](https://redirect.github.com/rogpeppe/go-internal/pull/247)
- testscript: add kill command by
[@&#8203;kortschak](https://redirect.github.com/kortschak) in
[https://github.com/rogpeppe/go-internal/pull/243](https://redirect.github.com/rogpeppe/go-internal/pull/243)
- testscript: clarify HOME and TMPDIR env var names by
[@&#8203;mvdan](https://redirect.github.com/mvdan) in
[https://github.com/rogpeppe/go-internal/pull/240](https://redirect.github.com/rogpeppe/go-internal/pull/240)
- all: Add Go 1.22, drop Go 1.20 by
[@&#8203;abhinav](https://redirect.github.com/abhinav) in
[https://github.com/rogpeppe/go-internal/pull/252](https://redirect.github.com/rogpeppe/go-internal/pull/252)
- update dependencies and rely on Go 1.21 APIs by
[@&#8203;mvdan](https://redirect.github.com/mvdan) in
[https://github.com/rogpeppe/go-internal/pull/256](https://redirect.github.com/rogpeppe/go-internal/pull/256)
- cmd/testscript: remove redundant use of Failed by
[@&#8203;rogpeppe](https://redirect.github.com/rogpeppe) in
[https://github.com/rogpeppe/go-internal/pull/257](https://redirect.github.com/rogpeppe/go-internal/pull/257)
- testscript: add Config.Files by
[@&#8203;rogpeppe](https://redirect.github.com/rogpeppe) in
[https://github.com/rogpeppe/go-internal/pull/258](https://redirect.github.com/rogpeppe/go-internal/pull/258)
- cmd/testscript: do not create an extra temporary directory by
[@&#8203;rogpeppe](https://redirect.github.com/rogpeppe) in
[https://github.com/rogpeppe/go-internal/pull/259](https://redirect.github.com/rogpeppe/go-internal/pull/259)
- Fix typos discovered by codespell by
[@&#8203;cclauss](https://redirect.github.com/cclauss) in
[https://github.com/rogpeppe/go-internal/pull/262](https://redirect.github.com/rogpeppe/go-internal/pull/262)
- testscript: ignore result when interrupting background processes by
[@&#8203;mvdan](https://redirect.github.com/mvdan) in
[https://github.com/rogpeppe/go-internal/pull/265](https://redirect.github.com/rogpeppe/go-internal/pull/265)
- add goproxytest testing API, forward dirhash by
[@&#8203;mvdan](https://redirect.github.com/mvdan) in
[https://github.com/rogpeppe/go-internal/pull/272](https://redirect.github.com/rogpeppe/go-internal/pull/272)
- update Go, update the README by
[@&#8203;mvdan](https://redirect.github.com/mvdan) in
[https://github.com/rogpeppe/go-internal/pull/273](https://redirect.github.com/rogpeppe/go-internal/pull/273)

#### New Contributors

- [@&#8203;anthonyfok](https://redirect.github.com/anthonyfok) made
their first contribution in
[https://github.com/rogpeppe/go-internal/pull/246](https://redirect.github.com/rogpeppe/go-internal/pull/246)
- [@&#8203;abhinav](https://redirect.github.com/abhinav) made their
first contribution in
[https://github.com/rogpeppe/go-internal/pull/248](https://redirect.github.com/rogpeppe/go-internal/pull/248)
- [@&#8203;rudifa](https://redirect.github.com/rudifa) made their first
contribution in
[https://github.com/rogpeppe/go-internal/pull/249](https://redirect.github.com/rogpeppe/go-internal/pull/249)
- [@&#8203;kortschak](https://redirect.github.com/kortschak) made their
first contribution in
[https://github.com/rogpeppe/go-internal/pull/243](https://redirect.github.com/rogpeppe/go-internal/pull/243)
- [@&#8203;cclauss](https://redirect.github.com/cclauss) made their
first contribution in
[https://github.com/rogpeppe/go-internal/pull/262](https://redirect.github.com/rogpeppe/go-internal/pull/262)

**Full Changelog**:
rogpeppe/go-internal@v1.12.0...v1.13.1

###
[`v1.13.0`](https://redirect.github.com/rogpeppe/go-internal/compare/v1.12.0...v1.13.0)

[Compare
Source](https://redirect.github.com/rogpeppe/go-internal/compare/v1.12.0...v1.13.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/open-telemetry/opentelemetry-go-contrib).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC44MC4wIiwidXBkYXRlZEluVmVyIjoiMzguODAuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiU2tpcCBDaGFuZ2Vsb2ciLCJkZXBlbmRlbmNpZXMiXX0=-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: dmathieu <42@dmathieu.com>
dmathieu referenced this pull request in open-telemetry/opentelemetry-go Sep 25, 2024
…#5835)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/rogpeppe/go-internal](https://redirect.github.com/rogpeppe/go-internal)
| `v1.12.0` -> `v1.13.1` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2frogpeppe%2fgo-internal/v1.13.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2frogpeppe%2fgo-internal/v1.13.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2frogpeppe%2fgo-internal/v1.12.0/v1.13.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2frogpeppe%2fgo-internal/v1.12.0/v1.13.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>rogpeppe/go-internal
(github.com/rogpeppe/go-internal)</summary>

###
[`v1.13.1`](https://redirect.github.com/rogpeppe/go-internal/releases/tag/v1.13.1)

[Compare
Source](https://redirect.github.com/rogpeppe/go-internal/compare/v1.13.0...v1.13.1)

#### What's Changed

- testscript: fix ptyName() returning /dev/pts/4294967296 on s390x by
[@&#8203;anthonyfok](https://redirect.github.com/anthonyfok) in
[https://github.com/rogpeppe/go-internal/pull/246](https://redirect.github.com/rogpeppe/go-internal/pull/246)
- all: Move away from ioutil by
[@&#8203;abhinav](https://redirect.github.com/abhinav) in
[https://github.com/rogpeppe/go-internal/pull/248](https://redirect.github.com/rogpeppe/go-internal/pull/248)
- testscript/doc: add `go` to the list of testscript commands by
[@&#8203;rudifa](https://redirect.github.com/rudifa) in
[https://github.com/rogpeppe/go-internal/pull/249](https://redirect.github.com/rogpeppe/go-internal/pull/249)
- testscript: Add Chdir method to change directory by
[@&#8203;abhinav](https://redirect.github.com/abhinav) in
[https://github.com/rogpeppe/go-internal/pull/247](https://redirect.github.com/rogpeppe/go-internal/pull/247)
- testscript: add kill command by
[@&#8203;kortschak](https://redirect.github.com/kortschak) in
[https://github.com/rogpeppe/go-internal/pull/243](https://redirect.github.com/rogpeppe/go-internal/pull/243)
- testscript: clarify HOME and TMPDIR env var names by
[@&#8203;mvdan](https://redirect.github.com/mvdan) in
[https://github.com/rogpeppe/go-internal/pull/240](https://redirect.github.com/rogpeppe/go-internal/pull/240)
- all: Add Go 1.22, drop Go 1.20 by
[@&#8203;abhinav](https://redirect.github.com/abhinav) in
[https://github.com/rogpeppe/go-internal/pull/252](https://redirect.github.com/rogpeppe/go-internal/pull/252)
- update dependencies and rely on Go 1.21 APIs by
[@&#8203;mvdan](https://redirect.github.com/mvdan) in
[https://github.com/rogpeppe/go-internal/pull/256](https://redirect.github.com/rogpeppe/go-internal/pull/256)
- cmd/testscript: remove redundant use of Failed by
[@&#8203;rogpeppe](https://redirect.github.com/rogpeppe) in
[https://github.com/rogpeppe/go-internal/pull/257](https://redirect.github.com/rogpeppe/go-internal/pull/257)
- testscript: add Config.Files by
[@&#8203;rogpeppe](https://redirect.github.com/rogpeppe) in
[https://github.com/rogpeppe/go-internal/pull/258](https://redirect.github.com/rogpeppe/go-internal/pull/258)
- cmd/testscript: do not create an extra temporary directory by
[@&#8203;rogpeppe](https://redirect.github.com/rogpeppe) in
[https://github.com/rogpeppe/go-internal/pull/259](https://redirect.github.com/rogpeppe/go-internal/pull/259)
- Fix typos discovered by codespell by
[@&#8203;cclauss](https://redirect.github.com/cclauss) in
[https://github.com/rogpeppe/go-internal/pull/262](https://redirect.github.com/rogpeppe/go-internal/pull/262)
- testscript: ignore result when interrupting background processes by
[@&#8203;mvdan](https://redirect.github.com/mvdan) in
[https://github.com/rogpeppe/go-internal/pull/265](https://redirect.github.com/rogpeppe/go-internal/pull/265)
- add goproxytest testing API, forward dirhash by
[@&#8203;mvdan](https://redirect.github.com/mvdan) in
[https://github.com/rogpeppe/go-internal/pull/272](https://redirect.github.com/rogpeppe/go-internal/pull/272)
- update Go, update the README by
[@&#8203;mvdan](https://redirect.github.com/mvdan) in
[https://github.com/rogpeppe/go-internal/pull/273](https://redirect.github.com/rogpeppe/go-internal/pull/273)

#### New Contributors

- [@&#8203;anthonyfok](https://redirect.github.com/anthonyfok) made
their first contribution in
[https://github.com/rogpeppe/go-internal/pull/246](https://redirect.github.com/rogpeppe/go-internal/pull/246)
- [@&#8203;abhinav](https://redirect.github.com/abhinav) made their
first contribution in
[https://github.com/rogpeppe/go-internal/pull/248](https://redirect.github.com/rogpeppe/go-internal/pull/248)
- [@&#8203;rudifa](https://redirect.github.com/rudifa) made their first
contribution in
[https://github.com/rogpeppe/go-internal/pull/249](https://redirect.github.com/rogpeppe/go-internal/pull/249)
- [@&#8203;kortschak](https://redirect.github.com/kortschak) made their
first contribution in
[https://github.com/rogpeppe/go-internal/pull/243](https://redirect.github.com/rogpeppe/go-internal/pull/243)
- [@&#8203;cclauss](https://redirect.github.com/cclauss) made their
first contribution in
[https://github.com/rogpeppe/go-internal/pull/262](https://redirect.github.com/rogpeppe/go-internal/pull/262)

**Full Changelog**:
rogpeppe/go-internal@v1.12.0...v1.13.1

###
[`v1.13.0`](https://redirect.github.com/rogpeppe/go-internal/compare/v1.12.0...v1.13.0)

[Compare
Source](https://redirect.github.com/rogpeppe/go-internal/compare/v1.12.0...v1.13.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/open-telemetry/opentelemetry-go).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC44MC4wIiwidXBkYXRlZEluVmVyIjoiMzguODAuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiU2tpcCBDaGFuZ2Vsb2ciLCJkZXBlbmRlbmNpZXMiXX0=-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: dmathieu <damien.mathieu@elastic.co>
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.

3 participants