Skip to content

Commit 8acc92c

Browse files
committed
make tests.lua auto-detect platform
1 parent ed3bc65 commit 8acc92c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ local Prometheus = require("src.prometheus")
1212

1313
-- Config Variables - Later passed as Parameters
1414
local noColors = false; -- Whether Colors in the Console output should be enabled
15-
local isWindows = true; -- Whether the Test are Performed on a Windows or Linux System
15+
local isWindows = package.config:sub(1, 1) == "\\"; -- Whether the Test are Performed on a Windows or Linux System
1616
local ciMode = false; -- Whether the Test error are ignored or not
1717
local iterationCount = 20; -- How often each test should be executed
1818

1919
for _, currArg in pairs(arg) do
2020
if currArg == "--Linux" then
2121
isWindows = false
2222
end
23+
if currArg == "--Windows" then
24+
isWindows = true
25+
end
2326
if currArg == "--CI" then
2427
ciMode = true
2528
end
@@ -56,6 +59,9 @@ print(string.format(
5659
local function scandir(directory)
5760
local i, t, popen = 0, {}, io.popen
5861
local pfile = popen(isWindows and 'dir "'..directory..'" /b' or 'ls -a "'..directory..'"')
62+
if not pfile then
63+
error("Failed to list files in test directory: " .. tostring(directory))
64+
end
5965
for filename in pfile:lines() do
6066
if string.sub(filename, -4) == ".lua" then
6167
i = i + 1

0 commit comments

Comments
 (0)