big cpp test reorg (#24801)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/24801

This is to fix the ODR-violations in fbcode static builds, which have been broken for several months.

This PR is unfortunately quite large, but the changes are only mechanical:
1. Tests defined in header files -> tests defined in cpp files
2. Remove the `torch::jit::testing` namespace -> `torch::jit`.
3. Single `test.h` file that aggregates all tests.
4. Separate out files for gtest and python versions of the tests instead of using a build flag
5. Add a readme for how to add a new test, and explaining a bit about why the cpp tests are the way they are.

Test Plan: Imported from OSS

Differential Revision: D16878605

Pulled By: suo

fbshipit-source-id: 27b5c077dadd990a5f74e25d01731f9c1f491603
This commit is contained in:
Michael Suo
2019-08-18 16:46:56 -07:00
committed by Facebook Github Bot
parent 85564c1456
commit dfdb86a595
37 changed files with 328 additions and 293 deletions

View File

@@ -0,0 +1,28 @@
#include <test/cpp/jit/tests.h>
#include <c10/util/Exception.h>
namespace torch {
namespace jit {
#if defined(_WIN32)
void runJITCPPTests(bool runCuda) {
TORCH_INTERNAL_ASSERT("JIT tests not yet supported on Windows");
}
#else
#define JIT_TEST(name) test##name();
TORCH_API void runJITCPPTests(bool runCuda) {
TH_FORALL_TESTS(JIT_TEST)
if (runCuda) {
TH_FORALL_TESTS_CUDA(JIT_TEST)
}
// This test is special since it requires prior setup in python.
// So it is not part of the general test list (which is shared between the gtest
// and python test runners), but is instead invoked manually by the
// torch_python_test.cpp
testEvalModeForLoadedModule();
}
#undef JIT_TEST
#endif
} // namespace jit
} // namespace torch