Commit 4d62b5b9 authored by Chris's avatar Chris
Browse files

fix: Remove Arduino entry points

Improved flexibility by removing the Arduino entry points in favor of manual calls to setup/loop that the user can call from their entry point.  This is the more common use case for Arudino.

Also added the gtest/gmock_main files to the PlatformIO ignore list since we are not supporting that feature.
parent de99386b
...@@ -92,6 +92,22 @@ GTEST_API_ void InitGoogleMock(int* argc, char** argv); ...@@ -92,6 +92,22 @@ GTEST_API_ void InitGoogleMock(int* argc, char** argv);
// UNICODE mode. // UNICODE mode.
GTEST_API_ void InitGoogleMock(int* argc, wchar_t** argv); GTEST_API_ void InitGoogleMock(int* argc, wchar_t** argv);
#ifdef ARDUINO
inline void gmock_setup() {
// Since Arduino doesn't have a command line, fake out the argc/argv arguments
int argc = 1;
const auto arg0 = "PlatformIO";
char* argv0 = const_cast<char*>(arg0);
char** argv = &argv0;
// Since Google Mock depends on Google Test, InitGoogleMock() is
// also responsible for initializing Google Test. Therefore there's
// no need for calling testing::InitGoogleTest() separately.
testing::InitGoogleMock(&argc, argv);
}
inline void gmock_loop() { RUN_ALL_TESTS(); }
#endif
} // namespace testing } // namespace testing
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_H_ #endif // GMOCK_INCLUDE_GMOCK_GMOCK_H_
...@@ -32,22 +32,6 @@ ...@@ -32,22 +32,6 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#ifdef ARDUINO
void setup() {
// Since Arduino doesn't have a command line, fake out the argc/argv arguments
int argc = 1;
const auto arg0 = "PlatformIO";
char* argv0 = const_cast<char*>(arg0);
char** argv = &argv0;
// Since Google Mock depends on Google Test, InitGoogleMock() is
// also responsible for initializing Google Test. Therefore there's
// no need for calling testing::InitGoogleTest() separately.
testing::InitGoogleMock(&argc, argv);
}
void loop() { RUN_ALL_TESTS(); }
#else
// MS C++ compiler/linker has a bug on Windows (not on Windows CE), which // MS C++ compiler/linker has a bug on Windows (not on Windows CE), which
// causes a link error when _tmain is defined in a static library and UNICODE // causes a link error when _tmain is defined in a static library and UNICODE
// is enabled. For this reason instead of _tmain, main function is used on // is enabled. For this reason instead of _tmain, main function is used on
...@@ -68,4 +52,3 @@ GTEST_API_ int main(int argc, char** argv) { ...@@ -68,4 +52,3 @@ GTEST_API_ int main(int argc, char** argv) {
testing::InitGoogleMock(&argc, argv); testing::InitGoogleMock(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }
#endif
This diff is collapsed.
...@@ -30,24 +30,8 @@ ...@@ -30,24 +30,8 @@
#include <stdio.h> #include <stdio.h>
#include "gtest/gtest.h" #include "gtest/gtest.h"
#ifdef ARDUINO
void setup() {
// Since Arduino doesn't have a command line, fake out the argc/argv arguments
int argc = 1;
const auto arg0 = "PlatformIO";
char* argv0 = const_cast<char*>(arg0);
char** argv = &argv0;
testing::InitGoogleTest(&argc, argv);
}
void loop() { RUN_ALL_TESTS(); }
#else
GTEST_API_ int main(int argc, char **argv) { GTEST_API_ int main(int argc, char **argv) {
printf("Running main() from %s\n", __FILE__); printf("Running main() from %s\n", __FILE__);
testing::InitGoogleTest(&argc, argv); testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }
#endif
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
"googlemock/CMakeLists.txt", "googlemock/CMakeLists.txt",
"googlemock/Makefile.am", "googlemock/Makefile.am",
"googlemock/configure.ac", "googlemock/configure.ac",
"googlemock/gmock_main.cc",
"googletest/cmake", "googletest/cmake",
"googletest/codegear", "googletest/codegear",
"googletest/m4", "googletest/m4",
...@@ -41,7 +42,8 @@ ...@@ -41,7 +42,8 @@
"googletest/xcode", "googletest/xcode",
"googletest/CMakeLists.txt", "googletest/CMakeLists.txt",
"googletest/Makefile.am", "googletest/Makefile.am",
"googletest/configure.ac" "googletest/configure.ac",
"googletest/gtest_main.cc"
] ]
}, },
"build": { "build": {
......
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