Skip to content

Commit 01a8c85

Browse files
committed
test:ram_* more robust
1 parent aafa1a3 commit 01a8c85

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

test/TestSys.m

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,27 @@ function test_cpu_arch(tc, cpu_arch_fun)
159159
end
160160

161161
function test_ram_total(tc, ram_total_method)
162-
is_capable(tc, str2func("stdlib." + ram_total_method + ".ram_total"))
163-
164-
t = stdlib.ram_total(ram_total_method);
162+
try
163+
t = stdlib.ram_total(ram_total_method);
164+
catch e
165+
tc.verifyEqual(e.identifier, 'stdlib:choose_method:NameError', e.message)
166+
return
167+
end
168+
165169
tc.verifyGreaterThan(t, 0)
166170
tc.verifyClass(t, 'uint64')
167171
end
168172

169173

170174
function test_ram_free(tc, ram_free_method)
171-
% don't verify less than or equal total due to shaky system measurements
172-
is_capable(tc, str2func("stdlib." + ram_free_method + ".ram_free"))
175+
% don't verify less than or equal total due to shaky system measurements'
176+
try
177+
f = stdlib.ram_free(ram_free_method);
178+
catch e
179+
tc.verifyEqual(e.identifier, 'stdlib:choose_method:NameError', e.message)
180+
return
181+
end
173182

174-
f = stdlib.ram_free(ram_free_method);
175183
tc.verifyGreaterThan(f, 0)
176184
tc.verifyClass(f, 'uint64')
177185
end

test/is_capable.m

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,12 @@ function is_capable(tc, f)
99
if contains(n, ".dotnet.")
1010

1111
dapi = stdlib.dotnet_api();
12-
1312
tc.assumeGreaterThan(dapi, 0, ".NET not available")
1413

1514
if endsWith(n, ["is_admin", "owner"])
1615
tc.assumeTrue(ispc(), "Windows only function")
1716
end
1817

19-
if endsWith(n, "ram_total")
20-
tc.assumeGreaterThanOrEqual(dapi, 6);
21-
end
22-
2318
elseif contains(n, ".java.")
2419

2520
japi = stdlib.java_api();
@@ -33,10 +28,6 @@ function is_capable(tc, f)
3328

3429
tc.assumeTrue(stdlib.has_python(), "Python not available")
3530

36-
if endsWith(n, ["filesystem_type", "ram_free", "ram_total"])
37-
tc.assumeTrue(stdlib.python.has_psutil(), "need Python psutil package")
38-
end
39-
4031
if endsWith(n, "owner")
4132
tc.assumeFalse(ispc(), "unix only function")
4233
end

0 commit comments

Comments
 (0)