Skip to content

Commit 980ccfa

Browse files
committed
Fix the issue of compatibility with zig 0.15
1 parent 2b605a8 commit 980ccfa

3 files changed

Lines changed: 11 additions & 67 deletions

File tree

build.zig

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ pub fn build(b: *std.Build) void {
1010
.optimize = optimize,
1111
});
1212

13-
const unit_tests = b.addTest(.{
13+
// Create a test module
14+
const test_module = b.createModule(.{
1415
.root_source_file = b.path("src/test.zig"),
1516
.target = target,
1617
.optimize = optimize,
1718
});
18-
unit_tests.root_module.addImport("url", module);
19+
test_module.addImport("url", module);
20+
21+
const unit_tests = b.addTest(.{
22+
.root_module = test_module,
23+
});
1924
const run_unit_tests = b.addRunArtifact(unit_tests);
2025

2126
const test_step = b.step("test", "Run unit tests");

build.zig.zon

Lines changed: 3 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,11 @@
11
.{
2-
// This is the default name used by packages depending on this one. For
3-
// example, when a user runs `zig fetch --save <url>`, this field is used
4-
// as the key in the `dependencies` table. Although the user can choose a
5-
// different name, most users will stick with this provided value.
6-
//
7-
// It is redundant to include "zig" in this name because it is already
8-
// within the Zig package namespace.
9-
.name = "url",
10-
11-
// This is a [Semantic Version](https://semver.org/).
12-
// In a future version of Zig it will be used for package deduplication.
2+
.name = .url,
3+
.fingerprint = 0xf47645aec2d0229e,
134
.version = "0.1.0",
14-
15-
// This field is optional.
16-
// This is currently advisory only; Zig does not yet do anything
17-
// with this value.
18-
//.minimum_zig_version = "0.11.0",
19-
20-
// This field is optional.
21-
// Each dependency must either provide a `url` and `hash`, or a `path`.
22-
// `zig build --fetch` can be used to fetch all dependencies of a package, recursively.
23-
// Once all dependencies are fetched, `zig build` no longer requires
24-
// internet connectivity.
25-
.dependencies = .{
26-
// See `zig fetch --save <url>` for a command-line interface for adding dependencies.
27-
//.example = .{
28-
// // When updating this field to a new URL, be sure to delete the corresponding
29-
// // `hash`, otherwise you are communicating that you expect to find the old hash at
30-
// // the new URL.
31-
// .url = "https://example.com/foo.tar.gz",
32-
//
33-
// // This is computed from the file contents of the directory of files that is
34-
// // obtained after fetching `url` and applying the inclusion rules given by
35-
// // `paths`.
36-
// //
37-
// // This field is the source of truth; packages do not come from a `url`; they
38-
// // come from a `hash`. `url` is just one of many possible mirrors for how to
39-
// // obtain a package matching this `hash`.
40-
// //
41-
// // Uses the [multihash](https://multiformats.io/multihash/) format.
42-
// .hash = "...",
43-
//
44-
// // When this is provided, the package is found in a directory relative to the
45-
// // build root. In this case the package's hash is irrelevant and therefore not
46-
// // computed. This field and `url` are mutually exclusive.
47-
// .path = "foo",
48-
//
49-
// // When this is set to `true`, a package is declared to be lazily
50-
// // fetched. This makes the dependency only get fetched if it is
51-
// // actually used.
52-
// .lazy = false,
53-
//},
54-
},
55-
56-
// Specifies the set of files and directories that are included in this package.
57-
// Only files and directories listed here are included in the `hash` that
58-
// is computed for this package. Only files listed here will remain on disk
59-
// when using the zig package manager. As a rule of thumb, one should list
60-
// files required for compilation plus any license(s).
61-
// Paths are relative to the build root. Use the empty string (`""`) to refer to
62-
// the build root itself.
63-
// A directory listed here means that all files within, recursively, are included.
5+
.dependencies = .{},
646
.paths = .{
657
"build.zig",
668
"build.zig.zon",
679
"src",
68-
// For example...
69-
//"LICENSE",
70-
//"README.md",
7110
},
7211
}

src/url_test.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ test "url parse" {
8888
test "RFC example 1" {
8989
const text = "/over/there?name=ferret#nose";
9090
var url = URL.init(.{ .allocator = std.testing.allocator });
91+
defer url.deinit();
9192
const result = try url.parseUrl(text);
9293
try testing.expectEqualStrings("/over/there", result.path);
9394
try testing.expectEqualStrings("name=ferret", @constCast(result.query.?));
9495
try testing.expectEqualStrings("nose", result.fragment.?);
9596

9697
var qm = url.values.?;
97-
defer qm.deinit();
9898
const vm = qm.get("name").?;
9999
try testing.expectEqualStrings("ferret", vm.items[0]);
100100
}

0 commit comments

Comments
 (0)