Commit Graph

109 Commits

Author SHA1 Message Date
Andrew Kelley
3f6e651d5a remove tool: update-license-headers
This tool is not needed since license headers were removed in
d29871977f.
2024-01-07 17:02:17 -07:00
Abhinav Gupta
d3a163f868
build/LazyPath: Add dirname (#18371)
Adds a variant to the LazyPath union representing a parent directory
of a generated path.

```zig
const LazyPath = union(enum) {
    generated_dirname: struct {
        generated: *const GeneratedFile,
        up: usize,
    },
    // ...
}
```

These can be constructed with the new method:

```zig
pub fn dirname(self: LazyPath) LazyPath
```

For the cases where the LazyPath is already known
(`.path`, `.cwd_relative`, and `dependency`)
this is evaluated right away.
For dirnames of generated files and their dirnames,
this is evaluated at getPath time.

dirname calls can be chained, but for safety,
they are not allowed to escape outside a root
defined for each case:

- path: This is relative to the build root,
  so dirname can't escape outside the build root.
- generated: Can't escape the zig-cache.
- cwd_relative: This can be a relative or absolute path.
  If relative, can't escape the current directory,
  and if absolute, can't go beyond root (/).
- dependency: Can't escape the dependency's root directory.

Testing:
I've included a standalone case for many of the happy cases.
I couldn't find an easy way to test the negatives, though,
because tests cannot yet expect panics.
2024-01-04 18:47:28 -05:00
Andrew Kelley
2b63ba31e9 add standalone test for depending on the main module 2024-01-01 19:49:08 -07:00
Andrew Kelley
3179f58c41 rename std.zig.CrossTarget to std.Target.Query 2024-01-01 17:51:18 -07:00
Andrew Kelley
142471fcc4 zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.

The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.

* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
  std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
  std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
  `std.Build.Module.addCMacro` is provided.
  - remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
  - use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
  - use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
  Along with other fields, those unspecified options will be inherited
  from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
  to get the host target.
2024-01-01 17:51:18 -07:00
kcbanner
53500a5768 sema: fixup underflows during struct / ptr array init when using -fstrip 2023-11-12 18:22:57 -05:00
Andrew Kelley
1302274910 move two TODO comments to a github issue 2023-10-11 11:40:13 -07:00
Andrew Kelley
f80ca1d66a disable flaky test 2023-10-11 11:35:51 -07:00
Ryan Liptak
01fc6a05ef Add a standalone test for Windows resource file compilation 2023-09-17 03:09:45 -07:00
Andrew Kelley
4c97919e8e
Merge pull request #16885 from squeek502/windows-selfExePath-symlink
`fs.selfExePath`: Make the Windows implementation follow symlinks
2023-08-19 21:24:36 -07:00
Ryan Liptak
47343f9bcf Add self_exe_symlink standalone test
Tests that fs.selfExePath follows symlinks by comparing it to the path of the File returned from fs.openSelfExe
2023-08-19 17:48:19 -07:00
Jakub Konka
f4afc6525b standalone: add iOS smoke test - test ability to target iOS with Zig 2023-08-18 11:58:11 +02:00
kcbanner
8b9627f01d test: add a test that verifies no debug handlers get pulled into compiler_rt
build: fix CheckObject checkNotPresent only checking a single line of the haystack
2023-07-27 10:31:52 -04:00
Andrew Kelley
48e0b89f2c remove tools/extract-grammar.zig
This is not a sound way to check Zig's grammar against the spec.

This is a partial revert of f8f1c6ac06.
2023-07-25 18:17:18 -07:00
alex
abd960873c test/standalone: reinstate std.ChildProcess tests
67d5bfef removed std.ChildProcess tests, suggesting to make them
standalone instead. This commit does exactly that after the
bug creating SIGPIPE in ReleaseFast is no more with LLVM 15.0.5.

Thanks to @x1ddos for the idea with the compile artifacts and PR
improvements.
2023-07-25 10:57:45 -07:00
kcbanner
bdb0a6fa77 test: add a test for dwarf embedded in coff 2023-07-20 22:58:16 -04:00
kcbanner
ec96095efd compilation: pass omit_frame_pointer through to builtin.zig
Renamed dwarf_unwinding -> stack_iterator to better reflect that it's not just DWARF unwinding.
Added a test for unwinding with a frame pointer.
2023-07-20 22:58:16 -04:00
kcbanner
9c908ea814 test: add standalone test for DWARF unwinding with -fomit-frame-pointer 2023-07-20 22:58:14 -04:00
Andrew Kelley
c597ba32d9 Sema: fix return type of generic function is function pointer
also that's one less standalone test and one more behavior test.
2023-07-18 21:15:16 -07:00
Luuk de Gram
37e2a04da8
add stand alone test to verify bulk-memory features
This adds a standalone test case to ensure the runtime does not trap
when performing a memory.copy or memory.fill instruction while the
destination or source address is out-of-bounds and the length is 0.
2023-07-10 20:05:13 +02:00
Jan200101
f74285b3be
test: add standalone test for cmakedefine 2023-06-21 21:51:07 +02:00
Nameless
71c228fe65
std.http: add simple standalone http tests, add state check for http server 2023-05-06 21:35:15 -05:00
Jacob Young
7e0c6d7edc Sema: fix empty infinite loops
Closes #15284
2023-04-17 02:30:10 +03:00
Andrew Kelley
f289277599 Merge remote-tracking branch 'origin/master' into llvm16 2023-04-05 22:05:31 -07:00
dweiller
ff97bd21c3 tests: enable test_runner_module_imports standalone test 2023-03-30 11:53:07 +03:00
Andrew Kelley
8f481dfc3c fix std.Build.OptionsStep
* use the same hash function as the rest of the steps
 * fix race condition due to a macOS oddity.
 * fix race condition due to file truncation (rename into place instead)
 * integrate with marking Step.result_cached. check if the file already
   exists with fs.access before doing anything else.
 * use a directory so that the file basename can be "options.zig"
   instead of a hash digest.
 * better error reporting in case of file system failures.
2023-03-19 00:39:29 -04:00
Andrew Kelley
4d7e77cb17 remove standalone test "issue_9812"
This test has a few problems:

 * I don't want to vendor third party projects into the main compiler
   repository such as kuba-zip just for test cases. If we want to test
   third party projects, that should be a separate repository dedicated
   to that purpose.

 * Ideally tests would be isolated to test a particular thing, rather
   than have a lot of unrelated logic that is not what is primarily
   being tested.

 * Ideally tests will not be named after GitHub issues, but named after
   the thing that is being tested. And not testing for the absence of a
   bug, but for the existence of correct behavior.

Aside from these issues, it's also failing in the LLVM 16 branch:

```
kuba-zip/zip.c:276:16: error: call to undeclared function 'fileno'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
kuba-zip/zip.c:277:14: error: call to undeclared function 'ftruncate'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
kuba-zip/zip.c:364:11: error: call to undeclared function 'symlink'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
```

These are not interesting failures related to the thing actually being
tested; this is busywork related to the fact that we vendor third party
code. So, that is why I chose to delete this test case instead of repair
it.
2023-03-16 21:51:58 -07:00
Andrew Kelley
c5cdc0262b add the new extern test to standalone tests
This was from master branch commit
c93e0d8618. Since standalone test are
completely reworked, I had to resolve the merge conflict later, in this
commit.
2023-03-15 10:48:15 -07:00
Andrew Kelley
2956232b42 standalone tests: avoid running on strange target
Without this, aarch64-linux tried to compile this test for
aarch64-windows with the same CPU settings, which is not an intended
test combination.
2023-03-15 10:48:14 -07:00
Andrew Kelley
030742f1f7 re-enable standalone tests based on build.zig 2023-03-15 10:48:14 -07:00
Andrew Kelley
15c4fae1c9 re-enable the simple standalone tests 2023-03-15 10:48:14 -07:00
mlugg
c93e0d8618 Sema: @extern fixes
* There was an edge case where the arena could be destroyed twice on
  error: once from the arena itself and once from the decl destruction.

* The type of the created decl was incorrect (it should have been the
  pointer child type), but it's not required anyway, so it's now just
  initialized to anyopaque (which more accurately reflects what's
  actually at that memory, since e.g. [*]T may correspond to nothing).

* A runtime bitcast of the pointer was performed, meaning @extern didn't
  work at comptime. This is unnecessary: the decl_ref can just be
  initialized with the correct pointer type.
2023-03-12 18:55:23 +02:00
mlugg
f94cbab3ac
Add test coverage for some module structures 2023-02-21 02:05:36 +00:00
Jonathan Marler
0a8fe34b11 add test to ignore sigpipe 2023-02-17 15:25:36 -07:00
dweiller
1f7390f399 fix custom test runner package path resolution
Fixes #13970.

This fix makes test runners resolve package paths relative to the
directory the test runner is in. This means it is not possible to import
a file from outside the file tree root at the directory containing the
test runner.
2023-02-08 14:30:37 +11:00
Andrew Kelley
11cc1c16fa make @embedFile support module-mapped names the same way as @import
closes #14553
2023-02-05 03:25:43 -05:00
Jan Philipp Hafer
301a89849b tools: build all tools in ci to prevent bitrot
No LLVM assertions were triggered for me.
Closes #12015
Closes #12022
Closes #12223
2023-01-06 01:18:46 +02:00
Andrew Kelley
9bcd48e40e Revert "make a .rsp file for zig clang"
This reverts commit 9db293492b.

It's not OK to call `realpath` in the compiler.

Reopens #12419
2023-01-02 16:31:45 -07:00
Ryan Liptak
0cbc59f227 standalone tests: Add windows spawn test
Tests a decent amount of edge cases dealing with how PATH and PATHEXT searching is handled.
2022-12-18 03:55:28 -08:00
Coin
5e111098e5 Revert "compiler_c test: skip build modes on aarch64-windows"
This reverts commit c029a98f1c.
2022-12-12 04:58:10 +08:00
Coin
ed0ecd9bff Revert "mix_c_files: skip build modes on aarch64-windows due to bug"
This reverts commit cf543199ca.
2022-12-12 04:57:55 +08:00
Jakub Konka
c029a98f1c compiler_c test: skip build modes on aarch64-windows 2022-12-10 16:00:59 -07:00
Jakub Konka
cf543199ca mix_c_files: skip build modes on aarch64-windows due to bug 2022-12-10 16:00:59 -07:00
Andrew Kelley
b1793c2b52 add test coverage for zig build CLI and options API 2022-11-30 13:22:43 -07:00
Jakub Konka
033aa1d761 aarch64-windows: skip failing standalone tests 2022-11-28 19:45:53 -05:00
Veikka Tuominen
8082323dfd
Merge pull request #13411 from dweiller/custom-test-runner
Custom test runner
2022-11-18 14:47:21 +02:00
Andrew Kelley
a50ad04e85 disable failing test on aarch64-macos 2022-11-14 16:07:52 -07:00
dweiller
ae0f12885b test: add test_runner_path test 2022-11-02 22:41:20 +11:00
Hadrien Dorio
9db293492b make a .rsp file for zig clang
same as std.build.LibExeObjStep.make() for `zig build-exe`
closes #12419
2022-10-26 23:50:51 +02:00
Veikka Tuominen
8fa91939a8 build.zig: separate C ABI tests from standalone tests 2022-10-22 11:31:41 +03:00