mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 03:42:50 +08:00
test_build
Summary: Ensure copyright header consistency and translation unit name uniqueness. Reviewed By: nikhilaravi Differential Revision: D20438802 fbshipit-source-id: 9820cfe4c6efab016a0a8589dfa24bb526692f83
This commit is contained in:
parent
20e457ca0e
commit
fa81953380
@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||||
|
|
||||||
# flake8: noqa
|
# flake8: noqa
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||||
|
|
||||||
__version__ = "0.1.1"
|
__version__ = "0.1.1"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
|
||||||
from itertools import islice
|
from itertools import islice
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||||
|
|
||||||
from itertools import tee
|
from itertools import tee
|
||||||
from math import cos, pi, sin
|
from math import cos, pi, sin
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||||
|
|
||||||
# run this script from the project root using `./scripts/build_docs.sh`
|
# run this script from the project root using `./scripts/build_docs.sh`
|
||||||
|
|
||||||
@ -57,4 +57,4 @@ else
|
|||||||
echo "Starting local server"
|
echo "Starting local server"
|
||||||
echo "-----------------------------------"
|
echo "-----------------------------------"
|
||||||
yarn start
|
yarn start
|
||||||
fi
|
fi
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $0 [-b]"
|
echo "Usage: $0 [-b]"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
|
||||||
from itertools import product
|
from itertools import product
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
|
||||||
from itertools import product
|
from itertools import product
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
|
||||||
from itertools import product
|
from itertools import product
|
||||||
|
45
tests/test_build.py
Normal file
45
tests/test_build.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||||
|
import unittest
|
||||||
|
from collections import Counter
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# This file groups together tests which look at the code without running it.
|
||||||
|
|
||||||
|
|
||||||
|
class TestBuild(unittest.TestCase):
|
||||||
|
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.
|
||||||
|
test_dir = Path(__file__).resolve().parent
|
||||||
|
source_dir = test_dir.parent / "pytorch3d"
|
||||||
|
|
||||||
|
stems = []
|
||||||
|
for extension in [".cu", ".cpp"]:
|
||||||
|
files = source_dir.glob(f"**/*{extension}")
|
||||||
|
stems.extend(f.stem for f in files)
|
||||||
|
|
||||||
|
counter = Counter(stems)
|
||||||
|
for k, v in counter.items():
|
||||||
|
self.assertEqual(v, 1, f"Too many files with stem {k}.")
|
||||||
|
|
||||||
|
def test_copyright(self):
|
||||||
|
test_dir = Path(__file__).resolve().parent
|
||||||
|
root_dir = test_dir.parent
|
||||||
|
|
||||||
|
extensions = ("py", "cu", "cuh", "cpp", "h", "hpp", "sh")
|
||||||
|
|
||||||
|
expect = (
|
||||||
|
"Copyright (c) Facebook, Inc. and its affiliates."
|
||||||
|
+ " All rights reserved.\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
for extension in extensions:
|
||||||
|
for i in root_dir.glob(f"**/*.{extension}"):
|
||||||
|
with open(i) as f:
|
||||||
|
firstline = f.readline()
|
||||||
|
if firstline.startswith(("# -*-", "#!")):
|
||||||
|
firstline = f.readline()
|
||||||
|
self.assertTrue(
|
||||||
|
firstline.endswith(expect),
|
||||||
|
f"{i} missing copyright header.",
|
||||||
|
)
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
|
Loading…
x
Reference in New Issue
Block a user