pytorch/test/cpp/jit/torch_python_test.cpp
Dmytro Dzhulgakov 0ae0c9788e Fix misuages for TORCH_CHECK/TORCH_INTERNAL_ASSERT with string (#26897)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/26897

TORCH_INTERNAL_ASSERT("foo") doesn't do what you think it does :)

I'll try to do a fix to catch it in the compiler, but for now - let's fix usages

Found them using regex:
```
ag --cpp "TORCH_(CHECK|INTERNAL_ASSERT)\([ \n]*\"" --multiline
```

Test Plan: Imported from OSS

Differential Revision: D17624299

Pulled By: dzhulgakov

fbshipit-source-id: 74f05737ef598fd92b5e61541ee36de2405df23d
2019-09-27 13:45:19 -07:00

29 lines
751 B
C++

#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(false, "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