Граф коммитов

94 коммитов

Автор SHA1 Сообщение Дата
Dan Kegel
69d7ed5cda os: define ErrDeadlineExceeded; fixes go 1.18 compile error in net/http, #2782 2022-04-19 09:22:27 +02:00
Dan Kegel
0590ccb260 gofmt exec_posix.go 2022-04-18 22:52:14 +02:00
Dan Kegel
c78df85015 os: Implement Pipe for darwin, add smoke test.
Evidently when you read from pipes in Go, you have to adjust your slice length to reflect the number of bytes read.
Verified upstream behaves the same way.
2022-04-08 08:29:30 +02:00
Elliott Sales de Andrade
42ae9a665f os: Add some exec.ProcessState stubs 2022-03-17 12:33:59 +01:00
ZauberNerd
6fb90b6fc4 src/os: Add UserHomeDir() function to os package
This commit adds the `UserHomeDir()` function to the `os` package.
2022-03-16 22:19:05 +01:00
ZauberNerd
6f31712b7d test: write into a temp file and read from its fd
This test creates a new temp file and writes some bytes into it.
It then opens a new file for the file descriptor of the temp file and
tries to read some bytes out of it.
2022-03-16 15:40:04 +01:00
ZauberNerd
e295770363 test: simple test to verify os.File.Fd() is working 2022-03-16 15:40:04 +01:00
ZauberNerd
486b99961d src/os: implement os.File.Fd() method
This commits adds a OS-specific `Fd()` function for `file_anyos.go` and
`file_other.go`, which returns a uintptr to the underlying file
descriptor.
2022-03-16 15:40:04 +01:00
Elliott Sales de Andrade
5d4f795aec Add an empty os.Process.Signal implementation
This fixes compile of tests in Go 1.18, due to its use in
`src/internal/testenv/testenv.go`.
2022-03-13 12:53:23 +01:00
Elliott Sales de Andrade
db8603e378 Add os Signal aliases
These are used in Go 1.18's `testing/internal/testdeps`. Though the
comment says they should exist _everywhere_, there is still a build
constraint, but that seems to be fine.
2022-03-13 12:53:23 +01:00
ZauberNerd
3f69c32a55 src/os: export correct values for os.DevNull for each OS
This commit introduces `os.DevNull` exports for all supported OS
targets.
2022-03-08 14:49:14 +01:00
ZauberNerd
0243a5b8be src/os: add stubs for exec.ExitError and ProcessState.ExitCode
This commit adds stubs for the `ExitError` struct of the `exec` package
and `ProcessState.ExitCode()` of the `os` package.

Since the `os/exec` is listed as unsupported, stubbing these methods
and structs should be enough to get programs that use these to compile.
2022-03-08 06:45:53 +01:00
Elliott Sales de Andrade
a680bfbb7a os: Use a uintptr for NewFile
This appears to have been how it is upstream for about 10 years. Using
an interface breaks if a file descriptor number is passed directly to
`NewFile`, e.g., `NewFile(3, "fuzz_in")` as used in Go 1.18 fuzzing
code.
2022-03-01 14:01:40 +01:00
Damian Gryski
bf23839931 src/os,src/syscall: move env copy code to syscall.Environ() 2022-03-01 11:44:39 +01:00
Damian Gryski
6b15a72895 src/os: add back TestClearenv
Removed as flaky in #2603
2022-03-01 11:44:39 +01:00
Damian Gryski
08fd49fe60 src/os: make Environ() return a copy of the environment
Fixes #2646
2022-03-01 11:44:39 +01:00
Dan Kegel
f962e2fd15 github: also run 'make tinygo-test' on mac 2022-02-21 05:18:27 +01:00
Dan Kegel
e9d9ae8781 os: disable TestClearenv for now, it is very flaky. Also reduce verbosity. 2022-02-20 13:46:48 +01:00
Dan Kegel
47a622a903 Implement os.RemoveAll()
TODO: enable test on windows once Readdir is implemented there
2022-02-18 04:47:19 +01:00
Ayke van Laethem
77ec9b6369 all: update build constraints to Go 1.17
Do it all at once in preparation for Go 1.18 support.

To make this commit, I've simply modified the `fmt-check` Makefile
target to rewrite files instead of listing the differences. So this is a
fully mechanical change, it should not have introduced any errors.
2022-02-04 07:49:46 +01:00
Dan Kegel
aa8e0bb509 os: isWine: be compatible with older versions of wine, too
Turns out wine 5.x doesn't export WINEUSERNAME.
2022-02-03 19:12:19 +01:00
Dan Kegel
98a6ed8059 os: add DirFS, which is used by many programs to access readdir.
It's wafer-thin :-)

Includes smoke test from upstream.

TODO: once t.TempDir is implemented, add io/fs to the list of standard library tests to run; that's a better test.
2022-02-02 08:57:49 +01:00
Dan Kegel
641a7e5cb9 os: implement readdir for darwin and linux
readdir is disabled on linux for 386 and arm until syscall.seek is implemented there.

windows is hard, so leaving that for later.

File src/os/dir_other_go115.go can be deleted when we drop support for go 1.15.

Also adds TestReadNonDir, which was helpful while debugging.
2022-02-02 08:57:49 +01:00
Dan Kegel
a29e1d43f1 Kludge: provide stub for syscall.seek on 386 and arm, #1906
This replaces an earlier kludge which was at the wrong level
and caused "GOARCH=386 tinygo test os" to fail to compile on linux.

Stubbing just the one missing function, syscall.seek, lets
os tests compile on linux 386, and skipping tests of seek and Fstat
(which has a cryptic dependency on syscall.Seek via time)
lets os tests pass on linux 386.

