-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from minayaserrano/google-test-migration
Google test migration
- Loading branch information
Showing
9 changed files
with
98 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include <Arduino.h> | ||
|
||
void setup() { delay(1000); } | ||
|
||
void loop() { delay(1000); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Modify GoogletestTestCaseParser to allow Renode log format | ||
# https://github.com/platformio/platformio-core/blob/master/platformio/test/runners/googletest.py | ||
|
||
import os | ||
import re | ||
|
||
from platformio.public import GoogletestTestRunner | ||
from platformio.test.runners.googletest import GoogletestTestCaseParser | ||
|
||
|
||
class CustomGoogletestTestCaseParser(GoogletestTestCaseParser): | ||
# Examples: | ||
# 12:02:09.8136 [INFO] uart0: [host: 2.12s (+11.59ms)|virt: 1.03s (+0.21ms)] [ RUN ] FooTest.Bar | ||
# ... | ||
# 12:02:09.8136 [INFO] uart0: [host: 2.12s (+11.59ms)|virt: 1.03s (+0.21ms)] [ FAILED ] FooTest.Bar (0 ms) | ||
STATUS__NAME_RE = r".*\[\s+(?P<status>[A-Z]+)\s+\]\s+(?P<name>[^\(\s]+)" | ||
|
||
# Examples: | ||
# 12:02:09.8136 [INFO] uart0: [host: 2.12s (+11.59ms)|virt: 1.03s (+0.21ms)] [ RUN ] FooTest.Bar | ||
# 12:02:09.8136 [INFO] uart0: [host: 2.12s (+11.59ms)|virt: 1.03s (+0.21ms)] test/test_gtest/test_main.cpp:26: Failure | ||
# 12:02:09.8136 [INFO] uart0: [host: 2.12s (+11.59ms)|virt: 1.03s (+0.21ms)] Y:\core\examples\unit-testing\googletest\test\test_gtest\test_main.cpp:26: Failure | ||
SOURCE_MESSAGE_RE = r".*(?P<source_file>.+):(?P<source_line>\d+):(?P<message>.*)$" | ||
|
||
def _parse_status_and_name(self, line): | ||
result = (None, None) | ||
line = line.strip() | ||
# if not line.startswith("["): | ||
# return result | ||
match = re.search(self.STATUS__NAME_RE, line) | ||
if not match: | ||
return result | ||
return match.group("status"), match.group("name") | ||
|
||
|
||
class CustomTestRunner(GoogletestTestRunner): | ||
EXTRA_LIB_DEPS = ["google/googletest@^1.15.2"] | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self._tc_parser = CustomGoogletestTestCaseParser() | ||
os.environ["GTEST_COLOR"] = "no" # disable ANSI symbols |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
#ifdef UNIT_TEST | ||
|
||
#include <RoboCaddie.h> | ||
#include <unity.h> | ||
#include <gmock/gmock.h> | ||
#include <gtest/gtest.h> | ||
|
||
#include "RoboCaddie/RoboCaddieTests.h" | ||
|
||
int main() { return run_tests(); } | ||
int main(int argc, char **argv) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
|
||
if (RUN_ALL_TESTS()) { | ||
}; | ||
|
||
// Always return zero-code and allow PlatformIO to parse results | ||
return 0; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import time | ||
|
||
def waiting_for_restart_before_embedding_tests(source, target, env): | ||
time.sleep(2) | ||
|
||
Import("env") | ||
env.AddPostAction("upload", waiting_for_restart_before_embedding_tests) |