aboutsummaryrefslogtreecommitdiff
path: root/src/os/path_test.go
AgeCommit message (Collapse)Author
2025-05-21os: add Root.MkdirAllDamien Neil
For #67002 Change-Id: Idd74b5b59e787e89bdfad82171b6a7719465f501 Reviewed-on: https://go-review.googlesource.com/c/go/+/674116 Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-01-19os: clean up testsBryan C. Mills
- Use testenv.Command instead of exec.Command to try to get more useful timeout behavior. - Parallelize tests that appear not to require global state. (And add explanatory comments for a few that are not parallelizable for subtle reasons.) - Consolidate some “Helper” tests with their parent tests. - Use t.TempDir instead of os.MkdirTemp when appropriate. - Factor out subtests for repeated test helpers. For #36107. Updates #22315. Change-Id: Ic24b6957094dcd40908a59f48e44c8993729222b Reviewed-on: https://go-review.googlesource.com/c/go/+/458015 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
2022-01-02os: enable TestMkdirAllWithSymlink on darwin/arm64Tobias Klauser
Go 1.16 renamed the iOS port from darwin/arm64 to ios/arm64 and darwin/arm64 was repurposed for the macOS ARM64 port (see https://golang.org/doc/go1.16#darwin). TestMkdirAllWithSymlink ought to run on darwin/arm64, so enable it on that platform. For #45696 Change-Id: I2cad6b1dfddf215e6b6cd262bbd22251f48f3d8c Reviewed-on: https://go-review.googlesource.com/c/go/+/373359 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-09os: replace os.MkdirTemp with T.TempDirManlio Perillo
Updates #45402 Change-Id: Ib8e62a13ddff884e4d34b3a0fdc9a10db2b68da6 Reviewed-on: https://go-review.googlesource.com/c/go/+/308109 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2020-12-09all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTempRuss Cox
As part of #42026, these helpers from io/ioutil were moved to os. (ioutil.TempFile and TempDir became os.CreateTemp and MkdirTemp.) Update the Go tree to use the preferred names. As usual, code compiled with the Go 1.4 bootstrap toolchain and code vendored from other sources is excluded. ReadDir changes are in a separate CL, because they are not a simple search and replace. For #42026. Change-Id: If318df0216d57e95ea0c4093b89f65e5b0ababb3 Reviewed-on: https://go-review.googlesource.com/c/go/+/266365 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-09-23all: add GOOS=iosCherry Zhang
Introduce GOOS=ios for iOS systems. GOOS=ios matches "darwin" build tag, like GOOS=android matches "linux" and GOOS=illumos matches "solaris". Only ios/arm64 is supported (ios/amd64 is not). GOOS=ios and GOOS=darwin remain essentially the same at this point. They will diverge at later time, to differentiate macOS and iOS. Uses of GOOS=="darwin" are changed to (GOOS=="darwin" || GOOS=="ios"), except if it clearly means macOS (e.g. GOOS=="darwin" && GOARCH=="amd64"), it remains GOOS=="darwin". Updates #38485. Change-Id: I4faacdc1008f42434599efb3c3ad90763a83b67c Reviewed-on: https://go-review.googlesource.com/c/go/+/254740 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2020-04-08all: remove scattered remnants of darwin/armAustin Clements
This removes all conditions and conditional code (that I could find) that depended on darwin/arm. Fixes #35439 (since that only happened on darwin/arm) Fixes #37611. Change-Id: Ia4c32a5a4368ed75231075832b0b5bfb1ad11986 Reviewed-on: https://go-review.googlesource.com/c/go/+/227198 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-10-31os: add support for long path names on unix RemoveAllOliver Stenbom
On unix systems, long enough path names will fail when performing syscalls like `Lstat`. The current RemoveAll uses several of these syscalls, and so will fail for long paths. This can be risky, as it can let users "hide" files from the system or otherwise make long enough paths for programs to fail. By using `Unlinkat` and `Openat` syscalls instead, RemoveAll is safer on unix systems. Initially implemented for linux, darwin, dragonfly, netbsd and openbsd. Not yet implemented on freebsd due to fstatat 64-bit inode compatibility issues. Fixes #27029 Co-authored-by: Giuseppe Capizzi <gcapizzi@pivotal.io> Co-authored-by: Julia Nedialkova <yulia.nedyalkova@sap.com> Change-Id: I978a6a4986878fe076d3c7af86e7927675624a96 GitHub-Last-Rev: 9235489c81b90c228210144b7c25b28a46bb80b7 GitHub-Pull-Request: golang/go#28494 Reviewed-on: https://go-review.googlesource.com/c/146020 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-10-30Revert "os: add support for long path names on unix RemoveAll"Katie Hockman
This reverts commit 85143d355493c6bba994d49ed154b4df8b78874b. Reason for revert: Breaking all Darwin and FreeBSD builds. Trybots did not pass for this. Change-Id: I5494e14ad5ab9cf6e1e225a25b2e8b38f3359d13 Reviewed-on: https://go-review.googlesource.com/c/145897 Reviewed-by: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-30os: add support for long path names on unix RemoveAllOliver Stenbom
On unix systems, long enough path names will fail when performing syscalls like `Lstat`. The current RemoveAll uses several of these syscalls, and so will fail for long paths. This can be risky, as it can let users "hide" files from the system or otherwise make long enough paths for programs to fail. By using `Unlinkat` and `Openat` syscalls instead, RemoveAll is safer on unix systems. Initially implemented for linux, darwin, and several bsds. Fixes #27029 Co-authored-by: Giuseppe Capizzi <gcapizzi@pivotal.io> Co-authored-by: Julia Nedialkova <yulia.nedyalkova@sap.com> Change-Id: Id9fcdf4775962b021b7ff438dc51ee6d16bb5f56 GitHub-Last-Rev: b30a621fe359fa2acbb055445b54202b0c508167 GitHub-Pull-Request: golang/go#27871 Reviewed-on: https://go-review.googlesource.com/c/137442 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-11-06os: fix RemoveAll on large directories on Plan 9 and NaClDavid du Colombier
On Plan 9, some file servers, like ramfs, handle the read offset when reading directories. However, the offset isn't valid anymore after directory entries have been removed between successive calls to read. This issue happens when os.RemoveAll is called on a directory that doesn't fit on a single 9P response message. In this case, the first part of the directory is read, then directory entries are removed and the second read will be incomplete because the read offset won't be valid anymore. Consequently, the content of the directory will only be partially removed. We change RemoveAll to call fd.Seek(0, 0) before calling fd.Readdirnames, so the read offset will always be reset after removing the directory entries. After adding TestRemoveAllLarge, we noticed the same issue appears on NaCl and the same fix applies as well. Fixes #22572. Change-Id: Ifc76ea7ccaf0168c34dc8ec0f400dc04db1baf8f Reviewed-on: https://go-review.googlesource.com/75974 Run-TryBot: David du Colombier <0intro@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-23os: use testenv.MustHaveSymlink to simplify symlink testsHiroshi Ioka
Cleanup test code for symbolic links. Change-Id: I7a116e4d5c0e955578eca53c1af559e9092f60cd Reviewed-on: https://go-review.googlesource.com/27572 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-02all: single space after period.Brad Fitzpatrick
The tree's pretty inconsistent about single space vs double space after a period in documentation. Make it consistently a single space, per earlier decisions. This means contributors won't be confused by misleading precedence. This CL doesn't use go/doc to parse. It only addresses // comments. It was generated with: $ perl -i -npe 's,^(\s*// .+[a-z]\.) +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.) +([A-Z])') $ go test go/doc -update Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7 Reviewed-on: https://go-review.googlesource.com/20022 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Dave Day <djd@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-20os: disable symlink tests on android.Hyang-Ah Hana Kim
Creating symlinks (/data/local/tmp/*) doesn't seem to work on android-L (tested on nexus5). I cannot find any official documentation yet but just guess it's a measure for security attacks using symlinks. The tests failed with 'permission denied' errors. For golang/go#10807 Change-Id: I99a9c401c6ecca3c4adc7b21708adaf3dd601279 Reviewed-on: https://go-review.googlesource.com/16115 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-12os: adjust working dir for darwin/arm64 testsDavid Crawshaw
Just like darwin/arm. Change-Id: Ib64a3e8ff11249a20b0208bd3b900db318c682b7 Reviewed-on: https://go-review.googlesource.com/8817 Reviewed-by: Minux Ma <minux@golang.org> Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-03-07Fixed wrong arguments to formatting functionstnt
Change-Id: I11b4cf00ceeb4441b865e0de3f1674095d1c32d0 Reviewed-on: https://go-review.googlesource.com/7043 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-06os: do not leave /go_os_test/dir after testAlex Brainman
Change-Id: Idb8e211bf33d2713735f9cdc868a3458ce799c97 Reviewed-on: https://go-review.googlesource.com/6913 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-02-28os: fix tests on darwin/armDavid Crawshaw
Tests that fork are skipped. Tests that create files do so in a temporary directory, as the initial PWD is read-only. And darwin/arm returns a strange mkdir error when trying to write to /. Change-Id: I2de661a85524300bbac226693d72142992dc188d Reviewed-on: https://go-review.googlesource.com/6312 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-02os: fix TestMkdirAllAtSlash on Plan 9David du Colombier
Since CL 3676, the TestMkdirAllAtSlash test depends on syscall.EROFS, which isn't defined on Plan 9. This change works around this issue by defining a system dependent isReadonlyError function. Change-Id: If972fd2fe4828ee3bcb8537ea7f4ba29f7a87619 Reviewed-on: https://go-review.googlesource.com/3696 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-31os: don't silently skip testDave Cheney
This is a followup to CL 3676. Rather than silently returning from the test, a pass, use the Skip facility to mark the test as skipped. Change-Id: I90d237e770150bf8d69f14fb09874e70894a7f86 Reviewed-on: https://go-review.googlesource.com/3682 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-30os: allow EROFS in TestMkdirAllAtSlashRahul Chaudhry
On some systems (e.g. ChromeOS), / is mounted read-only. This results in error code syscall.EROFS, which I guess is just as valid as syscall.EACCES for this test. Change-Id: I9188d5437a1b5ac1daa9c68b95b8dcb447666ca3 Reviewed-on: https://go-review.googlesource.com/3676 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-09-08build: move package sources from src/pkg to srcRuss Cox
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.