Skip to content

Commit a8b27ea

Browse files
benoit-nexthopmeta-codesync[bot]
authored andcommitted
Add a --exclude flag when running tests
Summary: **Pre-submission checklist** - [x] I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running `pip install -r requirements-dev.txt && pre-commit install` - [x] `pre-commit run` This flag is currently only implemented when building with cmake and can be used to avoid running matching test cases. X-link: facebook/fboss#715 Reviewed By: bigfootjon Differential Revision: D90142763 Pulled By: KevinYakar fbshipit-source-id: b8d3a410253ef0a5475a01ba7ecb963daea1ff61
1 parent ddcdac0 commit a8b27ea

File tree

3 files changed

+44
-5
lines changed

3 files changed

+44
-5
lines changed

build/fbcode_builder/getdeps.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,7 @@ def run_project_cmd(self, args, loader, manifest):
940940
schedule_type=args.schedule_type,
941941
owner=args.test_owner,
942942
test_filter=args.filter,
943+
test_exclude=args.exclude,
943944
retry=args.retry,
944945
no_testpilot=args.no_testpilot,
945946
timeout=args.timeout,
@@ -948,6 +949,7 @@ def run_project_cmd(self, args, loader, manifest):
948949
def setup_project_cmd_parser(self, parser):
949950
parser.add_argument("--test-owner", help="Owner for testpilot")
950951
parser.add_argument("--filter", help="Only run the tests matching the regex")
952+
parser.add_argument("--exclude", help="Exclude tests matching the regex")
951953
parser.add_argument(
952954
"--retry",
953955
type=int,

build/fbcode_builder/getdeps/builder.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,14 @@ def num_jobs(self) -> int:
239239
)
240240

241241
def run_tests(
242-
self, schedule_type, owner, test_filter, retry, no_testpilot, timeout=None
242+
self,
243+
schedule_type,
244+
owner,
245+
test_filter,
246+
test_exclude,
247+
retry,
248+
no_testpilot,
249+
timeout=None,
243250
) -> None:
244251
"""Execute any tests that we know how to run. If they fail,
245252
raise an exception."""
@@ -346,7 +353,14 @@ def _build(self, reconfigure) -> None:
346353
shutil.copy(file, libdir)
347354

348355
def run_tests(
349-
self, schedule_type, owner, test_filter, retry, no_testpilot, timeout=None
356+
self,
357+
schedule_type,
358+
owner,
359+
test_filter,
360+
test_exclude,
361+
retry,
362+
no_testpilot,
363+
timeout=None,
350364
) -> None:
351365
if not self.test_args:
352366
return
@@ -909,7 +923,14 @@ def _build(self, reconfigure: bool) -> None:
909923
)
910924

911925
def run_tests(
912-
self, schedule_type, owner, test_filter, retry: int, no_testpilot, timeout=None
926+
self,
927+
schedule_type,
928+
owner,
929+
test_filter,
930+
test_exclude,
931+
retry: int,
932+
no_testpilot,
933+
timeout=None,
913934
) -> None:
914935
env = self._compute_env()
915936
ctest = path_search(env, "ctest")
@@ -1119,6 +1140,8 @@ def list_tests():
11191140
]
11201141
if test_filter:
11211142
args += ["-R", test_filter]
1143+
if test_exclude:
1144+
args += ["--exclude-regex", test_exclude]
11221145
if timeout is not None:
11231146
args += ["--timeout", str(timeout)]
11241147

@@ -1421,7 +1444,14 @@ def _build(self, reconfigure) -> None:
14211444
f.write("built")
14221445

14231446
def run_tests(
1424-
self, schedule_type, owner, test_filter, retry, no_testpilot, timeout=None
1447+
self,
1448+
schedule_type,
1449+
owner,
1450+
test_filter,
1451+
test_exclude,
1452+
retry,
1453+
no_testpilot,
1454+
timeout=None,
14251455
) -> None:
14261456
# setup.py actually no longer has a standard command for running tests.
14271457
# Instead we let manifest files specify an arbitrary Python file to run

build/fbcode_builder/getdeps/cargo.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,14 @@ def _build(self, reconfigure) -> None:
208208
)
209209

210210
def run_tests(
211-
self, schedule_type, owner, test_filter, retry, no_testpilot, timeout=None
211+
self,
212+
schedule_type,
213+
owner,
214+
test_filter,
215+
test_exclude,
216+
retry,
217+
no_testpilot,
218+
timeout=None,
212219
) -> None:
213220
build_args = []
214221
if self.build_opts.build_type != "Debug":

0 commit comments

Comments
 (0)