Changeset View
Changeset View
Standalone View
Standalone View
tests/gtests/gtests_runner.cc
- This file was added.
| #include "gtests_runner.h" | |||||
sergey: Copyright. | |||||
| #include "BLI_utildefines.h" | |||||
| #include "MEM_guardedalloc.h" | |||||
| #include "gflags/gflags.h" | |||||
| #include "gtest/gtest.h" | |||||
| int blender_gtests_runner(int argc, const char **argv) | |||||
| { | |||||
| /* Prepend "Blender test runner" to argv, before passing it to ParseCommandLineFlags. | |||||
| * It expects argv[0] to be an indication of the command to run. */ | |||||
| char **gtests_argv = (char **)MEM_calloc_arrayN(argc, sizeof(char *), "GTest ARGV"); | |||||
sergeyUnsubmitted Not Done Inline ActionsI would use vector<const char*> gtest_argv; and pass gtest_argv.data() to ParseCommandLineFlags. Eliminates manual memory allocation/free. sergey: I would use `vector<const char*> gtest_argv;` and pass `gtest_argv.data()` to… | |||||
| int gtests_argc = 1; | |||||
| gtests_argv[0] = (char *)"Blender test runner"; | |||||
| for (int src_index = 1; src_index < argc; src_index++) { | |||||
| gtests_argv[gtests_argc++] = (char *)argv[src_index]; | |||||
| } | |||||
brechtUnsubmitted Not Done Inline ActionsI don't understand what this does, how is Blender test runner an indication of the command to run? This seems like a description rather than a command. brecht: I don't understand what this does, how is `Blender test runner` an indication of the command to… | |||||
| ::google::SetUsageMessage(std::string("blender --gtests [GTest options]")); | |||||
brechtUnsubmitted Not Done Inline ActionsThis needs to be updated now that it's no longer part of the Blender executable (or removed?). brecht: This needs to be updated now that it's no longer part of the Blender executable (or removed?). | |||||
| ::testing::InitGoogleTest(>ests_argc, gtests_argv); | |||||
| BLENDER_GFLAGS_NAMESPACE::ParseCommandLineFlags(>ests_argc, >ests_argv, true); | |||||
| int status_code = RUN_ALL_TESTS(); | |||||
sergeyUnsubmitted Not Done Inline Actionsconst int sergey: `const int` | |||||
| MEM_freeN(gtests_argv); | |||||
| return status_code; | |||||
| } | |||||
Copyright.