aboutsummaryrefslogtreecommitdiff
path: root/src/embed/internal/embedtest/embed_test.go
AgeCommit message (Collapse)Author
2024-07-24crypto/x509,embed: use slices to clean up testsapocelipes
Replace reflect.DeepEqual with slices.Equal, which is much faster. Change-Id: Ia93cc153d1f71ce92656129843be8dadcefbbca3 GitHub-Last-Rev: 0af0cc4205f51b31780ca2cbefe780e7256b1188 GitHub-Pull-Request: golang/go#67610 Reviewed-on: https://go-review.googlesource.com/c/go/+/587817 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org> Commit-Queue: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-04-14embed/internal/embedtest: test openFile.ReadAt with non-zero offsetTobias Klauser
Also fix log messages to report expected values in the standard "got foo, want bar" format. Change-Id: I6a9fd4abe1f86c2651c72c2bf7ac4588028e5923 Reviewed-on: https://go-review.googlesource.com/c/go/+/484715 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2023-04-12embed: implement openFile.ReadAtNuno Cruces
Implementation copied from testing/fstest/mapfs.go Fixes #57803 Change-Id: I531682b50ab6663511bac41fce7614ab9197bf38 GitHub-Last-Rev: d9bcc1c0bf4d339edcdabaf4d4d67b848ad8818d GitHub-Pull-Request: golang/go#59489 Reviewed-on: https://go-review.googlesource.com/c/go/+/483235 Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com>
2021-12-13all: gofmt -w -r 'interface{} -> any' srcRuss Cox
And then revert the bootstrap cmd directories and certain testdata. And adjust tests as needed. Not reverting the changes in std that are bootstrapped, because some of those changes would appear in API docs, and we want to use any consistently. Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories when preparing the bootstrap copy. A few files changed as a result of running gofmt -w not because of interface{} -> any but because they hadn't been updated for the new //go:build lines. Fixes #49884. Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09 Reviewed-on: https://go-review.googlesource.com/c/go/+/368254 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-11-11go/build: skip rune literals when looking for go:embedIan Lance Taylor
Fixes #49514 Change-Id: Id687eead731ba49974f11d2e5b489f11eff7d07b Reviewed-on: https://go-review.googlesource.com/c/go/+/363275 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-26embed/internal/embedtest: use parenthesized vars for one testIan Lance Taylor
The gofrontend code mishandled this case, so add it to the test. Change-Id: I183b8fab57552320b04c4826c590b7c6d36b6548 Reviewed-on: https://go-review.googlesource.com/c/go/+/358836 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2021-08-25cmd/compile: allow embed into any byte slice typekorzhao
Fixes #47735 Change-Id: Ia21ea9a67f36a3edfef1b299ae4f3b00c306cd68 Reviewed-on: https://go-review.googlesource.com/c/go/+/342851 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Alexander Rakoczy <alex@golang.org>
2021-05-04embed/internal/embedtest: add test for embedded path starting with dashIan Lance Taylor
Fixes #45447 Change-Id: I1b1a0a844ee4345ced1a007bbe53db035183175f Reviewed-on: https://go-review.googlesource.com/c/go/+/311529 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-01-19embed: treat uninitialized FS as emptyJay Conrod
As described in the FS documentation. This prevents http.FS and other clients from panicking when the go:embed directive is missing. For #43682 Related #43698 Change-Id: Iecf26d229a099e55d24670c3119cd6c6d17ecc6e Reviewed-on: https://go-review.googlesource.com/c/go/+/283852 Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-01-15cmd/compile: disallow embed of var inside funcRuss Cox
Allowing embedding into []byte inside a func creates an unfortunate problem: either all calls start with the same underlying data and can see each other's changes to the underlying data (surprising and racy!) or all calls start by making their own copy of the underlying data (surprising and expensive!). After discussion on #43216, the consensus was to remove support for all vars embedded inside functions. Fixes #43216. Change-Id: I01e62b5f0dcd9e8566c6d2286218e97803f54704 Reviewed-on: https://go-review.googlesource.com/c/go/+/282714 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-12-04io/fs: add SubRuss Cox
Sub provides a convenient way to refer to a subdirectory automatically in future operations, like Unix's chdir(2). The CL also includes updates to fstest to check Sub implementations. As part of updating fstest, I changed the meaning of TestFS's expected list to introduce a special case: if you list no expected files, that means the FS must be empty. In general it's OK not to list all the expected files, but if you list none, that's almost certainly a mistake - if your FS were broken and empty, you wouldn't find out. Making no expected files mean "must be empty" makes the mistake less likely - if your file system ever worked, then your test will keep it working. That change found a testing bug: embedtest was making exactly that mistake. Fixes #42322. Change-Id: I63fd4aa866b30061a0e51ca9a1927e576d6ec41e Reviewed-on: https://go-review.googlesource.com/c/go/+/274856 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-04cmd/go, embed: exclude .* and _* from embedded directory treesRuss Cox
Discussion on #42328 led to a decision to exclude files matching .* and _* from embedded directory results when embedding an entire directory tree. This CL implements that new behavior. Fixes #42328. Change-Id: I6188994e96348b3449c7d9d3d0d181cfbf2d4db1 Reviewed-on: https://go-review.googlesource.com/c/go/+/275092 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-29cmd/go: add //go:embed supportRuss Cox
The final piece of //go:embed support: have the go command stitch together parsing in go/build, low-level data initialization in cmd/compile, and the new data structures in package embed, to make the //go:embed feature actually function. And test, now that all the pieces are available to work together. For #41191. (Issue not fixed: still need to add a tool for use by Bazel.) Change-Id: Ib1d198345c3b4d557d340f292eda13b984b65d65 Reviewed-on: https://go-review.googlesource.com/c/go/+/243945 Trust: Russ Cox <rsc@golang.org> Trust: Jay Conrod <jayconrod@google.com> Trust: Johan Brandhorst <johan.brandhorst@gmail.com> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com> Reviewed-by: Johan Brandhorst <johan.brandhorst@gmail.com>