|
10 | 10 | TEST_DIR = os.path.dirname(__file__) |
11 | 11 | top_dir_path = os.path.realpath(os.path.dirname(test_dir_path)) |
12 | 12 |
|
| 13 | +serial_test_files = [ |
| 14 | + "test-general-buildx.yaml", |
| 15 | + "test-general.yaml", |
| 16 | + "test-push-artifact-buildx.yaml", |
| 17 | + "test-security-scan.yaml", |
| 18 | +] |
| 19 | + |
13 | 20 |
|
14 | 21 | def _get_test_args(file_name: str) -> Optional[List[str]]: |
15 | 22 | if file_name == "test-timeout.yaml": |
@@ -52,14 +59,22 @@ def _get_exit_code(file_name: str) -> int: |
52 | 59 | return os.EX_OK |
53 | 60 |
|
54 | 61 |
|
55 | | -def _get_test_runs(test_dir: str) -> List[Tuple[str, str, Optional[List[str]], int]]: |
56 | | - file_names = sorted( |
57 | | - [ |
58 | | - file_name |
59 | | - for file_name in os.listdir(test_dir) |
60 | | - if file_name.startswith("test-") and file_name.endswith(".yaml") |
61 | | - ] |
62 | | - ) |
| 62 | +def _get_test_runs( |
| 63 | + test_dir: str, serial_tests: bool |
| 64 | +) -> List[Tuple[str, str, Optional[List[str]], int]]: |
| 65 | + file_names = [] |
| 66 | + for file_name in os.listdir(test_dir): |
| 67 | + if serial_tests: |
| 68 | + if file_name in serial_test_files: |
| 69 | + file_names.append(file_name) |
| 70 | + else: |
| 71 | + if ( |
| 72 | + file_name.startswith("test-") |
| 73 | + and file_name.endswith(".yaml") |
| 74 | + and file_name not in serial_test_files |
| 75 | + ): |
| 76 | + file_names.append(file_name) |
| 77 | + |
63 | 78 | return [ |
64 | 79 | (test_dir, file_name, _get_test_args(file_name), _get_exit_code(file_name)) |
65 | 80 | for file_name in file_names |
@@ -107,19 +122,42 @@ def fixture_set_env(): |
107 | 122 |
|
108 | 123 |
|
109 | 124 | @pytest.mark.parametrize( |
110 | | - "test_dir, file_name, args, exit_code", _get_test_runs(f"{TEST_DIR}/test-files") |
| 125 | + "test_dir, file_name, args, exit_code", |
| 126 | + _get_test_runs(test_dir=f"{TEST_DIR}/test-files", serial_tests=False), |
111 | 127 | ) |
112 | 128 | def test_buildrunner_dir(test_dir: str, file_name, args, exit_code): |
113 | 129 | _test_buildrunner_file(test_dir, file_name, args, exit_code) |
114 | 130 |
|
115 | 131 |
|
| 132 | +@pytest.mark.serial |
| 133 | +@pytest.mark.parametrize( |
| 134 | + "test_dir, file_name, args, exit_code", |
| 135 | + _get_test_runs(test_dir=f"{TEST_DIR}/test-files", serial_tests=True), |
| 136 | +) |
| 137 | +def test_serial_buildrunner_dir(test_dir: str, file_name, args, exit_code): |
| 138 | + _test_buildrunner_file(test_dir, file_name, args, exit_code) |
| 139 | + |
| 140 | + |
116 | 141 | @pytest.mark.skipif( |
117 | 142 | "arm64" not in platform.uname().machine, |
118 | 143 | reason="This test should only be run on arm64 architecture", |
119 | 144 | ) |
120 | 145 | @pytest.mark.parametrize( |
121 | 146 | "test_dir, file_name, args, exit_code", |
122 | | - _get_test_runs(f"{TEST_DIR}/test-files/arm-arch"), |
| 147 | + _get_test_runs(test_dir=f"{TEST_DIR}/test-files/arm-arch", serial_tests=False), |
123 | 148 | ) |
124 | 149 | def test_buildrunner_arm_dir(test_dir: str, file_name, args, exit_code): |
125 | 150 | _test_buildrunner_file(test_dir, file_name, args, exit_code) |
| 151 | + |
| 152 | + |
| 153 | +@pytest.mark.serial |
| 154 | +@pytest.mark.skipif( |
| 155 | + "arm64" not in platform.uname().machine, |
| 156 | + reason="This test should only be run on arm64 architecture", |
| 157 | +) |
| 158 | +@pytest.mark.parametrize( |
| 159 | + "test_dir, file_name, args, exit_code", |
| 160 | + _get_test_runs(test_dir=f"{TEST_DIR}/test-files/arm-arch", serial_tests=True), |
| 161 | +) |
| 162 | +def test_serial_buildrunner_arm_dir(test_dir: str, file_name, args, exit_code): |
| 163 | + _test_buildrunner_file(test_dir, file_name, args, exit_code) |
0 commit comments