git: 5f58d9207469 - main - nuageinit: add dirname edge case tests
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 04 Jun 2026 21:15:39 UTC
The branch main has been updated by bapt:
URL: https://cgit.FreeBSD.org/src/commit/?id=5f58d9207469dcd2d3fa24db7f5276a681df91e5
commit 5f58d9207469dcd2d3fa24db7f5276a681df91e5
Author: Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2026-06-04 17:24:45 +0000
Commit: Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2026-06-04 17:24:45 +0000
nuageinit: add dirname edge case tests
---
libexec/nuageinit/tests/dirname.lua | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/libexec/nuageinit/tests/dirname.lua b/libexec/nuageinit/tests/dirname.lua
index 7e3a2c835502..9d76aed0ac11 100644
--- a/libexec/nuageinit/tests/dirname.lua
+++ b/libexec/nuageinit/tests/dirname.lua
@@ -1,11 +1,34 @@
#!/usr/libexec/flua
+---
+-- SPDX-License-Identifier: BSD-2-Clause
+--
+-- Copyright (c) 2026 Baptiste Daroussin <bapt@FreeBSD.org>
local n = require("nuage")
print(n.dirname("/my/path/path1"))
+
+-- relative path with no directory component: nil
if n.dirname("path") then
n.err('Expecting nil for n.dirname("path")')
end
+
+-- nil input: nil
if n.dirname() then
n.err("Expecting nil for n.dirname")
end
+
+-- root path: returns "/"
+if n.dirname("/") ~= "/" then
+ n.err('Expecting "/" for n.dirname("/"), got: ' .. tostring(n.dirname("/")))
+end
+
+-- top-level directory: returns "/"
+if n.dirname("/foo") ~= "/" then
+ n.err('Expecting "/" for n.dirname("/foo")')
+end
+
+-- deep path
+if n.dirname("/foo/bar/baz") ~= "/foo/bar/" then
+ n.err('Expecting "/foo/bar/" for n.dirname("/foo/bar/baz")')
+end