Skip to content

Commit 9e351e4

Browse files
committed
test: adjust java expectations based on whether jars can be listed
1 parent 6c8380d commit 9e351e4

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

test/t/test_java.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,44 @@
11
import pytest
22

3+
from conftest import is_bash_type
4+
35

46
@pytest.mark.bashcomp(
57
pre_cmds=("CLASSPATH=$PWD/java/a:$PWD/java/bashcomp.jar",)
68
)
79
class TestJava:
10+
@pytest.fixture(scope="class")
11+
def can_list_jar(self, bash):
12+
return (
13+
is_bash_type(bash, "zipinfo")
14+
or is_bash_type(bash, "unzip")
15+
or is_bash_type(bash, "jar")
16+
)
17+
818
@pytest.mark.complete("java -", require_cmd=True)
919
def test_1(self, completion):
1020
assert completion
1121

1222
@pytest.mark.complete("java ")
13-
def test_2(self, completion):
14-
assert completion == "b bashcomp.jarred c. toplevel".split()
23+
def test_2(self, completion, can_list_jar):
24+
if can_list_jar:
25+
assert completion == "b bashcomp.jarred c. toplevel".split()
26+
else:
27+
assert completion == "b c.".split()
1528

1629
@pytest.mark.complete("java -classpath java/bashcomp.jar ")
17-
def test_3(self, completion):
18-
assert completion == "bashcomp.jarred toplevel".split()
30+
def test_3(self, completion, can_list_jar):
31+
if can_list_jar:
32+
assert completion == "bashcomp.jarred toplevel".split()
33+
else:
34+
assert not completion
1935

2036
@pytest.mark.complete("java -cp java/bashcomp.jar:java/a/c ")
21-
def test_4(self, completion):
22-
assert completion == "bashcomp.jarred d toplevel".split()
37+
def test_4(self, completion, can_list_jar):
38+
if can_list_jar:
39+
assert completion == "bashcomp.jarred d toplevel".split()
40+
else:
41+
assert completion == ["d"]
2342

2443
@pytest.mark.complete("java -cp '' ")
2544
def test_5(self, completion):

0 commit comments

Comments
 (0)