|
1 | 1 | import pytest
|
2 | 2 |
|
| 3 | +from conftest import is_bash_type |
| 4 | + |
3 | 5 |
|
4 | 6 | @pytest.mark.bashcomp(
|
5 | 7 | pre_cmds=("CLASSPATH=$PWD/java/a:$PWD/java/bashcomp.jar",)
|
6 | 8 | )
|
7 | 9 | 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 | + |
8 | 18 | @pytest.mark.complete("java -", require_cmd=True)
|
9 | 19 | def test_1(self, completion):
|
10 | 20 | assert completion
|
11 | 21 |
|
12 | 22 | @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() |
15 | 28 |
|
16 | 29 | @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 |
19 | 35 |
|
20 | 36 | @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"] |
23 | 42 |
|
24 | 43 | @pytest.mark.complete("java -cp '' ")
|
25 | 44 | def test_5(self, completion):
|
|
0 commit comments