129 Commits

Author SHA1 Message Date
Veikka Tuominen
b2aedb0709
Merge pull request #12796 from Vexu/referenced-by-v2
stage2: add referenced by trace to compile errors attempt #2 (+ some fixes)
2022-09-16 23:49:00 +03:00
Andrew Kelley
85b10eb07c ZIG_EXE envirnoment variable instead of testing build options
No longer introduce build options for tests. Instead, ZIG_EXE
environment variable is added to any invocation of `zig run` or `zig
test`.

The end result of this branch is the same: there is no longer a
mandatory positional command line argument when invoking zig test
binaries directly.
2022-09-14 14:56:45 -07:00
Veikka Tuominen
31daea74d2 stage2: implement referenced by trace for error messages
Closes #7668
Closes #12141
2022-09-15 00:50:18 +03:00
Martin Wickham
5523e2061b Move std.testing.zig_exe_path into build options 2022-09-14 14:42:58 -07:00
Andrew Kelley
9e070b653c
Merge pull request #12788 from ziglang/detect-native-glibc
std.zig.system.NativeTargetInfo: improve glibc version and dynamic linker detection
2022-09-09 12:28:25 -04:00
Andrew Kelley
3ee01c14ee std.zig.system.NativeTargetInfo: detection ignores self exe
Before, native glibc and dynamic linker detection attempted to use the
executable's own binary if it was dynamically linked to answer both the
C ABI question and the dynamic linker question. However, this could be
problematic on a system that uses a RUNPATH for the compiler binary,
locking it to an older glibc version, while system binaries such as
/usr/bin/env use a newer glibc version. The problem is that libc.so.6
glibc version will match that of the system while the dynamic linker
will match that of the compiler binary. Executables with these versions
mismatching will fail to run.

Therefore, this commit changes the logic to be the same regardless of
whether the compiler binary is dynamically or statically linked. It
inspects `/usr/bin/env` as an ELF file to find the answer to these
questions, or if there is a shebang line, then it chases the referenced
file recursively. If that does not provide the answer, then the function
falls back to defaults.

This commit also solves a TODO to remove an Allocator parameter to the
detect() function.
2022-09-08 20:52:49 -07:00
Jakub Konka
0e152b76ac tests: force LLD off for stage2 backends until auto-select deems worthy 2022-09-07 23:16:42 +02:00
Jakub Konka
a226aef36c test-cases: enable stage2 tests on Windows 2022-09-07 22:42:59 +02:00
Andrew Kelley
507aae4a1a make self-hosted the default compiler
stage1 is available behind the -fstage1 flag.

closes #89
2022-08-19 16:45:15 -07:00
Andrew Kelley
150786e83c test harness: fix handling of object format
Follow-up to b975f7a56fec9e0e7aca9832282bc772c743d731.
2022-08-18 22:02:55 -07:00
Andrew Kelley
9f1f60fd43 test-cases: remove multi-threading
This effectively reverts 22690efcc2378222503cb8aaad26a6f4a539f5aa,
re-opening #11818.

This had the following problems:
 * Buggy on some targets (macOS, Windows)
 * Messy output to the terminal

These problems need to be solved before moving forward with this.
2022-08-11 00:46:44 -07:00
Andrew Kelley
20c230cda9 test-cases harness: annotate an optional type
Not sure why this is needed by the CI; it's not needed locally. This is
a mystery that will have to wait for another day.
2022-07-27 02:13:01 -07:00
Andrew Kelley
acf1aa10c2 test-cases harness: refresh just before update()
This makes it so that in a -Dsingle-threaded build of test-cases, if a
crash happens, the test case name will be printed just before the stderr
of the crash.
2022-07-26 20:11:52 -07:00
Andrew Kelley
4e53249d76 test-cases harness: improve stage2 compatibility
* proper skip_stage1 mechanism that doesn't get side-stepped with
   manually added test cases.
 * avoid runtime-known function pointers.
 * check for type equality more simply without checking the type name.
