Merge pull request #496 from leecannon/master
Fix `std.math.cast`, `std.ChildProcess`, tests on Windows and enable Windows in CI
This commit is contained in:
commit
ee65d3a623
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -27,9 +27,7 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: zig build
|
run: zig build
|
||||||
|
|
||||||
# ZLS Tests currently fail on windows? Once they are passing and kept up to date, this can be enabled everywhere
|
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
|
||||||
run: zig build test
|
run: zig build test
|
||||||
|
|
||||||
- name: Build artifacts
|
- name: Build artifacts
|
||||||
|
@ -36,10 +36,12 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
|
|
||||||
var unit_tests = b.addTest("src/unit_tests.zig");
|
var unit_tests = b.addTest("src/unit_tests.zig");
|
||||||
unit_tests.setBuildMode(.Debug);
|
unit_tests.setBuildMode(.Debug);
|
||||||
|
unit_tests.setTarget(target);
|
||||||
test_step.dependOn(&unit_tests.step);
|
test_step.dependOn(&unit_tests.step);
|
||||||
|
|
||||||
var session_tests = b.addTest("tests/sessions.zig");
|
var session_tests = b.addTest("tests/sessions.zig");
|
||||||
session_tests.addPackage(.{ .name = "header", .source = .{ .path = "src/header.zig" } });
|
session_tests.addPackage(.{ .name = "header", .source = .{ .path = "src/header.zig" } });
|
||||||
session_tests.setBuildMode(.Debug);
|
session_tests.setBuildMode(.Debug);
|
||||||
|
session_tests.setTarget(target);
|
||||||
test_step.dependOn(&session_tests.step);
|
test_step.dependOn(&session_tests.step);
|
||||||
}
|
}
|
||||||
|
@ -1454,8 +1454,7 @@ fn formattingHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req:
|
|||||||
return try respondGeneric(id, null_result_response);
|
return try respondGeneric(id, null_result_response);
|
||||||
};
|
};
|
||||||
|
|
||||||
var process = try std.ChildProcess.init(&[_][]const u8{ zig_exe_path, "fmt", "--stdin" }, allocator);
|
var process = std.ChildProcess.init(&[_][]const u8{ zig_exe_path, "fmt", "--stdin" }, allocator);
|
||||||
defer process.deinit();
|
|
||||||
process.stdin_behavior = .Pipe;
|
process.stdin_behavior = .Pipe;
|
||||||
process.stdout_behavior = .Pipe;
|
process.stdout_behavior = .Pipe;
|
||||||
|
|
||||||
@ -1656,7 +1655,7 @@ pub fn main() anyerror!void {
|
|||||||
// Check arguments.
|
// Check arguments.
|
||||||
var args_it = try std.process.ArgIterator.initWithAllocator(allocator);
|
var args_it = try std.process.ArgIterator.initWithAllocator(allocator);
|
||||||
defer args_it.deinit();
|
defer args_it.deinit();
|
||||||
if(!args_it.skip()) @panic("Could not find self argument");
|
if (!args_it.skip()) @panic("Could not find self argument");
|
||||||
|
|
||||||
var config_path: ?[]const u8 = null;
|
var config_path: ?[]const u8 = null;
|
||||||
var next_arg_config_path = false;
|
var next_arg_config_path = false;
|
||||||
|
@ -114,11 +114,11 @@ fn fromDynamicTreeInternal(arena: *std.heap.ArenaAllocator, value: std.json.Valu
|
|||||||
if (value != .Integer) return error.MalformedJson;
|
if (value != .Integer) return error.MalformedJson;
|
||||||
out.* = std.meta.intToEnum(
|
out.* = std.meta.intToEnum(
|
||||||
T,
|
T,
|
||||||
std.math.cast(TagType, value.Integer) catch return error.MalformedJson,
|
std.math.cast(TagType, value.Integer) orelse return error.MalformedJson,
|
||||||
) catch return error.MalformedJson;
|
) catch return error.MalformedJson;
|
||||||
} else if (comptime std.meta.trait.is(.Int)(T)) {
|
} else if (comptime std.meta.trait.is(.Int)(T)) {
|
||||||
if (value != .Integer) return error.MalformedJson;
|
if (value != .Integer) return error.MalformedJson;
|
||||||
out.* = std.math.cast(T, value.Integer) catch return error.MalformedJson;
|
out.* = std.math.cast(T, value.Integer) orelse return error.MalformedJson;
|
||||||
} else switch (T) {
|
} else switch (T) {
|
||||||
bool => {
|
bool => {
|
||||||
if (value != .Bool) return error.MalformedJson;
|
if (value != .Bool) return error.MalformedJson;
|
||||||
|
@ -13,7 +13,7 @@ const initialize_msg_offs =
|
|||||||
;
|
;
|
||||||
|
|
||||||
const Server = struct {
|
const Server = struct {
|
||||||
process: *std.ChildProcess,
|
process: std.ChildProcess,
|
||||||
request_id: u32 = 1,
|
request_id: u32 = 1,
|
||||||
|
|
||||||
fn start(initialization: []const u8, expect: ?[]const u8) !Server {
|
fn start(initialization: []const u8, expect: ?[]const u8) !Server {
|
||||||
@ -103,12 +103,11 @@ const Server = struct {
|
|||||||
// FIXME this shutdown request fails with a broken pipe on stdin on the CI
|
// FIXME this shutdown request fails with a broken pipe on stdin on the CI
|
||||||
self.request("shutdown", "{}", null) catch @panic("Could not send shutdown request");
|
self.request("shutdown", "{}", null) catch @panic("Could not send shutdown request");
|
||||||
// waitNoError(self.process) catch @panic("Server error");
|
// waitNoError(self.process) catch @panic("Server error");
|
||||||
self.process.deinit();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fn startZls() !*std.ChildProcess {
|
fn startZls() !std.ChildProcess {
|
||||||
var process = try std.ChildProcess.init(&[_][]const u8{"zig-out/bin/zls" ++ suffix}, allocator);
|
var process = std.ChildProcess.init(&[_][]const u8{"zig-out/bin/zls" ++ suffix}, allocator);
|
||||||
process.stdin_behavior = .Pipe;
|
process.stdin_behavior = .Pipe;
|
||||||
process.stdout_behavior = .Pipe;
|
process.stdout_behavior = .Pipe;
|
||||||
process.stderr_behavior = .Inherit;
|
process.stderr_behavior = .Inherit;
|
||||||
@ -155,10 +154,10 @@ test "Open file, ask for semantic tokens" {
|
|||||||
defer server.shutdown();
|
defer server.shutdown();
|
||||||
|
|
||||||
try server.request("textDocument/didOpen",
|
try server.request("textDocument/didOpen",
|
||||||
\\{"textDocument":{"uri":"file://./tests/test.zig","languageId":"zig","version":420,"text":"const std = @import(\"std\");"}}
|
\\{"textDocument":{"uri":"file:///test.zig","languageId":"zig","version":420,"text":"const std = @import(\"std\");"}}
|
||||||
, null);
|
, null);
|
||||||
try server.request("textDocument/semanticTokens/full",
|
try server.request("textDocument/semanticTokens/full",
|
||||||
\\{"textDocument":{"uri":"file://./tests/test.zig"}}
|
\\{"textDocument":{"uri":"file:///test.zig"}}
|
||||||
,
|
,
|
||||||
\\{"data":[0,0,5,7,0,0,6,3,0,33,0,4,1,11,0,0,2,7,12,0,0,8,5,9,0]}
|
\\{"data":[0,0,5,7,0,0,6,3,0,33,0,4,1,11,0,0,2,7,12,0,0,8,5,9,0]}
|
||||||
);
|
);
|
||||||
@ -218,19 +217,23 @@ test "Self-referential definition" {
|
|||||||
\\{"isIncomplete":false,"items":[{"label":"h","kind":21,"textEdit":null,"filterText":null,"insertText":"h","insertTextFormat":1,"detail":"const h = h(0)","documentation":null}]}
|
\\{"isIncomplete":false,"items":[{"label":"h","kind":21,"textEdit":null,"filterText":null,"insertText":"h","insertTextFormat":1,"detail":"const h = h(0)","documentation":null}]}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
test "Missing return type" {
|
|
||||||
var server = try Server.start(initialize_msg, null);
|
|
||||||
defer server.shutdown();
|
|
||||||
|
|
||||||
try server.request("textDocument/didOpen",
|
// This test as written depends on the configuration in the *host* machines zls.json, if `enable_snippets` is true then
|
||||||
\\{"textDocument":{"uri":"file:///test.zig","languageId":"zig","version":420,"text":"fn w() {}\nc"}}
|
// the insert text is "w()" if it is false it is "w"
|
||||||
, null);
|
//
|
||||||
try server.request("textDocument/completion",
|
// test "Missing return type" {
|
||||||
\\{"textDocument":{"uri":"file:///test.zig"}, "position":{"line":1,"character":1}}
|
// var server = try Server.start(initialize_msg, null);
|
||||||
,
|
// defer server.shutdown();
|
||||||
\\{"isIncomplete":false,"items":[{"label":"w","kind":3,"textEdit":null,"filterText":null,"insertText":"w","insertTextFormat":1,"detail":"fn","documentation":null}]}
|
|
||||||
);
|
// try server.request("textDocument/didOpen",
|
||||||
}
|
// \\{"textDocument":{"uri":"file:///test.zig","languageId":"zig","version":420,"text":"fn w() {}\nc"}}
|
||||||
|
// , null);
|
||||||
|
// try server.request("textDocument/completion",
|
||||||
|
// \\{"textDocument":{"uri":"file:///test.zig"}, "position":{"line":1,"character":1}}
|
||||||
|
// ,
|
||||||
|
// \\{"isIncomplete":false,"items":[{"label":"w","kind":3,"textEdit":null,"filterText":null,"insertText":"w","insertTextFormat":1,"detail":"fn","documentation":null}]}
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
test "Pointer and optional deref" {
|
test "Pointer and optional deref" {
|
||||||
var server = try Server.start(initialize_msg, null);
|
var server = try Server.start(initialize_msg, null);
|
||||||
|
Loading…
Reference in New Issue
Block a user