Skip to content

Commit

Permalink
internal/txtar: bring back to main repo, for tests in std
Browse files Browse the repository at this point in the history
This used to be cmd/go/internal/txtar,
and then it was moved to golang.org/x/tools/txtar
and revendored from there into cmd/vendor/golang.org/x/tools/txtar.

We have a use for txtar in a new test in the standard library,
which cannot access cmd/vendor. But we also don't really want
to vendor it into the standard library as is, because that would
be the first vendoring of x/tools in std, and it would be better
to keep std separate from x/tools, even for testing.

Instead, since a little copying is better than a little dependency,
just make a copy in internal/txtar. The package does not change.

Having done that, replace the uses in cmd/go so that there's
only one copy in the main repo.

Change-Id: I70b5cc05da3f6ebcc0fd9052ebcb3d369fb57956
Reviewed-on: https://go-review.googlesource.com/c/go/+/384254
Trust: Russ Cox <[email protected]>
Run-TryBot: Russ Cox <[email protected]>
Reviewed-by: Bryan Mills <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
  • Loading branch information
rsc committed Mar 16, 2022
1 parent 95395fd commit a3fcc75
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/cmd/go/internal/fsys/fsys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import (
"errors"
"fmt"
"internal/testenv"
"internal/txtar"
"io"
"io/fs"
"os"
"path/filepath"
"reflect"
"testing"

"golang.org/x/tools/txtar"
)

// initOverlay resets the overlay state to reflect the config.
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/go/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"errors"
"flag"
"fmt"
"internal/txtar"
"io"
"io/fs"
"log"
Expand All @@ -30,7 +31,6 @@ import (
"golang.org/x/mod/semver"
"golang.org/x/mod/sumdb"
"golang.org/x/mod/sumdb/dirhash"
"golang.org/x/tools/txtar"
)

var (
Expand Down
3 changes: 1 addition & 2 deletions src/cmd/go/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"fmt"
"go/build"
"internal/testenv"
"internal/txtar"
"io/fs"
"os"
"os/exec"
Expand All @@ -33,8 +34,6 @@ import (
"cmd/go/internal/robustio"
"cmd/go/internal/work"
"cmd/internal/sys"

"golang.org/x/tools/txtar"
)

var testSum = flag.String("testsum", "", `may be tidy, listm, or listall. If set, TestScript generates a go.sum file at the beginning of each test and updates test files if they pass.`)
Expand Down
3 changes: 1 addition & 2 deletions src/cmd/go/testdata/addmod.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ import (
"flag"
"fmt"
exec "internal/execabs"
"internal/txtar"
"io/fs"
"log"
"os"
"path/filepath"
"strings"

"golang.org/x/tools/txtar"
)

func usage() {
Expand Down
3 changes: 1 addition & 2 deletions src/cmd/go/testdata/savedir.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ package main
import (
"flag"
"fmt"
"internal/txtar"
"io/fs"
"log"
"os"
"path/filepath"
"strings"
"unicode/utf8"

"golang.org/x/tools/txtar"
)

func usage() {
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/go/testdata/script/README
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ In general script files should have short names: a few words, not whole sentence
The first word should be the general category of behavior being tested,
often the name of a go subcommand (list, build, test, ...) or concept (vendor, pattern).

Each script is a text archive (go doc cmd/go/internal/txtar).
Each script is a text archive (go doc internal/txtar).
The script begins with an actual command script to run
followed by the content of zero or more supporting files to
create in the script's temporary file system before it starts executing.
Expand Down
1 change: 0 additions & 1 deletion src/cmd/vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ golang.org/x/tools/go/types/typeutil
golang.org/x/tools/internal/analysisinternal
golang.org/x/tools/internal/lsp/fuzzy
golang.org/x/tools/internal/typeparams
golang.org/x/tools/txtar
# golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
## explicit; go 1.11
golang.org/x/xerrors
Expand Down
3 changes: 3 additions & 0 deletions src/go/build/deps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ var depsRules = `
FMT, container/heap, math/rand
< internal/trace;
FMT
< internal/txtar;
`

// listStdPkgs returns the same list of packages as "go list std".
Expand Down
File renamed without changes.

0 comments on commit a3fcc75

Please sign in to comment.