2022-07-26 20:09:48 -07:00
Andrew Kelley
f50c98a75a test-cases harness: test all updates
even if some are "run" on foreign hosts.

closes #12193
2022-07-26 13:28:46 -07:00
r00ster
cff5d9c805
std.mem: add first method to SplitIterator and SplitBackwardsIterator 2022-07-25 22:04:30 +03:00
Veikka Tuominen
262f4c7b3a std.fs: remove OpenDirOptions.iterate 2022-07-15 14:39:21 +03:00
Veikka Tuominen
2b67f56c35 std.fs: split Dir into IterableDir
Also adds safety check for attempting to iterate directory not opened with `iterate = true`.
2022-07-15 13:04:21 +03:00
r00ster91
da75eb0d79
Compilation: indent multiline error messages properly
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-07-12 00:10:39 +03:00
Jakub Konka
6420e9350c test: return error on unknown config value 2022-06-28 13:28:05 +02:00
Andrew Kelley
0e9458a3fc test-cases: avoid using realpath since it is not portable
For example FreeBSD does not support this syscall.
2022-06-14 22:15:22 -07:00
Andrew Kelley
8caa206417 test-cases: fix race with zig run on C backend tests
Also avoid redundantly doing compile-error checks on multiple targets
for test cases where that is not helpful.
2022-06-14 15:27:43 -07:00
Andrew Kelley
22690efcc2 multi-thread zig build test-cases
Instead of always using std.testing.allocator, the test harness now follows
the same logic as self-hosted for choosing an allocator - that is - it
uses C allocator when linking libc, std.testing.allocator otherwise, and
respects `-Dforce-gpa` to override the decision. I did this because
I found GeneralPurposeAllocator to be prohibitively slow when doing
multi-threading, even in the context of a debug build.

There is now a second thread pool which is used to spawn each
test case. The stage2 tests are passed the first thread pool. If it were
only multi-threading the stage1 tests then we could use the same thread
pool for everything. However, the problem with this strategy with stage2
is that stage2 wants to spawn tasks and then call wait() on the main
thread. If we use the same thread pool for everything, we get a deadlock
because all the threads end up all hanging at wait() and nothing is
getting done. So we use our second thread pool to simulate a "process pool"
of sorts.

I spent most of the time working on this commit scratching my head trying
to figure out why I was getting ETXTBSY when spawning the test cases.
Turns out it's a fundamental Unix design flaw, already a known, unsolved
issue by Go and Java maintainers:

https://github.com/golang/go/issues/22315
https://bugs.openjdk.org/browse/JDK-8068370

With this change, the following command, executed on my laptop, went from
6m24s to 1m44s:

```
stage1/bin/zig build test-cases -fqemu -fwasmtime -Denable-llvm
```

closes #11818
2022-06-14 17:15:13 -04:00
Andrew Kelley
bc36da0cb8 test harness: fix handling of counts
I'm not really happy with parsing compile errors; I think we should just
be checking that the expected compile error matches the actual rendered
version. I will save that change for a later date however.
2022-06-09 15:37:16 -07:00
Andrew Kelley
93d7fd9547 test harness: fix sort comparator
It was returning "true" for lessThan() when the objects were in fact
equal.
2022-06-08 15:17:53 -07:00
Jakub Konka
d1e4600675 test: correctly track identical error msgs in handled errors list
Prior to this change, for an example compiler error test case with
multiple identical errors messages such as

```
:1:2: error: foo
:1:2: error: foo
```

the test harness would never increment the error index thus only
marking the very first error message as handled yielding a false
positive.

