File: test_gcc.py

package info (click to toggle)
bash-completion 1%3A2.16.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,424 kB
  • sloc: python: 11,241; makefile: 2,471; sh: 934; perl: 85; awk: 55; xml: 29; ansic: 7; java: 5; ruby: 2
file content (74 lines) | stat: -rw-r--r-- 2,586 bytes parent folder | download
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
import pytest

from conftest import assert_bash_exec


class TestGcc:
    @pytest.fixture(scope="class")
    def gcc_with_completion(self, bash):
        got = assert_bash_exec(
            bash, "gcc --help=common || :", want_output=True
        )
        if "--completion" not in got:
            pytest.skip("GCC does not support --completion")

    @pytest.fixture(scope="class")
    def gcc_x86(self, bash):
        got = assert_bash_exec(bash, "gcc -v || :", want_output=True)
        if "Target: x86" not in got:
            pytest.skip("Not a x86 GCC")

    @pytest.mark.complete("gcc ")
    def test_1(self, completion):
        assert completion

    @pytest.mark.complete("gcc -fsanitize=add")
    def test_enum_value(self, completion, gcc_with_completion):
        assert completion == "ress"

    @pytest.mark.complete("gcc -fsanitize=")
    def test_enum_value_with_eq(self, completion, gcc_with_completion):
        assert "address" in completion

    @pytest.mark.complete("gcc -fno-ipa-ic")
    def test_negative_option(self, completion, gcc_with_completion):
        assert "-fno-ipa-icf" in completion

    @pytest.mark.complete("gcc -fxyz-abc")
    def test_no_completion(self, completion):
        assert not completion

    @pytest.mark.complete("gcc --param ")
    def test_param_with_space(self, completion, gcc_with_completion):
        assert len(completion) > 50
        # starting with GCC 10.1 param end with =
        assert (
            "lto-partitions" in completion or "lto-partitions=" in completion
        )

    @pytest.mark.complete("gcc --param=lto-max-p")
    def test_param_with_eq(self, completion, gcc_with_completion):
        # starting with GCC 10.1 param ends with =
        assert completion in ("artition", "artition=")

    @pytest.mark.complete("gcc -march=amd")
    def test_march_amd(self, completion, gcc_with_completion, gcc_x86):
        assert completion == "fam10"

    @pytest.mark.complete("gcc -march=")
    def test_march(self, completion, gcc_with_completion):
        # https://github.com/scop/bash-completion/issues/1201
        # native: x86, some others
        # power*: ppc
        assert "native" in completion or any(
            x.startswith("power") for x in completion
        )

    @pytest.mark.complete("gcc -mtune=")
    def test_mtune(self, completion, gcc_with_completion):
        # https://github.com/scop/bash-completion/issues/1201
        # generic: x86, some others
        # power*: ppc
        assert "generic" in completion or any(
            x.startswith("power") for x in completion
        )