Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅Unit test improvements #26965

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Marlin/src/inc/Warnings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
#warning "Warning! Don't use dummy thermistors (998/999) for final build!"
#endif

#if NONE(HAS_RESUME_CONTINUE, HOST_PROMPT_SUPPORT)
#if NONE(HAS_RESUME_CONTINUE, HOST_PROMPT_SUPPORT, UNIT_TEST)
#warning "Your Configuration provides no method to acquire user feedback!"
#endif

Expand Down
2 changes: 2 additions & 0 deletions ini/native.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ extra_scripts = ${common.extra_scripts}
build_src_filter = ${env:linux_native.build_src_filter} +<tests>
lib_deps = throwtheswitch/Unity@^2.5.2
test_build_src = true
build_unflags =
build_flags = ${env:linux_native.build_flags} -Werror

#
# Native Simulation
Expand Down
5 changes: 3 additions & 2 deletions test/unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@

static std::list<MarlinTest*> all_marlin_tests;

MarlinTest::MarlinTest(const std::string _name, const void(*_test)(), const int _line)
: name(_name), test(_test), line(_line) {
MarlinTest::MarlinTest(const std::string _name, const void(*_test)(), const char *_file, const int _line)
: name(_name), test(_test), file(_file), line(_line) {
all_marlin_tests.push_back(this);
}

void MarlinTest::run() {
Unity.TestFile = file.c_str();
UnityDefaultTestRun((UnityTestFunction)test, name.c_str(), line);
}

Expand Down
5 changes: 3 additions & 2 deletions test/unit_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
class MarlinTest {
public:
MarlinTest(const std::string name, const void(*test)(), const int line);
MarlinTest(const std::string name, const void(*test)(), const char *_file, const int line);
/**
* Run the test via Unity
*/
Expand All @@ -45,6 +45,7 @@ class MarlinTest {
*/
const std::string name;
const void(*test)();
const std::string file;
const int line;
};

Expand All @@ -66,7 +67,7 @@ class MarlinTest {
#define MARLIN_TEST(SUITE, NAME) \
class _MARLIN_TEST_CLASS_NAME(SUITE, NAME) : public MarlinTest { \
public: \
_MARLIN_TEST_CLASS_NAME(SUITE, NAME)() : MarlinTest(#NAME, (const void(*)())&TestBody, __LINE__) {} \
_MARLIN_TEST_CLASS_NAME(SUITE, NAME)() : MarlinTest(#SUITE "___" #NAME, (const void(*)())&TestBody, __FILE__, __LINE__) {} \
static void TestBody(); \
}; \
const _MARLIN_TEST_CLASS_NAME(SUITE, NAME) _MARLIN_TEST_INSTANCE_NAME(SUITE, NAME); \
Expand Down
Loading