Additionally, while here, regress `dereference_anyopaque` test case
as not passing on `wasm32-wasi` target.
2022-05-26 16:23:56 +02:00
Luuk de Gram
5138856a72 test harness: Set filename on error return
While calling `next` an error can occur while parsing the file.
However, we don't set the filename that is currently being processed, until `next` completed successfully.
This means that for invalid test names, the wrong filename was being displayed in the panic message.
The fix is to retrieve the correct filename when an error occurs and then setting the filename appropriately.
2022-05-15 09:30:59 +02:00
Andrew Kelley
7d8b90b905 test harness: actually run the stage1 "run" tests 2022-05-13 17:32:23 -07:00
Andrew Kelley
b986fcfc99 test-cases: honor -Dtest-filter argument from zig build 2022-05-13 14:31:02 -07:00
Andrew Kelley
915032715f test harness: dump stderr when compiler crashes 2022-05-13 14:03:20 -07:00
Andrew Kelley
66f3efb63b migrate runtime safety tests to the new test harness
* migrate runtime safety tests to the new test harness
   - this required adding compare output / execution support for stage1
     to the test harness.
 * rename `zig build test-stage2` to `zig build test-cases` since it now
   does quite a bit of stage1 testing actually. I named it this way
   since the main directory in the source tree associated with these
   tests is "test/cases/".
 * add some documentation for the test manifest format.
2022-05-13 14:03:20 -07:00
Jakub Konka
3624e1ef48 test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
Jakub Konka
9d79b740bc test: improve test batch/sequence iterator
With this improved iterator, type of test is now inferred from
the filename, enabling us to put all cases in one common parent
directory, and iterate over that, thus automating a lot of tasks.
2022-05-04 23:21:35 +02:00
Jakub Konka
f648a1b043 test: regression fix: skip stage1 if not enabled 2022-05-02 21:22:07 -04:00
Jakub Konka
d25f06a71c test: remove redundant codepaths from test harness 2022-04-28 18:35:01 +02:00
Jakub Konka
62625d9d95 test: migrate stage1 compile error tests to updated test manifest 2022-04-28 18:35:01 +02:00
Jakub Konka
c8d0fb0b21 test: migrate stage2 independent compile errors to test manifest parser 2022-04-28 18:35:01 +02:00
Jakub Konka
2cd456f8f4 test: correctly handle multiple backends
To correctly handle multiple backends crossed with multiple targets,
we need to push all elements in separate allocated arrays rather
than operate on raw iterators. Hence, introduce `getConfigForKeyAlloc`.
2022-04-28 18:35:01 +02:00
Jakub Konka
815dc2c6e7 test: enable wasm32-wasi incremental tests 2022-04-28 18:35:01 +02:00
Jakub Konka
8d5acf7693 test: recursively walk dir with tests
Prune incremental tests by moving non-incremental behavior tests to
behavior test suite instead.
2022-04-28 18:35:01 +02:00
Jakub Konka
97b781955e test: fix incorrect default target spec; port all incremental tests 2022-04-28 18:35:01 +02:00
Jakub Konka
133708d939 test: leave a todo note to explicitly specify ABI for targets in the future 2022-04-28 18:35:01 +02:00
Jakub Konka
81e90c7acb test: fix pointer invalidation bug in the harness 2022-04-28 18:35:01 +02:00
Jakub Konka
c1a98cd65d test: set case name from initial filename for a sequence
Port more incremental tests.
2022-04-28 18:35:01 +02:00
Jakub Konka
46db5e2a44 test: unroll into multiple cases, provide default parsers
Provide default parsers for obvious config options such as
`CrossTarget` or `Backend` (or any enum for that matter).

Unroll iterator loops into multiple cases - we need to create
a Cartesian product for all possibilities specified in the
test manifest.
2022-04-28 18:35:01 +02:00
Jakub Konka
bc370311cb test: add comptime struct holding default config values 2022-04-28 18:35:01 +02:00
Jakub Konka
f41dd3617e test: pass Strategy per directory of tests 2022-04-28 18:35:01 +02:00
Jakub Konka
d305a6fb55 test: parse all of manifest in TestManifest abstraction 2022-04-28 18:35:01 +02:00
Jakub Konka
d8d12d51ec test: abstract away test manifest parser into separate struct 2022-04-28 18:35:01 +02:00
Cody Tapscott
aaac8eae68 Use 0-indexing for incremental compile error tests 2022-04-13 01:09:21 -04:00