summaryrefslogtreecommitdiffstats
path: root/test/t/test_java.py
blob: ce0f7733575c1fa9ab099f23dd6a5db69adab021 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import pytest

from conftest import is_bash_type


@pytest.mark.bashcomp(
    pre_cmds=("CLASSPATH=$PWD/java/a:$PWD/java/bashcomp.jar",)
)
class TestJava:
    @pytest.fixture(scope="class")
    def can_list_jar(self, bash):
        return (
            is_bash_type(bash, "zipinfo")
            or is_bash_type(bash, "unzip")
            or is_bash_type(bash, "jar")
        )

    @pytest.mark.complete("java -", require_cmd=True)
    def test_1(self, completion):
        assert completion

    @pytest.mark.complete("java ")
    def test_2(self, completion, can_list_jar):
        if can_list_jar:
            assert completion == "b bashcomp.jarred c. toplevel".split()
        else:
            assert completion == "b c.".split()

    @pytest.mark.complete("java -classpath java/bashcomp.jar ")
    def test_3(self, completion, can_list_jar):
        if can_list_jar:
            assert completion == "bashcomp.jarred toplevel".split()
        else:
            assert not completion

    @pytest.mark.complete("java -cp java/bashcomp.jar:java/a/c ")
    def test_4(self, completion, can_list_jar):
        if can_list_jar:
            assert completion == "bashcomp.jarred d toplevel".split()
        else:
            assert completion == ["d"]

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

    @pytest.mark.complete("java -jar java/")
    def test_6(self, completion):
        assert completion == "a/ bashcomp.jar bashcomp.war".split()