Skip to content

Commit ae1387b

Browse files
bottlerfacebook-github-bot
authored andcommitted
let build tests run in conda
Summary: Much of the code is actually available during the conda tests, as long as we look in the right place. We enable some of them. Reviewed By: nikhilaravi Differential Revision: D30249357 fbshipit-source-id: 01c57b6b8c04442237965f23eded594aeb90abfb
1 parent b0dd0c8 commit ae1387b

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

tests/common_testing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def get_pytorch3d_dir() -> Path:
2929
"""
3030
if os.environ.get("INSIDE_RE_WORKER") is not None:
3131
return Path(__file__).resolve().parent
32+
elif os.environ.get("CONDA_BUILD_STATE", "") == "TEST":
33+
return Path(os.environ["SRC_DIR"])
3234
else:
3335
return Path(__file__).resolve().parent.parent
3436

tests/test_build.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,20 @@
99
import unittest
1010
from collections import Counter
1111

12-
from common_testing import get_pytorch3d_dir, get_tests_dir
12+
from common_testing import get_pytorch3d_dir
1313

1414

1515
# This file groups together tests which look at the code without running it.
16-
# When running the tests inside conda's build, the code is not available.
1716
in_conda_build = os.environ.get("CONDA_BUILD_STATE", "") == "TEST"
1817
in_re_worker = os.environ.get("INSIDE_RE_WORKER") is not None
1918

2019

2120
class TestBuild(unittest.TestCase):
22-
@unittest.skipIf(in_conda_build or in_re_worker, "In conda build, or RE worker")
21+
@unittest.skipIf(in_re_worker, "In RE worker")
2322
def test_name_clash(self):
2423
# For setup.py, all translation units need distinct names, so we
2524
# cannot have foo.cu and foo.cpp, even in different directories.
26-
test_dir = get_tests_dir()
27-
source_dir = test_dir.parent / "pytorch3d"
25+
source_dir = get_pytorch3d_dir() / "pytorch3d"
2826

2927
stems = []
3028
for extension in [".cu", ".cpp"]:
@@ -35,10 +33,9 @@ def test_name_clash(self):
3533
for k, v in counter.items():
3634
self.assertEqual(v, 1, f"Too many files with stem {k}.")
3735

38-
@unittest.skipIf(in_conda_build or in_re_worker, "In conda build, or RE worker")
36+
@unittest.skipIf(in_re_worker, "In RE worker")
3937
def test_copyright(self):
40-
test_dir = get_tests_dir()
41-
root_dir = test_dir.parent
38+
root_dir = get_pytorch3d_dir()
4239

4340
extensions = ("py", "cu", "cuh", "cpp", "h", "hpp", "sh")
4441

@@ -48,11 +45,19 @@ def test_copyright(self):
4845

4946
for extension in extensions:
5047
for path in root_dir.glob(f"**/*.{extension}"):
51-
if str(path).endswith(
52-
"pytorch3d/transforms/external/kornia_angle_axis_to_rotation_matrix.py"
53-
):
54-
continue
55-
if str(path).endswith("pytorch3d/csrc/pulsar/include/fastermath.h"):
48+
excluded_files = (
49+
"pytorch3d/transforms/external/kornia_angle_axis_to_rotation_matrix.py",
50+
"pytorch3d/csrc/pulsar/include/fastermath.h",
51+
)
52+
if in_conda_build:
53+
excluded_files += (
54+
"run_test.py",
55+
"run_test.sh",
56+
"conda_test_runner.sh",
57+
"conda_test_env_vars.sh",
58+
)
59+
60+
if str(path).endswith(excluded_files):
5661
continue
5762
with open(path) as f:
5863
firstline = f.readline()
@@ -64,7 +69,7 @@ def test_copyright(self):
6469
if len(files_missing_copyright_header) != 0:
6570
self.fail("\n".join(files_missing_copyright_header))
6671

67-
@unittest.skipIf(in_conda_build or in_re_worker, "In conda build, or RE worker")
72+
@unittest.skipIf(in_re_worker, "In RE worker")
6873
def test_valid_ipynbs(self):
6974
# Check that the ipython notebooks are valid json
7075
root_dir = get_pytorch3d_dir()

0 commit comments

Comments
 (0)