Skip to content

Commit 448db52

Browse files
committed
windows: hostname java optional
1 parent 734f86a commit 448db52

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

+stdlib/hostname.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11

22
%% HOSTNAME get hostname of local machine
3-
% requires: java
3+
% optional: java
44
%
55
% Ref: https://docs.oracle.com/javase/8/docs/api/java/net/InetAddress.html#getHostName--
66

77
function n = hostname()
88

9-
if stdlib.isoctave()
9+
if ispc()
10+
n = string(System.Environment.MachineName);
11+
elseif stdlib.isoctave()
1012
n = gethostname();
1113
else
1214
n = string(java.net.InetAddress.getLocalHost().getHostName());

test/TestJava.m

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ function test_username(tc)
3838
tc.verifyGreaterThan(strlength(u), 0)
3939
end
4040

41-
function test_hostname(tc)
42-
h = stdlib.hostname();
43-
tc.verifyGreaterThan(strlength(h), 0)
44-
end
45-
4641
function test_java_vendor(tc)
4742
v = stdlib.java_vendor();
4843
tc.verifyGreaterThan(strlength(v), 0)

test/TestSys.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@
99
methods (Test, TestTags="impure")
1010

1111
function test_platform_logical(tc, fun)
12-
1312
tc.verifyClass(fun, 'logical')
1413
end
1514

1615
function test_platform_int32(tc, fi32)
1716
tc.verifyClass(fi32, 'int32')
1817
end
1918

19+
function test_hostname(tc)
20+
tc.assumeTrue(ispc() || stdlib.has_java())
21+
h = stdlib.hostname();
22+
tc.verifyGreaterThan(strlength(h), 0)
23+
end
24+
2025
end
2126
end

0 commit comments

Comments
 (0)