The stub can be removed once tinygo implements go assembly and picks up the real definition.
2022-01-24 18:23:40 +01:00
Dan Kegel
ee663ccb96 Revert "Kludge: work around lack of syscall.seek on 386 and arm, #1906"
This reverts commit 60b483bd3b.
2022-01-24 18:23:40 +01:00
Dan Kegel
9c3f9537be os: add stubs for Readlink and File.Seek for baremetal targets, with smoke test.
Test currently enabled on pybadge (chosen at random)

TODO:
- enable test on arduino; currently fails with "interp: ptrtoint integer size..." (#2389)
- enable test on nintendoswitch; currently fails with many missing definitions (#2530)
2022-01-21 07:39:47 +01:00
Dan Kegel
60b483bd3b Kludge: work around lack of syscall.seek on 386 and arm, #1906
Revert this once syscall.seek is implemented
cf. https://github.com/tinygo-org/tinygo/issues/1906
2022-01-20 11:14:41 +01:00
Damian Gryski
322abf6d22 src/{syscall, os}: add File.Stat, with smoke test
This is File.Stat from https://github.com/tinygo-org/tinygo/pull/2371,
plus the windows bits,
plus a smoke test more or less from upstream,
all pulled together and rebased by dkegel-fastly.
2022-01-20 11:14:41 +01:00
Dan Kegel
57b8f7e667 os: implement os.Symlink and os.Readlink 2022-01-18 12:36:33 +01:00
Dan Kegel
db0efc52c7 os: implement os.ExpandEnv 2022-01-18 10:12:40 +01:00
Nia Waldvogel
6afceb5621 os (wasi): fix opening files in read-only mode
On wasi, O_RDWR is a bitwise or of read and write mode.
As a result, the bit test result was incorrect, and rewrote it to read-write mode.
However, the bit tests are not necessary (and upstream Go does not use them).
This passes the flags through directly.
2022-01-15 10:26:19 -05:00
Dan Kegel
998f01608c os: implement file.Seek, add smoke test 2022-01-11 14:23:14 +01:00
Dan Kegel
29f7ebc63e os: pull in os.Rename and some of its tests from upstream
Skip part of the test on Windows because of https://github.com/tinygo-org/tinygo/issues/2480

TODO: fix 2480 and unskip test
TODO: pull in rest of upstream tests, fix problems they find

Requested in https://github.com/tinygo-org/tinygo/issues/2109
2022-01-11 09:58:38 +01:00
Dan Kegel
ec97313239 When running tests under wasmtime, provide a fresh TMPDIR.
Also fix a couple os tests that wrote to current directory to write to os.TempDir() instead.

After this, os tests pass in wasi, so add them to the list run by "make tinygo-test-wasi".
2022-01-04 21:43:38 +01:00
Dan Kegel
61be9189f1 os: add a few upstream tests for Read and ReadAt, fix problems they exposed.
There are more upstream tests to pull in, but this is plenty for today.
2022-01-04 15:45:49 +01:00
Damian Gryski
1e2791b216 src/os: loop in File.ReadAt to handle short reads
This matches what upstream Go does.  This also means len(b) == 0 successfully
reads 0 bytes without any extra logic.  The tests in archive/zip test for this
behaviour.
2022-01-04 15:45:49 +01:00
Nia Waldvogel
c685e0696a os: add Perm stub on Go 1.15
This adds a stub for Perm on Go 1.15, which allows the OS package to compile again.
2021-12-26 16:04:19 -05:00
Dan Kegel
62bda8e129 os: os_chmod_test.go: fix copyright 2021-12-16 16:36:53 -05:00
Dan Kegel
51d6ffb3be os: Chmod: don't test on wasi yet, wasi-libc does not yet support it
Lets "tinygo test -target wasi os" compile, if not pass.

For https://github.com/tinygo-org/tinygo/issues/2369
2021-12-16 16:36:53 -05:00
Dan Kegel
929cd767c1 os/path_windows_test.go: don't fail on Wine, which allows dots for cur dir even in extended length paths 2021-12-15 12:23:28 +01:00
Dan Kegel
75dfb26452 os: skip TestMkdirTempBadDir on windows until TestStatBadDir passes 2021-12-14 09:25:27 +01:00
Dan Kegel
971da0bc09 os: implement and test os.MkdirTemp 2021-12-14 09:25:27 +01:00
Dan Kegel
0420842f4d os: skip TestStatBadPath on windows for now
I'm not up enough on how syscall errors work on windows to figure this out yet.
2021-12-14 09:25:27 +01:00
Dan Kegel
d30f8b6ed6 os.Stat: returned error on nonexistent path did not satisfy IsNotExist
Add direct test for the problem to make the fix commit clearer.

Noticed while implementing MkdirTemp on mac; the upstream tests for MkdirTemp fail without this.
2021-12-14 09:25:27 +01:00
Dan Kegel
1f6b4a5e7b os_test.go: use CreateTemp now that it is implemented 2021-12-14 09:25:27 +01:00
Dan Kegel
51fc78c100 os: implement and smoketest os.Clearenv 2021-12-13 23:05:17 +01:00
Dan Kegel
e4f2b9c003 os: implement and smoketest os.Unsetenv 2021-12-13 23:05:17 +01:00
Dan Kegel
cff4493ca0 os: implement and smoketest os.Setenv 2021-12-13 23:05:17 +01:00
Dan Kegel
039186a2a3 src/os/stat.go: get build tags right, maybe
Should fix https://github.com/tinygo-org/tinygo/issues/2354

Untested with wasi
2021-12-09 22:14:29 +01:00
Dan Kegel
be7bbba4ca os: implement and smoketest os.Chmod 2021-12-07 10:54:02 +01:00