diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44f841c..7d3cb9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ name: CI on: [push, pull_request] env: - HOSTNAME: ANYHOSTNAME + jobs: build: diff --git a/.vscode/launch.json b/.vscode/launch.json index 89480ff..41ce6a3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -15,7 +15,7 @@ "type": "lldb", "request": "launch", "name": "Debug Test", - "program": "${workspaceFolder}/zig-out/test-binary", + "program": "${workspaceFolder}/zig-out/bin/test", "preLaunchTask": "build_test", "args": [], "cwd": "${workspaceFolder}", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 649e354..2728112 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -15,6 +15,18 @@ "label": "build_test", "type": "shell", "command": "zig", + "args": [ + "build", + "install", + "--summary", + "all" + ], + "group": "test" + }, + { + "label": "build_test_org", + "type": "shell", + "command": "zig", "args": [ "test", "${input:testFile}", diff --git a/build.zig b/build.zig index 678c0dc..1f2dbcf 100644 --- a/build.zig +++ b/build.zig @@ -59,6 +59,7 @@ pub fn build(b: *std.Build) void { lib_unit_tests.root_module.addImport("network", zig_network.module("network")); lib_unit_tests.root_module.addImport("zig-datetime", zig_datetime.module("zig-datetime")); lib_unit_tests.root_module.addImport("mailbox", mailbox.module("mailbox")); + b.installArtifact(lib_unit_tests); const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests); diff --git a/src/application.zig b/src/application.zig index 29ac8b2..37a914c 100644 --- a/src/application.zig +++ b/src/application.zig @@ -65,9 +65,13 @@ pub const Application = struct { var fbAllocator = std.heap.FixedBufferAllocator.init(&buffer); const allocator = fbAllocator.allocator(); - const hostName = std.process.getEnvVarOwned(allocator, envMame) catch "-"; + var hostName = std.process.getEnvVarOwned(allocator, envMame) catch ""; - defer allocator.free(hostName); + if (hostName.len == 0) { + hostName = "-"; + } else { + defer allocator.free(hostName); + } _ = try appl.*.host_name.fillFrom(hostName);