diff options
| -rw-r--r-- | .gitattributes | 4 | ||||
| -rw-r--r-- | build.zig | 2 | ||||
| -rw-r--r-- | ci/aarch64-windows.ps1 | 5 | ||||
| -rw-r--r-- | doc/langref.html.in | 34 | ||||
| -rw-r--r-- | lib/std/child_process.zig | 8 | ||||
| -rw-r--r-- | lib/std/compress/deflate/huffman_bit_writer.zig | 5 | ||||
| -rw-r--r-- | lib/std/compress/gzip.zig | 4 | ||||
| -rw-r--r-- | lib/std/compress/testdata/rfc1951.txt (renamed from lib/std/compress/rfc1951.txt) | 0 | ||||
| -rw-r--r-- | lib/std/compress/testdata/rfc1951.txt.fixed.z.9 (renamed from lib/std/compress/rfc1951.txt.fixed.z.9) | bin | 12836 -> 12836 bytes | |||
| -rw-r--r-- | lib/std/compress/testdata/rfc1951.txt.z.0 (renamed from lib/std/compress/rfc1951.txt.z.0) | bin | 36960 -> 36960 bytes | |||
| -rw-r--r-- | lib/std/compress/testdata/rfc1951.txt.z.9 (renamed from lib/std/compress/rfc1951.txt.z.9) | bin | 11111 -> 11111 bytes | |||
| -rw-r--r-- | lib/std/compress/testdata/rfc1952.txt (renamed from lib/std/compress/rfc1952.txt) | 0 | ||||
| -rw-r--r-- | lib/std/compress/testdata/rfc1952.txt.gz (renamed from lib/std/compress/rfc1952.txt.gz) | bin | 8059 -> 8059 bytes | |||
| -rw-r--r-- | lib/std/compress/zlib.zig | 8 | ||||
| -rw-r--r-- | test/behavior/error.zig | 21 | ||||
| -rw-r--r-- | test/behavior/ptrcast.zig | 31 | ||||
| -rw-r--r-- | test/standalone/windows_spawn/main.zig | 9 |
17 files changed, 115 insertions, 16 deletions
diff --git a/.gitattributes b/.gitattributes index 2983afbfc3..581789817c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,9 +1,9 @@ *.zig text eol=lf *.txt text eol=lf langref.html.in text eol=lf -deps/SoftFloat-3e/*.txt text eol=crlf +lib/std/compress/testdata/** binary +lib/std/compress/deflate/testdata/** binary -deps/** linguist-vendored lib/include/** linguist-vendored lib/libc/** linguist-vendored lib/libcxx/** linguist-vendored @@ -106,7 +106,7 @@ pub fn build(b: *Builder) !void { .install_dir = .lib, .install_subdir = "zig", .exclude_extensions = &[_][]const u8{ - // exclude files from lib/std/compress/ + // exclude files from lib/std/compress/testdata ".gz", ".z.0", ".z.9", diff --git a/ci/aarch64-windows.ps1 b/ci/aarch64-windows.ps1 index bf80d3a091..0e43c1bf69 100644 --- a/ci/aarch64-windows.ps1 +++ b/ci/aarch64-windows.ps1 @@ -31,6 +31,11 @@ if ((git rev-parse --is-shallow-repository) -eq "true") { git fetch --unshallow # `git describe` won't work on a shallow repo } +# Fix files that have their gitattributes changed +git rm -rf lib +git restore --staged lib +git checkout lib + Write-Output "Building from source..." Remove-Item -Path 'build-release' -Recurse -Force -ErrorAction Ignore New-Item -Path 'build-release' -ItemType Directory diff --git a/doc/langref.html.in b/doc/langref.html.in index 04755d00ec..7a3c96595c 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -300,6 +300,40 @@ color: #fff; } } + + @media all { + main { + counter-reset: section-2; + } + h2 { + counter-reset: section-3; + } + h2::before { + counter-increment: section-2; + content: counter(section-2) ". "; + font-weight: normal; + } + h3 { + counter-reset: section-4; + } + h3::before { + counter-increment: section-3; + content: counter(section-2) "." counter(section-3) ". "; + font-weight: normal; + } + h4::before { + counter-increment: section-4; + content: counter(section-2) "." counter(section-3) "." counter(section-4) ". "; + font-weight: normal; + } + #zig-version::before { + content: ""; + } + #table-of-contents::before { + content: ""; + } + } + } </style> </head> <body> diff --git a/lib/std/child_process.zig b/lib/std/child_process.zig index 1cdbd2e9d1..7bff9fe089 100644 --- a/lib/std/child_process.zig +++ b/lib/std/child_process.zig @@ -1022,8 +1022,12 @@ pub const ChildProcess = struct { }; // If the app name had path separators, that disallows PATH searching, - // and there's no need to search the PATH if the cwd path is absolute. - if (app_dirname_w != null or fs.path.isAbsoluteWindowsWTF16(cwd_path_w)) { + // and there's no need to search the PATH if the app name is absolute. + // We still search the path if the cwd is absolute because of the + // "cwd set in ChildProcess is in effect when choosing the executable path + // to match posix semantics" behavior--we don't want to skip searching + // the PATH just because we were trying to set the cwd of the child process. + if (app_dirname_w != null or app_name_is_absolute) { return original_err; } diff --git a/lib/std/compress/deflate/huffman_bit_writer.zig b/lib/std/compress/deflate/huffman_bit_writer.zig index 3b83eecea3..fc5727ca63 100644 --- a/lib/std/compress/deflate/huffman_bit_writer.zig +++ b/lib/std/compress/deflate/huffman_bit_writer.zig @@ -848,11 +848,6 @@ test "writeBlockHuff" { // Tests huffman encoding against reference files to detect possible regressions. // If encoding/bit allocation changes you can regenerate these files - if (builtin.os.tag == .windows) { - // https://github.com/ziglang/zig/issues/13892 - return error.SkipZigTest; - } - try testBlockHuff( "huffman-null-max.input", "huffman-null-max.golden", diff --git a/lib/std/compress/gzip.zig b/lib/std/compress/gzip.zig index c3b2335a1a..d7a2cb0094 100644 --- a/lib/std/compress/gzip.zig +++ b/lib/std/compress/gzip.zig @@ -172,8 +172,8 @@ fn testReader(data: []const u8, comptime expected: []const u8) !void { // SHA256=164ef0897b4cbec63abf1b57f069f3599bd0fb7c72c2a4dee21bd7e03ec9af67 test "compressed data" { try testReader( - @embedFile("rfc1952.txt.gz"), - @embedFile("rfc1952.txt"), + @embedFile("testdata/rfc1952.txt.gz"), + @embedFile("testdata/rfc1952.txt"), ); } diff --git a/lib/std/compress/rfc1951.txt b/lib/std/compress/testdata/rfc1951.txt index 403c8c722f..403c8c722f 100644 --- a/lib/std/compress/rfc1951.txt +++ b/lib/std/compress/testdata/rfc1951.txt diff --git a/lib/std/compress/rfc1951.txt.fixed.z.9 b/lib/std/compress/testdata/rfc1951.txt.fixed.z.9 Binary files differindex 8ea5904770..8ea5904770 100644 --- a/lib/std/compress/rfc1951.txt.fixed.z.9 +++ b/lib/std/compress/testdata/rfc1951.txt.fixed.z.9 diff --git a/lib/std/compress/rfc1951.txt.z.0 b/lib/std/compress/testdata/rfc1951.txt.z.0 Binary files differindex 3f50fb68f8..3f50fb68f8 100644 --- a/lib/std/compress/rfc1951.txt.z.0 +++ b/lib/std/compress/testdata/rfc1951.txt.z.0 diff --git a/lib/std/compress/rfc1951.txt.z.9 b/lib/std/compress/testdata/rfc1951.txt.z.9 Binary files differindex 84e7cbe5b7..84e7cbe5b7 100644 --- a/lib/std/compress/rfc1951.txt.z.9 +++ b/lib/std/compress/testdata/rfc1951.txt.z.9 diff --git a/lib/std/compress/rfc1952.txt b/lib/std/compress/testdata/rfc1952.txt index a8e51b4567..a8e51b4567 100644 --- a/lib/std/compress/rfc1952.txt +++ b/lib/std/compress/testdata/rfc1952.txt diff --git a/lib/std/compress/rfc1952.txt.gz b/lib/std/compress/testdata/rfc1952.txt.gz Binary files differindex be43b90a79..be43b90a79 100644 --- a/lib/std/compress/rfc1952.txt.gz +++ b/lib/std/compress/testdata/rfc1952.txt.gz diff --git a/lib/std/compress/zlib.zig b/lib/std/compress/zlib.zig index 500bb0bb5b..0fc96a5aa9 100644 --- a/lib/std/compress/zlib.zig +++ b/lib/std/compress/zlib.zig @@ -107,21 +107,21 @@ fn testReader(data: []const u8, expected: []const u8) !void { // https://tools.ietf.org/rfc/rfc1951.txt length=36944 bytes // SHA256=5ebf4b5b7fe1c3a0c0ab9aa3ac8c0f3853a7dc484905e76e03b0b0f301350009 test "compressed data" { - const rfc1951_txt = @embedFile("rfc1951.txt"); + const rfc1951_txt = @embedFile("testdata/rfc1951.txt"); // Compressed with compression level = 0 try testReader( - @embedFile("rfc1951.txt.z.0"), + @embedFile("testdata/rfc1951.txt.z.0"), rfc1951_txt, ); // Compressed with compression level = 9 try testReader( - @embedFile("rfc1951.txt.z.9"), + @embedFile("testdata/rfc1951.txt.z.9"), rfc1951_txt, ); // Compressed with compression level = 9 and fixed Huffman codes try testReader( - @embedFile("rfc1951.txt.fixed.z.9"), + @embedFile("testdata/rfc1951.txt.fixed.z.9"), rfc1951_txt, ); } diff --git a/test/behavior/error.zig b/test/behavior/error.zig index ae1445dd9e..f5bf6493d8 100644 --- a/test/behavior/error.zig +++ b/test/behavior/error.zig @@ -287,6 +287,27 @@ test "inferred empty error set comptime catch" { S.foo() catch @compileError("fail"); } +test "error inference with an empty set" { + const S = struct { + const Struct = struct { + pub fn func() (error{})!usize { + return 0; + } + }; + + fn AnotherStruct(comptime SubStruct: type) type { + return struct { + fn anotherFunc() !void { + try expect(0 == (try SubStruct.func())); + } + }; + } + }; + + const GeneratedStruct = S.AnotherStruct(S.Struct); + try GeneratedStruct.anotherFunc(); +} + test "error union peer type resolution" { if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO diff --git a/test/behavior/ptrcast.zig b/test/behavior/ptrcast.zig index 982a0b862f..f25161ece8 100644 --- a/test/behavior/ptrcast.zig +++ b/test/behavior/ptrcast.zig @@ -203,6 +203,37 @@ test "comptime ptrcast keeps larger alignment" { } } +test "ptrcast of const integer has the correct object size" { + const is_value = ~@intCast(isize, std.math.minInt(isize)); + const is_bytes = @ptrCast([*]const u8, &is_value)[0..@sizeOf(isize)]; + if (@sizeOf(isize) == 8) { + switch (native_endian) { + .Little => { + try expect(is_bytes[0] == 0xff); + try expect(is_bytes[1] == 0xff); + try expect(is_bytes[2] == 0xff); + try expect(is_bytes[3] == 0xff); + + try expect(is_bytes[4] == 0xff); + try expect(is_bytes[5] == 0xff); + try expect(is_bytes[6] == 0xff); + try expect(is_bytes[7] == 0x7f); + }, + .Big => { + try expect(is_bytes[0] == 0x7f); + try expect(is_bytes[1] == 0xff); + try expect(is_bytes[2] == 0xff); + try expect(is_bytes[3] == 0xff); + + try expect(is_bytes[4] == 0xff); + try expect(is_bytes[5] == 0xff); + try expect(is_bytes[6] == 0xff); + try expect(is_bytes[7] == 0xff); + }, + } + } +} + test "implicit optional pointer to optional anyopaque pointer" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO diff --git a/test/standalone/windows_spawn/main.zig b/test/standalone/windows_spawn/main.zig index 970ff959f3..c0cfd15133 100644 --- a/test/standalone/windows_spawn/main.zig +++ b/test/standalone/windows_spawn/main.zig @@ -142,6 +142,10 @@ pub fn main() anyerror!void { defer allocator.free(goodbye_abs_path); // then the PATH should not be searched and we should get InvalidExe try testExecError(error.InvalidExe, allocator, goodbye_abs_path); + + // If we try to exec but provide a cwd that is an absolute path, the PATH + // should still be searched and the goodbye.exe in something should be found. + try testExecWithCwd(allocator, "goodbye", tmp_absolute_path, "hello from exe\n"); } fn testExecError(err: anyerror, allocator: std.mem.Allocator, command: []const u8) !void { @@ -149,9 +153,14 @@ fn testExecError(err: anyerror, allocator: std.mem.Allocator, command: []const u } fn testExec(allocator: std.mem.Allocator, command: []const u8, expected_stdout: []const u8) !void { + return testExecWithCwd(allocator, command, null, expected_stdout); +} + +fn testExecWithCwd(allocator: std.mem.Allocator, command: []const u8, cwd: ?[]const u8, expected_stdout: []const u8) !void { var result = try std.ChildProcess.exec(.{ .allocator = allocator, .argv = &[_][]const u8{command}, + .cwd = cwd, }); defer allocator.free(result.stdout); defer allocator.free(result.stderr); |
