aboutsummaryrefslogtreecommitdiffhomepage
path: root/main_test.go
AgeCommit message (Collapse)Author
2024-11-18ci: run at least some tests on older Go/LLVM versionsAyke van Laethem
These should make sure basic functionality is still working. Using the `-short` flag to avoid taking too long to run all tests (and to install all the necessary emulators), and because some targets might not work in older Go/LLVM versions (such as WASI). This does _not_ run tests and checks against expected IR, because LLVM IR changes a lot across versions.
2024-11-08wasm: correctly return from run() in wasm_exec.jsAyke van Laethem
Instead of hanging forever, it should return the exit code from os.Exit.
2024-11-01test: show output even when a test binary didn't exit cleanlyAyke van Laethem
This was a problem on wasm, where node would exit with a non-zero exit code when there was a panic.
2024-11-01test: run TestWasmExportJS tests in parallelAyke van Laethem
2024-10-23runtime: add support for os/signalAyke van Laethem
This adds support for enabling and listening to signals on Linux and MacOS.
2024-10-19wasm: add test for js.FuncOfAyke van Laethem
While there are some browser tests, Node.js is just a lot better for testing this kind of stuff because it's much faster and we don't need a browser for this.
2024-10-18wasm: add //go:wasmexport support to js/wasmAyke van Laethem
This adds support for //go:wasmexport with `-target=wasm` (in the browser). This follows the //go:wasmexport proposal, meaning that blocking functions are not allowed. Both `-buildmode=default` and `-buildmode=c-shared` are supported. The latter allows calling exported functions after `go.run()` has returned.
2024-10-18main_test: refactor output comparison into separate functionAyke van Laethem
This shouldn't affect anything, just make the code a bit better (especially for the next commit).
2024-10-04wasm: add `//go:wasmexport` support (#4451)Ayke
This adds support for the `//go:wasmexport` pragma as proposed here: https://github.com/golang/go/issues/65199 It is currently implemented only for wasip1 and wasm-unknown, but it is certainly possible to extend it to other targets like GOOS=js and wasip2.
2024-10-02TestWebAssembly: use wasm-unknown for panic=trap testDamian Gryski
2024-09-05reflect: support big-endian systemsAyke van Laethem
The reflect package needs to know the endianness of the system in a few places. Before this patch, it assumed little-endian systems. But with GOARCH=mips we now have a big-endian system which also needs to be supported. So this patch fixes the reflect package to work on big-endian systems. Also, I've updated the tests for MIPS: instead of running the little-endian tests, I've changed it to run the big-endian tests instead. The two are very similar except for endianness so this should be fine. To be sure we won't accidentally break little-endian support, I've kept a single MIPS little-endian test (the CGo test, which doesn't yet work on big-endian systems anyway).
2024-09-05interp: support big-endian targetsAyke van Laethem
The interp package was assuming that all targets were little-endian. But that's not true: we now have a big-endian target (GOARCH=mips). This fixes the interp package to use the appropriate byte order for a given target.
2024-08-22mips: fix big-endian (GOARCH=mips) supportAyke van Laethem
I made an awkward mistake, mixing up GOOS and GOARCH. So here is a fix, with an associated test.
2024-08-17ci: use Go 1.23Ayke van Laethem
2024-08-17compiler: add support for Go 1.23 range-over-funcAyke van Laethem
2024-08-12mips: add GOMIPS=softfloat supportAyke van Laethem
Previously, the compiler would default to hardfloat. This is not supported by some MIPS CPUs. This took me much longer than it should have because of a quirk in the LLVM Mips backend: if the target-features string is not set (like during LTO), the Mips backend picks the first function in the module and uses that. Unfortunately, in the case of TinyGo this first function is `llvm.dbg.value`, which is an LLVM intrinsic and doesn't have the target-features string. I fixed it by adding a `-mllvm -mattr=` flag to the linker.
2024-08-11builder: interpret linker error messagesAyke van Laethem
This shows nicely formatted error messages for missing symbol names and for out-of-flash, out-of-RAM conditions (on microcontrollers with limited flash/RAM). Unfortunately the missing symbol name errors aren't available on Windows and WebAssembly because the linker doesn't report source locations yet. This is something that I could perhaps improve in LLD.
2024-07-22all: add linux/mipsle supportAyke van Laethem
This adds linux/mipsle (little endian Mips) support to TinyGo. It also adds experimental linux/mips (big-endian) support. It doesn't quite work yet, some parts of the standard library (like the reflect package) currently seem to assume a little-endian system.
2024-07-20diagnostics: move diagnostic printing to a new packageAyke van Laethem
This is a refactor, which should (in theory) not change the behavior of the compiler. But since this is a pretty large change, there is a chance there will be some regressions. For that reason, the previous commits added a bunch of tests to make sure most error messages will not be changed due to this refactor.
2024-07-13all: add testing for compiler error messagesAyke van Laethem
This is needed for some improvements I'm going to make next. This commit also refactors error handling slightly to make it more easily testable, this should hopefully not result in any actual changes in behavior.
2024-07-08main_test: Diff expected and actual results when tests fail (#4288)L. Pereira
Uses a vendored "internal/diff" from Big Go to show the differences between the expected and actual outputs when tests fail. Signed-off-by: L. Pereira <[email protected]>
2024-07-02wasi preview 2 support (#4027)Damian Gryski
* all: wasip2 support Co-authored-by: Randy Reddig <[email protected]>
2024-06-28test: support GOOS/GOARCH pairs in the -target flagAyke van Laethem
This means it's possible to test just a particular OS/arch with a command like this: go test -run=Build -target=linux/arm I found it useful while working on MIPS support.
2024-03-27all: change references of 'wasi' to 'wasip1'; test hygieneRandy Reddig
2024-03-19all: move -panic=trap support to the compiler/runtimeAyke van Laethem
Support for `-panic=trap` was previously a pass in the optimization pipeline. This change moves it to the compiler and runtime, which in my opinion is a much better place. As a side effect, it also fixes https://github.com/tinygo-org/tinygo/issues/4161 by trapping inside runtime.runtimePanicAt and not just runtime.runtimePanic. This change also adds a test for the list of imported functions. This is a more generic test where it's easy to add more tests for WebAssembly file properties, such as exported functions.
2024-01-19loader: make sure Go version is plumbed throughAyke van Laethem
This fixes the new loop variable behavior in Go 1.22. Specifically: * The compiler (actually, the x/tools/go/ssa package) now correctly picks up the Go version. * If a module doesn't specify the Go version, the current Go version (from the `go` tool and standard library) is used. This fixes `go run`. * The tests in testdata/ that use a separate directory are now actually run in that directory. This makes it possible to use a go.mod file there. * There is a test to make sure old Go modules still work with the old Go behavior, even on a newer Go version.
2024-01-18compiler: update golang.org/x/tools/go/ssa packageAyke van Laethem
This update includes support for the new range loops over integers.
2023-08-17wasm: add support for GOOS=wasip1Ayke van Laethem
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-04compiler: add min and max builtin supportAyke van Laethem
2023-03-31main: stuff test runner options into their own structDamian Gryski
Fixes #2406
2023-02-26ci: add AVR timers testAyke van Laethem
Add the timers test because they now work correctly on AVR, probably as a result of the reflect refactor: https://github.com/tinygo-org/tinygo/pull/2640 I've also updated a few of the other tests to indicate the new status and why they don't work. It's no longer because of compiler errors, but because of linker or runtime errors (which is at least some progress). For example, I found that testdata/reflect.go works if you disable `testAppendSlice` and increase the stack size.
2023-01-15test: print package name when compilation failedAyke van Laethem
Before this patch, a compile error would prevent the 'ok' or 'FAIL' line to be printed. That's unexpected. This patch changes the code in such a way that it's obvious a test result line is printed in all cases. To be able to also print the package name, I had to make sure the build result is passed through everywhere even on all the failure paths. This results in a bit of churn, but it's all relatively straightforward. Found while working on Go 1.20.
2022-11-25all: re-enable AVR testsAyke van Laethem
I have some confidence they'll work reliably now.
2022-11-25avr: add channel testAyke van Laethem
It is working now, so add it as a test. Not sure why, maybe the ThinLTO change fixed something here?
2022-08-30all: drop support for Go 1.16 and Go 1.17Ayke van Laethem
2022-08-23runtime: add support for time.NewTimer and time.NewTickerKenneth Bell
This commit adds support for time.NewTimer and time.NewTicker. It also adds support for the Stop() method on time.Timer, but doesn't (yet) add support for the Reset() method. The implementation has been carefully written so that programs that don't use these timers will normally not see an increase in RAM or binary size. None of the examples in the drivers repo change as a result of this commit. This comes at the cost of slightly more complex code and possibly slower execution of the timers when they are used.
2022-08-20src/testing: add support for -benchmemDamian Gryski
2022-08-20make interp timeout configurable from command lineDamian Gryski
2022-08-09Fix skip message for missing emulatorsElliott Sales de Andrade
2022-08-07all: update _test.go files for ioutil changesDamian Gryski
2022-06-19avr: add support for recover()Ayke van Laethem
You can see that it works with the following command: tinygo run -target=simavr ./testdata/recover.go This also gets the following tests to pass again: go test -run=Build -target=simavr -v Adding support for AVR was a bit more compliated because it's also necessary to save and restore the Y register.
2022-06-16compiler: implement recover() built-in functionAyke van Laethem
2022-06-11compiler: add support for type parameters (aka generics)Ayke van Laethem
...that was surprisingly easy.
2022-06-11fix: fixes tinygo test ./... syntax.José Carlos Chávez
2022-05-30all: add support for the embed packageAyke van Laethem
2022-05-18avr: enable testdata/map.goAyke van Laethem
The test needs a few changes to support low-memory devices but other than that, it works fine.
2022-05-18avr: use compiler-rtAyke van Laethem
This change adds support for compiler-rt, which supports float64 (unlike libgcc for AVR). This gets a number of tests to pass that require float64 support. We're still using libgcc with this change, but libgcc will probably be removed eventually once AVR support in compiler-rt is a bit more mature. I've also pushed a fix for a small regression in our xtensa_release_14.0.0-patched LLVM branch that has also been merged upstream. Without it, a floating point comparison against zero always returns true which is certainly a bug. It is necessary to correctly print floating point values.
2022-05-18avr: get `go test -target=simavr` to workAyke van Laethem
This patch changes two things: 1. It changes the default stack size. Without this change, the goroutine.go test doesn't pass (apparently there's some memory corruption). 2. It moves the excluded tests so that they are skipped with a regular `-target=simavr`, not just when running all tests (without `-target`).
2022-04-28testdata: move map growth test to map.goDamian Gryski
2022-04-28testdata: add test for mapgrowth logicDamian Gryski