Skip to content

Commit 224bffc

Browse files
committed
Introduce test skip markers for Sandcastle
Simplify the markers a bit to make them more expressive
1 parent 09e5a93 commit 224bffc

22 files changed

+114
-118
lines changed

test/benchmark_utils/test_benchmark_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
import torch
1616
import torch.utils.benchmark as benchmark_utils
1717
from torch.testing._internal.common_utils import (
18-
IS_SANDCASTLE,
1918
IS_WINDOWS,
2019
run_tests,
20+
skipIfSandcastle,
2121
slowTest,
2222
TEST_WITH_ASAN,
2323
TestCase,
@@ -188,7 +188,7 @@ def test_timer(self):
188188
self.assertIsInstance(sample, float)
189189

190190
@slowTest
191-
@unittest.skipIf(IS_SANDCASTLE, "C++ timing is OSS only.")
191+
@skipIfSandcastle("C++ timing is OSS only.")
192192
@unittest.skipIf(True, "Failing on clang, see 74398")
193193
def test_timer_tiny_fast_snippet(self):
194194
timer = benchmark_utils.Timer(
@@ -200,7 +200,7 @@ def test_timer_tiny_fast_snippet(self):
200200
self.assertIsInstance(median, float)
201201

202202
@slowTest
203-
@unittest.skipIf(IS_SANDCASTLE, "C++ timing is OSS only.")
203+
@skipIfSandcastle("C++ timing is OSS only.")
204204
@unittest.skipIf(True, "Failing on clang, see 74398")
205205
def test_cpp_timer(self):
206206
timer = benchmark_utils.Timer(
@@ -494,7 +494,7 @@ class MockCudaTimer(benchmark_utils.Timer):
494494

495495
@slowTest
496496
@unittest.skipIf(IS_WINDOWS, "Valgrind is not supported on Windows.")
497-
@unittest.skipIf(IS_SANDCASTLE, "Valgrind is OSS only.")
497+
@skipIfSandcastle("Valgrind is OSS only.")
498498
@unittest.skipIf(TEST_WITH_ASAN, "fails on asan")
499499
def test_collect_callgrind(self):
500500
with self.assertRaisesRegex(
@@ -575,7 +575,7 @@ def add_one(x):
575575

576576
@slowTest
577577
@unittest.skipIf(IS_WINDOWS, "Valgrind is not supported on Windows.")
578-
@unittest.skipIf(IS_SANDCASTLE, "Valgrind is OSS only.")
578+
@skipIfSandcastle("Valgrind is OSS only.")
579579
@unittest.skipIf(True, "Failing on clang, see 74398")
580580
def test_collect_cpp_callgrind(self):
581581
timer = benchmark_utils.Timer(

test/export/test_export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@
7171
find_library_location,
7272
IS_FBCODE,
7373
IS_MACOS,
74-
IS_SANDCASTLE,
7574
IS_WINDOWS,
7675
run_tests,
7776
skipIfCrossRef,
77+
skipIfSandcastleOr,
7878
skipIfXpu,
7979
TEST_TRANSFORMERS,
8080
TEST_WITH_CROSSREF,

test/jit/test_backends.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@
33
import io
44
import os
55
import sys
6-
import unittest
76

87
import torch
98
import torch._C
109
from torch.jit.mobile import _load_for_lite_interpreter
1110
from torch.testing import FileCheck
1211
from torch.testing._internal.common_utils import (
1312
find_library_location,
14-
IS_FBCODE,
1513
IS_MACOS,
16-
IS_SANDCASTLE,
1714
IS_WINDOWS,
1815
raise_on_run_directly,
16+
skipIfMetaOr,
1917
skipIfRocm,
2018
TEST_WITH_ROCM,
2119
)
@@ -60,8 +58,8 @@ def sub_accum(self, x, h):
6058

6159

6260
# This is ignored in IS_WINDOWS or IS_MACOS cases. Hence we need the one in TestBackends.
63-
@unittest.skipIf(
64-
TEST_WITH_ROCM or IS_SANDCASTLE or IS_WINDOWS or IS_MACOS or IS_FBCODE,
61+
@skipIfMetaOr(
62+
TEST_WITH_ROCM or IS_WINDOWS or IS_MACOS,
6563
"Non-portable load_library call used in test",
6664
)
6765
class JitBackendTestCase(JitTestCase):
@@ -446,8 +444,8 @@ def test_errors(self):
446444

447445

448446
# This is needed for IS_WINDOWS or IS_MACOS to skip the tests.
449-
@unittest.skipIf(
450-
TEST_WITH_ROCM or IS_SANDCASTLE or IS_WINDOWS or IS_MACOS or IS_FBCODE,
447+
@skipIfMetaOr(
448+
TEST_WITH_ROCM or IS_WINDOWS or IS_MACOS,
451449
"Non-portable load_library call used in test",
452450
)
453451
class TestBackends(JitTestCase):
@@ -509,8 +507,8 @@ def forward(self, x, h):
509507

510508

511509
# This is ignored in IS_WINDOWS or IS_MACOS cases. Hence we need the one in TestBackends.
512-
@unittest.skipIf(
513-
TEST_WITH_ROCM or IS_SANDCASTLE or IS_WINDOWS or IS_MACOS or IS_FBCODE,
510+
@skipIfMetaOr(
511+
TEST_WITH_ROCM or IS_WINDOWS or IS_MACOS,
514512
"Non-portable load_library call used in test",
515513
)
516514
class JitBackendTestCaseWithCompiler(JitTestCase):
@@ -692,8 +690,8 @@ def test_execution(self):
692690

693691

694692
# This is needed for IS_WINDOWS or IS_MACOS to skip the tests.
695-
@unittest.skipIf(
696-
IS_SANDCASTLE or IS_WINDOWS or IS_MACOS or IS_FBCODE,
693+
@skipIfMetaOr(
694+
IS_WINDOWS or IS_MACOS,
697695
"Non-portable load_library call used in test",
698696
)
699697
class TestBackendsWithCompiler(JitTestCase):

test/jit/test_class_type.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import io
55
import os
66
import sys
7-
import unittest
87
from typing import Any
98

109
import torch
@@ -21,6 +20,7 @@
2120
from torch.testing._internal.common_utils import (
2221
IS_SANDCASTLE,
2322
raise_on_run_directly,
23+
skipIfSandcastle,
2424
skipIfTorchDynamo,
2525
)
2626
from torch.testing._internal.jit_utils import JitTestCase, make_global
@@ -542,7 +542,7 @@ def fun(x: Any):
542542
sc = torch.jit.script(fun)
543543

544544
@skipIfTorchDynamo("Test does not work with TorchDynamo")
545-
@unittest.skipIf(IS_SANDCASTLE, "Importing like this doesn't work in fbcode")
545+
@skipIfSandcastle("Importing like this doesn't work in fbcode")
546546
def test_imported_classes(self):
547547
import jit._imported_class_test.bar
548548
import jit._imported_class_test.foo

test/jit/test_tracer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
from torch.testing._internal.common_cuda import with_tf32_off
2929
from torch.testing._internal.common_utils import (
3030
enable_profiling_mode_for_profiling_tests,
31-
IS_SANDCASTLE,
3231
raise_on_run_directly,
3332
skipIfCompiledWithoutNumpy,
3433
skipIfCrossRef,
34+
skipIfSandcastle,
3535
skipIfTorchDynamo,
3636
suppress_warnings,
3737
TemporaryFileName,
@@ -942,7 +942,7 @@ def foo(a):
942942
def test_ge_unoptimized(self):
943943
self.run_ge_tests(False, False)
944944

945-
@unittest.skipIf(IS_SANDCASTLE, "NYI: fuser support for Sandcastle")
945+
@skipIfSandcastle("NYI: fuser support for Sandcastle")
946946
@enable_cpu_fuser
947947
def test_ge_optimized(self):
948948
with enable_profiling_mode_for_profiling_tests():

test/package/test_directory_reader.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@
99

1010
import torch
1111
from torch.package import PackageExporter, PackageImporter
12-
from torch.testing._internal.common_utils import (
13-
IS_FBCODE,
14-
IS_SANDCASTLE,
15-
IS_WINDOWS,
16-
run_tests,
17-
)
12+
from torch.testing._internal.common_utils import IS_WINDOWS, run_tests, skipIfMetaOr
1813

1914

2015
try:
@@ -38,8 +33,8 @@
3833
packaging_directory = Path(__file__).parent
3934

4035

41-
@skipIf(
42-
IS_FBCODE or IS_SANDCASTLE or IS_WINDOWS,
36+
@skipIfMetaOr(
37+
IS_WINDOWS,
4338
"Tests that use temporary files are disabled in fbcode",
4439
)
4540
class DirectoryReaderTest(PackageTestCase):

test/package/test_load_bc_packages.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# Owner(s): ["oncall: package/deploy"]
22

33
from pathlib import Path
4-
from unittest import skipIf
54

65
from torch.package import PackageImporter
7-
from torch.testing._internal.common_utils import IS_FBCODE, IS_SANDCASTLE, run_tests
6+
from torch.testing._internal.common_utils import run_tests, skipIfMeta
87

98

109
try:
@@ -19,28 +18,19 @@
1918
class TestLoadBCPackages(PackageTestCase):
2019
"""Tests for checking loading has backwards compatiblity"""
2120

22-
@skipIf(
23-
IS_FBCODE or IS_SANDCASTLE,
24-
"Tests that use temporary files are disabled in fbcode",
25-
)
21+
@skipIfMeta("Tests that use temporary files are disabled in fbcode")
2622
def test_load_bc_packages_nn_module(self):
2723
"""Tests for backwards compatible nn module"""
2824
importer1 = PackageImporter(f"{packaging_directory}/test_nn_module.pt")
2925
importer1.load_pickle("nn_module", "nn_module.pkl")
3026

31-
@skipIf(
32-
IS_FBCODE or IS_SANDCASTLE,
33-
"Tests that use temporary files are disabled in fbcode",
34-
)
27+
@skipIfMeta("Tests that use temporary files are disabled in fbcode")
3528
def test_load_bc_packages_torchscript_module(self):
3629
"""Tests for backwards compatible torchscript module"""
3730
importer2 = PackageImporter(f"{packaging_directory}/test_torchscript_module.pt")
3831
importer2.load_pickle("torchscript_module", "torchscript_module.pkl")
3932

40-
@skipIf(
41-
IS_FBCODE or IS_SANDCASTLE,
42-
"Tests that use temporary files are disabled in fbcode",
43-
)
33+
@skipIfMeta("Tests that use temporary files are disabled in fbcode")
4434
def test_load_bc_packages_fx_module(self):
4535
"""Tests for backwards compatible fx module"""
4636
importer3 = PackageImporter(f"{packaging_directory}/test_fx_module.pt")

test/package/test_misc.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
from io import BytesIO
88
from pathlib import Path
99
from textwrap import dedent
10-
from unittest import skipIf
1110

1211
from torch.package import is_from_package, PackageExporter, PackageImporter
1312
from torch.package.package_exporter import PackagingError
1413
from torch.testing._internal.common_utils import (
15-
IS_FBCODE,
16-
IS_SANDCASTLE,
1714
run_tests,
15+
skipIfMeta,
1816
skipIfTorchDynamo,
1917
)
2018

@@ -191,10 +189,7 @@ def test_python_version(self):
191189

192190
self.assertEqual(hi.python_version(), platform.python_version())
193191

194-
@skipIf(
195-
IS_FBCODE or IS_SANDCASTLE,
196-
"Tests that use temporary files are disabled in fbcode",
197-
)
192+
@skipIfMeta("Tests that use temporary files are disabled in fbcode")
198193
def test_load_python_version_from_package(self):
199194
"""Tests loading a package with a python version embdded"""
200195
importer1 = PackageImporter(

test/package/test_model.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import torch
88
from torch.package import PackageExporter, PackageImporter, sys_importer
9-
from torch.testing._internal.common_utils import IS_FBCODE, IS_SANDCASTLE, run_tests
9+
from torch.testing._internal.common_utils import run_tests, skipIfMeta
1010

1111

1212
try:
@@ -32,10 +32,7 @@
3232
class ModelTest(PackageTestCase):
3333
"""End-to-end tests packaging an entire model."""
3434

35-
@skipIf(
36-
IS_FBCODE or IS_SANDCASTLE,
37-
"Tests that use temporary files are disabled in fbcode",
38-
)
35+
@skipIfMeta("Tests that use temporary files are disabled in fbcode")
3936
def test_resnet(self):
4037
resnet = resnet18()
4138

test/package/test_package_script.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
import torch
88
from torch.package import PackageExporter, PackageImporter
99
from torch.testing._internal.common_utils import (
10-
IS_FBCODE,
11-
IS_SANDCASTLE,
1210
run_tests,
11+
skipIfMeta,
1312
skipIfTorchDynamo,
1413
)
1514

@@ -196,10 +195,7 @@ def test_save_scriptmodule(self):
196195
input = torch.rand(1, 2, 3)
197196
self.assertEqual(loaded_mod(input), scripted_mod(input))
198197

199-
@skipIf(
200-
IS_FBCODE or IS_SANDCASTLE,
201-
"Tests that use temporary files are disabled in fbcode",
202-
)
198+
@skipIfMeta("Tests that use temporary files are disabled in fbcode")
203199
def test_save_scriptmodule_file(self):
204200
"""
205201
Test basic saving of ScriptModule in file.

0 commit comments

Comments
 (0)