summaryrefslogtreecommitdiffstats
path: root/test/t/test_make.py
blob: 34fc7e5906aaed607b9916059fbfbaf08c5e845f (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import os

import pytest

from conftest import assert_complete


class TestMake:
    @pytest.mark.complete("make -f Ma", cwd="make")
    def test_1(self, completion):
        assert completion == "kefile"

    @pytest.mark.complete("make .", cwd="make", require_cmd=True)
    def test_2(self, bash, completion):
        """Hidden targets."""
        assert completion == ".cache/ .test_passes".split()
        os.remove(f"{bash.cwd}/make/extra_makefile")

    @pytest.mark.complete("make .cache/", cwd="make", require_cmd=True)
    def test_3(self, bash, completion):
        assert completion == ".cache/1 .cache/2".split()
        os.remove(f"{bash.cwd}/make/extra_makefile")

    @pytest.mark.complete("make ", cwd="shared/empty_dir")
    def test_4(self, completion):
        assert not completion

    @pytest.mark.complete("make -j ")
    def test_5(self, completion):
        assert completion

    @pytest.mark.complete("make ", cwd="make", require_cmd=True)
    def test_6(self, bash, completion):
        assert completion == "all clean extra_makefile install sample".split()
        os.remove(f"{bash.cwd}/make/extra_makefile")

    @pytest.mark.complete("make .cache/.", cwd="make", require_cmd=True)
    def test_7(self, bash, completion):
        assert completion == ".cache/.1 .cache/.2".split()
        os.remove(f"{bash.cwd}/make/extra_makefile")

    @pytest.mark.complete("make -C make ", require_cmd=True)
    def test_8(self, bash, completion):
        assert completion == "all clean extra_makefile install sample".split()
        os.remove(f"{bash.cwd}/make/extra_makefile")

    @pytest.mark.complete("make -nC make ", require_cmd=True)
    def test_8n(self, bash, completion):
        assert completion == "all clean extra_makefile install sample".split()
        os.remove(f"{bash.cwd}/make/extra_makefile")

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


@pytest.mark.bashcomp(require_cmd=True, cwd="make/test2")
class TestMake2:
    def test_github_issue_544_1(self, bash):
        completion = assert_complete(bash, "make ab")
        assert completion == "c/xyz"

    def test_github_issue_544_2(self, bash):
        completion = assert_complete(bash, "make 1")
        assert completion == "23/"

    def test_github_issue_544_3(self, bash):
        completion = assert_complete(bash, "make 123/")
        assert completion == ["123/xaa", "123/xbb"]

    def test_github_issue_544_4(self, bash):
        completion = assert_complete(bash, "make 123/xa")
        assert completion == "a"

    def test_subdir_1(self, bash):
        completion = assert_complete(bash, "make sub1")
        assert completion == "test/bar/"

    def test_subdir_2(self, bash):
        completion = assert_complete(bash, "make sub2")
        assert completion == "test/bar/alpha"

    def test_subdir_3(self, bash):
        completion = assert_complete(bash, "make sub3")
        assert completion == "test/"

    def test_subdir_4(self, bash):
        completion = assert_complete(bash, "make sub4")
        assert completion == "sub4test/bar/ sub4test2/foo/gamma".split()