9
9
import unittest
10
10
from collections import Counter
11
11
12
- from common_testing import get_pytorch3d_dir , get_tests_dir
12
+ from common_testing import get_pytorch3d_dir
13
13
14
14
15
15
# 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.
17
16
in_conda_build = os .environ .get ("CONDA_BUILD_STATE" , "" ) == "TEST"
18
17
in_re_worker = os .environ .get ("INSIDE_RE_WORKER" ) is not None
19
18
20
19
21
20
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" )
23
22
def test_name_clash (self ):
24
23
# For setup.py, all translation units need distinct names, so we
25
24
# 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"
28
26
29
27
stems = []
30
28
for extension in [".cu" , ".cpp" ]:
@@ -35,10 +33,9 @@ def test_name_clash(self):
35
33
for k , v in counter .items ():
36
34
self .assertEqual (v , 1 , f"Too many files with stem { k } ." )
37
35
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" )
39
37
def test_copyright (self ):
40
- test_dir = get_tests_dir ()
41
- root_dir = test_dir .parent
38
+ root_dir = get_pytorch3d_dir ()
42
39
43
40
extensions = ("py" , "cu" , "cuh" , "cpp" , "h" , "hpp" , "sh" )
44
41
@@ -48,11 +45,19 @@ def test_copyright(self):
48
45
49
46
for extension in extensions :
50
47
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 ):
56
61
continue
57
62
with open (path ) as f :
58
63
firstline = f .readline ()
@@ -64,7 +69,7 @@ def test_copyright(self):
64
69
if len (files_missing_copyright_header ) != 0 :
65
70
self .fail ("\n " .join (files_missing_copyright_header ))
66
71
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" )
68
73
def test_valid_ipynbs (self ):
69
74
# Check that the ipython notebooks are valid json
70
75
root_dir = get_pytorch3d_dir ()
0 commit comments