|
1 | 1 | import pytest
|
2 | 2 |
|
| 3 | +from conftest import assert_bash_exec |
| 4 | + |
3 | 5 |
|
4 | 6 | class TestGcc:
|
| 7 | + @pytest.fixture(scope="class") |
| 8 | + def gcc_with_completion(self, bash): |
| 9 | + got = assert_bash_exec( |
| 10 | + bash, "gcc --help=common || :", want_output=True |
| 11 | + ) |
| 12 | + if "--completion" not in got: |
| 13 | + pytest.skip("GCC does not support --completion") |
| 14 | + |
| 15 | + @pytest.fixture(scope="class") |
| 16 | + def gcc_x86(self, bash): |
| 17 | + got = assert_bash_exec(bash, "gcc -v || :", want_output=True) |
| 18 | + if "Target: x86" not in got: |
| 19 | + pytest.skip("Not a x86 GCC") |
| 20 | + |
5 | 21 | @pytest.mark.complete("gcc ")
|
6 | 22 | def test_1(self, completion):
|
7 | 23 | assert completion
|
| 24 | + |
| 25 | + @pytest.mark.complete("gcc -fsanitize=add") |
| 26 | + def test_enum_value(self, completion, gcc_with_completion): |
| 27 | + assert completion == "-fsanitize=address" |
| 28 | + |
| 29 | + @pytest.mark.complete("gcc -fsanitize=") |
| 30 | + def test_enum_value_with_eq(self, completion, gcc_with_completion): |
| 31 | + assert "address" in completion |
| 32 | + |
| 33 | + @pytest.mark.complete("gcc -fno-ipa-ic") |
| 34 | + def test_negative_option(self, completion, gcc_with_completion): |
| 35 | + assert "-fno-ipa-icf" in completion |
| 36 | + |
| 37 | + @pytest.mark.complete("gcc -fxyz-abc") |
| 38 | + def test_no_completion(self, completion): |
| 39 | + assert not completion |
| 40 | + |
| 41 | + @pytest.mark.complete("gcc --param ") |
| 42 | + def test_param_with_space(self, completion, gcc_with_completion): |
| 43 | + assert len(completion) > 50 |
| 44 | + # starting with GCC 10.1 param end with = |
| 45 | + assert ( |
| 46 | + "lto-partitions" in completion or "lto-partitions=" in completion |
| 47 | + ) |
| 48 | + |
| 49 | + @pytest.mark.complete("gcc --param=lto-max-p") |
| 50 | + def test_param_with_eq(self, completion, gcc_with_completion): |
| 51 | + # starting with GCC 10.1 param end with = |
| 52 | + assert ( |
| 53 | + completion == "--param=lto-max-partition" |
| 54 | + or completion == "--param=lto-max-partition=" |
| 55 | + ) |
| 56 | + |
| 57 | + @pytest.mark.complete("gcc -march=amd") |
| 58 | + def test_march(self, completion, gcc_with_completion, gcc_x86): |
| 59 | + assert completion == "-march=amdfam10" |
| 60 | + |
| 61 | + @pytest.mark.complete("gcc -march=") |
| 62 | + def test_march_native(self, completion, gcc_with_completion): |
| 63 | + assert "native" in completion |
| 64 | + |
| 65 | + @pytest.mark.complete("gcc -mtune=") |
| 66 | + def test_mtune_generic(self, completion, gcc_with_completion): |
| 67 | + assert "generic" in completion |
0 commit comments