Commit 1e474960 authored by Jeremy Reizenstein's avatar Jeremy Reizenstein Committed by Facebook GitHub Bot
Browse files

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
parent 6207c359
...@@ -19,7 +19,6 @@ requirements: ...@@ -19,7 +19,6 @@ requirements:
run: run:
- python - python
- numpy >=1.11 - numpy >=1.11
- six
- torchvision >=0.5 - torchvision >=0.5
- fvcore - fvcore
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }} {{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
......
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import os
import unittest import unittest
from collections import Counter from collections import Counter
from pathlib import Path from pathlib import Path
# This file groups together tests which look at the code without running it. # 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): class TestBuild(unittest.TestCase):
@unittest.skipIf(in_conda_build, "In conda build")
def test_name_clash(self): def test_name_clash(self):
# For setup.py, all translation units need distinct names, so we # For setup.py, all translation units need distinct names, so we
# cannot have foo.cu and foo.cpp, even in different directories. # cannot have foo.cu and foo.cpp, even in different directories.
...@@ -23,6 +27,7 @@ class TestBuild(unittest.TestCase): ...@@ -23,6 +27,7 @@ class TestBuild(unittest.TestCase):
for k, v in counter.items(): for k, v in counter.items():
self.assertEqual(v, 1, f"Too many files with stem {k}.") self.assertEqual(v, 1, f"Too many files with stem {k}.")
@unittest.skipIf(in_conda_build, "In conda build")
def test_deprecated_usage(self): def test_deprecated_usage(self):
# Check certain expressions do not occur in the csrc code # Check certain expressions do not occur in the csrc code
test_dir = Path(__file__).resolve().parent test_dir = Path(__file__).resolve().parent
...@@ -44,6 +49,7 @@ class TestBuild(unittest.TestCase): ...@@ -44,6 +49,7 @@ class TestBuild(unittest.TestCase):
) )
self.assertFalse(found, msg) self.assertFalse(found, msg)
@unittest.skipIf(in_conda_build, "In conda build")
def test_copyright(self): def test_copyright(self):
test_dir = Path(__file__).resolve().parent test_dir = Path(__file__).resolve().parent
root_dir = test_dir.parent root_dir = test_dir.parent
...@@ -55,17 +61,8 @@ class TestBuild(unittest.TestCase): ...@@ -55,17 +61,8 @@ class TestBuild(unittest.TestCase):
+ " All rights reserved.\n" + " 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 extension in extensions:
for i in root_dir.glob(f"**/*.{extension}"): for i in root_dir.glob(f"**/*.{extension}"):
if i.name in conda_generated_files:
continue
with open(i) as f: with open(i) as f:
firstline = f.readline() firstline = f.readline()
if firstline.startswith(("# -*-", "#!")): if firstline.startswith(("# -*-", "#!")):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment