From 1e4749602d4956af23204de8bee4159e5f9f125f Mon Sep 17 00:00:00 2001 From: Jeremy Reizenstein Date: Mon, 20 Apr 2020 12:17:49 -0700 Subject: [PATCH] skip code tests in conda build Summary: None of the current test_build tests make sense during `conda build`. Also remove the unnecessary dependency on the `six` library. Reviewed By: nikhilaravi Differential Revision: D20893852 fbshipit-source-id: 685f0446eaa0bd9151eeee89fc630a1ddc0252ff --- packaging/pytorch3d/meta.yaml | 1 - tests/test_build.py | 15 ++++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packaging/pytorch3d/meta.yaml b/packaging/pytorch3d/meta.yaml index 173fae0c..2856815f 100644 --- a/packaging/pytorch3d/meta.yaml +++ b/packaging/pytorch3d/meta.yaml @@ -19,7 +19,6 @@ requirements: run: - python - numpy >=1.11 - - six - torchvision >=0.5 - fvcore {{ environ.get('CONDA_PYTORCH_CONSTRAINT') }} diff --git a/tests/test_build.py b/tests/test_build.py index 72c2b39b..1c47c5de 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -1,13 +1,17 @@ # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. +import os import unittest from collections import Counter from pathlib import Path # This file groups together tests which look at the code without running it. +# When running the tests inside conda's build, the code is not available. +in_conda_build = os.environ.get("CONDA_BUILD_STATE", "") == "TEST" class TestBuild(unittest.TestCase): + @unittest.skipIf(in_conda_build, "In conda build") def test_name_clash(self): # For setup.py, all translation units need distinct names, so we # cannot have foo.cu and foo.cpp, even in different directories. @@ -23,6 +27,7 @@ class TestBuild(unittest.TestCase): for k, v in counter.items(): self.assertEqual(v, 1, f"Too many files with stem {k}.") + @unittest.skipIf(in_conda_build, "In conda build") def test_deprecated_usage(self): # Check certain expressions do not occur in the csrc code test_dir = Path(__file__).resolve().parent @@ -44,6 +49,7 @@ class TestBuild(unittest.TestCase): ) self.assertFalse(found, msg) + @unittest.skipIf(in_conda_build, "In conda build") def test_copyright(self): test_dir = Path(__file__).resolve().parent root_dir = test_dir.parent @@ -55,17 +61,8 @@ class TestBuild(unittest.TestCase): + " All rights reserved.\n" ) - conda_generated_files = [ - "run_test.py", - "run_test.sh", - "conda_test_runner.sh", - "conda_test_env_vars.sh", - ] - for extension in extensions: for i in root_dir.glob(f"**/*.{extension}"): - if i.name in conda_generated_files: - continue with open(i) as f: firstline = f.readline() if firstline.startswith(("# -*-", "#!")):