Ben Krieger
ed0fb774b9
Add testing.T.Context() and testing.B.Context()
2025-11-05 10:33:15 +01:00
Ayke van Laethem
bc77922d47
testing: stub out testing.B.Loop
...
This gets the path package tests to pass, so we can move ahead with Go
1.25. It should be implemented in the future at some point (that, or
we'll use the upstream testing package instead).
2025-08-06 17:08:26 +02:00
Ayke van Laethem
c180d6fe2f
testing: add Chdir
...
This method was added in Go 1.24.
2025-02-25 14:41:42 +01:00
Ayke van Laethem
a6cd072fa1
Revert "fix: implement testing {Skip,Fail}Now"
...
This reverts commit c5879c682c .
It doesn't look like this is working (see
https://github.com/tinygo-org/tinygo/pull/4736#issuecomment-2679670226 ),
and it doesn't have any tests anyway to prove that it does work. So I
think it's best to revert it for now and add a working implementation
with tests in the future.
2025-02-25 12:38:52 +01:00
leongross
c5879c682c
fix: implement testing {Skip,Fail}Now
...
PR https://github.com/tinygo-org/tinygo/pull/4623 implements
runtime.GoExit() with which we can improve the testing package
and align it more to upstream testing behavour https://cs.opensource.google/go/go/+/refs/tags/go1.24.0:src/testing/testing.go;l=1150
Signed-off-by: leongross <leon.gross@9elements.com >
2025-02-15 21:30:22 +01:00
Laurent Demailly
61d36fb3f8
Add missing T.Deadline
2024-07-23 22:23:35 +02:00
Damian Gryski
9cb263479c
wasi preview 2 support ( #4027 )
...
* all: wasip2 support
Co-authored-by: Randy Reddig <randy.reddig@fastly.com >
2024-07-02 07:02:03 -07:00
Randy Reddig
8bd0155c51
os, testing: just check runtime.GOOS == "wasip1"
2024-03-27 16:01:40 +01:00
Randy Reddig
8e8ad9004f
all: replace target=wasi with target=wasip1
...
This eliminates the 'wasi' build tag in favor of 'GOOS=wasip1', introduced in Go 1.21.
For backwards compatablity, -target=wasi is a synonym for -target=wasip1.
2024-03-27 16:01:40 +01:00
Ayke van Laethem
a545f17d2e
wasm: add support for GOOS=wasip1
...
This adds true GOOS=wasip1 support in addition to our existing
-target=wasi support. The old support for WASI isn't removed, but should
be treated as deprecated and will likely be removed eventually to reduce
the test burden.
2023-08-17 18:16:54 +02:00
Ayke van Laethem
c25dd0a972
testing: add Testing function
...
This is new in Go 1.21.
2023-08-04 11:59:11 +02:00
Damian Gryski
2b1dc4fee5
testing: add -test.shuffle to order randomize test and benchmark order
2023-04-12 20:43:41 +02:00
Damian Gryski
1672610749
testing: move runtime.GC() call to runN to match upstream
2023-04-11 12:16:25 +02:00
Damian Gryski
e00a2395d9
testing: fix benchmark logging output
2023-04-11 12:16:25 +02:00
Damian Gryski
8badf79af9
testing: remove unused variable left over from count prototyping
2023-03-31 19:17:02 -07:00
Damian Gryski
63aaa43072
testing: add test.skip
...
Fixes #3056
2023-03-31 19:17:02 -07:00
Damian Gryski
ee81c31884
testing: import new version of match.go
2023-03-31 19:17:02 -07:00
Damian Gryski
9182664845
testing: make test output unbuffered when verbose
...
Fixes #3579
2023-03-31 09:07:13 +02:00
Damian Gryski
698b1f19c6
testing: support -test.count
...
This makes running benchmarks repeatedly easier.
2023-03-31 09:07:13 +02:00
Ayke van Laethem
33489d6344
testing: implement t.Setenv
...
This method has been added in Go 1.17 and is used in archive/zip
starting with Go 1.20. Therefore, this method is now needed in Go 1.20.
I've left out the parts that disable parallel execution of tests,
because we don't do that in TinyGo.
See:
* https://github.com/golang/go/issues/41260
* https://go-review.googlesource.com/c/go/+/260577
2023-01-15 11:48:05 +01:00
Yurii Soldak
8d4d3c6201
build: drop deprecated build tags
2022-12-19 23:20:11 +01:00
Fred Goya
b734b3c7a1
Print PASS on pass when running standalone test binaries ( #3229 )
...
* Add test.batch flag so standalone tests print PASS on pass
* Add comment; use single-dash flag style to match usage elsewhere
* Don't add test.batch for wasmtime
* Skip test.batch unless emulator name is blank
* Remove test.batch flag; buffer test output and show only on verbose or failure
* Remove FAIL when all tests fail to match go test output
2022-10-19 09:46:43 +02:00
Ayke van Laethem
4695da83b7
all: drop support for Go 1.16 and Go 1.17
2022-08-30 12:38:06 +02:00
Damian Gryski
c4d99e5297
src/testing: add support for -benchmem
2022-08-20 11:41:20 +02:00
Damian Gryski
f12ddfe164
all: update _test.go files for os.IsFoo changes
2022-08-07 10:32:23 +02:00
Damian Gryski
a2704f1435
all: move from os.IsFoo to errors.Is(err, ErrFoo)
2022-08-07 10:32:23 +02:00
Ayke van Laethem
c7a23183e8
all: format code according to Go 1.19 rules
...
Go 1.19 started reformatting code in a way that makes it more obvious
how it will be rendered on pkg.go.dev. It gets it almost right, but not
entirely. Therefore, I had to modify some of the comments so that they
are formatted correctly.
2022-08-04 12:18:32 +02:00
Elliott Sales de Andrade
9cedd78d9c
Add a shim for internal/fuzz
...
This simply shadows the real code temporarily to see what else is
broken. It only defines a single type to fix testing/internal/testdeps.
2022-04-09 09:16:37 +02:00
Dan Kegel
c534fa1b6f
On baremetal platforms, use simpler test matcher. Fixes #2666 .
...
Uses same matcher in testdata (because now we can't replace it in testdata).
2022-03-15 05:59:00 +01:00
Dan Kegel
31a3a7c84b
os: testTempDir: now that we have os.ReadDir, bring back one use of it in a test
2022-02-24 12:35:40 -05:00
Dan Kegel
a9a225ba26
testing: nudge type TB closer to upstream; should be a no-op change.
2022-02-24 12:35:40 -05:00
Dan Kegel
b24af78327
testing: implement testing.TempDir
...
TODO: enable test on windows and wasi once os.Readdir and os.RemoveAll are implemented there
2022-02-24 12:35:40 -05:00
Dan Kegel
dd6adcacb6
testing: --run now allows filtering of subtests
...
Also fix typo in error message in sub_test.go from upstream,
and move a few members from B to common where they belonged.
Note that testdata/testing.go seems to be pushing the edge of what
the emulated cortex-m3 target can handle; using regexp in that test
causes it to fail on that target with an out of memory error.
TODO: once tinygo supports runtime.Goexit, consider just using upstream's testing directory...
2022-01-17 21:54:20 +01:00
Dan Kegel
610a20c4d5
testing.go: hoist runTests() out of Run() to match upstream a bit better
...
Only trivial functional changes:
- gets rid of mistaken extra "no tests" warning (whoops)
- matches upstream's exit code better
In preparation for switching to fancy test filtering.
2022-01-17 21:54:20 +01:00
Dan Kegel
0ed34e3cb0
testing: print duration
...
TODO: account for time taken in Cleanup().
2022-01-15 10:38:22 +01:00
Dan Kegel
78a36f7724
testing: nudge functions closer to upstream order, to make diffing easier. No functional change.
2022-01-15 10:38:22 +01:00
Dan Kegel
21c76c0cb0
testing: benchmarks: implement -benchtime flag
2022-01-12 21:49:27 +01:00
Dan Kegel
fbd72a4b2c
testing: benchmarks: -bench: allow filtering subbenchmarks
...
Pull in testing/match.go verbatim from upstream and use it to filter benchmarks.
TODO: also update testing.go to filter tests similarly.
2022-01-12 21:49:27 +01:00
Dan Kegel
ef77b645b9
testing: implement testing.Cleanup
...
Also reorder and regroup common's fields slightly to match upstream.
TODO: pull in more upstream tests once this package is goroutine-safe
2022-01-12 08:59:09 +01:00
Dan Kegel
0b939f93bc
testing: gather duplicate code into tRunner
...
No change in behavior, just preparing for next commit, and gently nudging code closer to upstream.
2022-01-12 08:59:09 +01:00
Dan Kegel
a888d6245d
testing: replace spaces with underscores in test/benchmark names, as upstream does
2022-01-11 11:53:24 +01:00
Dan Kegel
f80efa5b8b
testing: support b.SetBytes(); implement sub-benchmarks.
2022-01-11 11:53:24 +01:00
Dan Kegel
ee4e42ba1f
src/testing: support -bench option to run benchmarks matching the given pattern.
2022-01-07 10:39:30 +01:00
Dan Kegel
c6678525a9
src/testing/benchmark.go: reorder functions to make diffing against go easier
...
On the theory that tinygo is tending towards smaller diffs with go...
Also adds placeholder for ReportAllocs(), otherwise zero semantic changes.
2022-01-07 10:39:30 +01:00
Damian Gryski
343146f35c
src/testing: stub b.RunParallel() and PB.Next()
2021-12-06 20:09:36 +01:00
Damian Gryski
a536ddcda8
tinygo: support -run for tests
...
Fixes #2294
2021-11-24 17:27:11 +01:00
Damian Gryski
9d87d658ba
testing: add a stub for CoverMode
...
This allows the strings package test to compile.
2021-11-20 00:36:42 +01:00
Damian Gryski
7273a2b5fd
src/testing stub AllocsPerRun
2021-11-17 19:25:52 +01:00
Damian Gryski
2e6b92fc56
src/testing: add testing.Verbose()
2021-11-17 19:25:52 +01:00
Damian Gryski
a88530b785
src/testing: stub B.ReportAllocs()
...
This allows test packages that use this feature in their benchmarks
to build and run (if not the benchmarks themselves).
2021-10-16 01:49:25 +02:00