Skip to content
Snippets Groups Projects
Commit 270fe6c1 authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

tests: add an option to force fail on warning for certain tests

Several subsequent patches will be required so this can be used for our tests.

Gitlab: #899
Change-Id: I3939770ed34fe40aafa2ab93e2bab3cd77a20955
parent 690148ea
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,35 @@
#include <windows.h>
#endif
// Removes the given argument from the command line arguments, and invokes the callback
// function with the removed argument if it was found.
// This is required for custom args as quick_test_main_with_setup() will
// fail if given an invalid command-line argument.
void
Utils::remove_argument(char** argv,
int& argc,
const std::string& arg_to_remove,
std::function<void()> callback)
{
// Remove arg_to_remove from argv, as quick_test_main_with_setup() will
// fail if given an invalid command-line argument.
auto new_end = std::remove_if(argv + 1, argv + argc, [&](char* arg_ptr) {
if (std::string(arg_ptr).compare(arg_to_remove) == 0) {
// Invoke the callback function with the removed argument.
callback();
return true;
} else {
return false;
}
});
// If any occurrences were removed...
if (new_end != argv + argc) {
// Adjust the argument count.
argc = std::distance(argv, new_end);
}
}
void
Utils::testVulkanSupport()
{
......
......@@ -56,6 +56,12 @@ class LRCInstance;
namespace Utils {
// Helper used to remove app arguments.
void remove_argument(char** argv,
int& argc,
const std::string& arg_to_remove,
std::function<void()> callback);
// Throws if Vulkan cannot be instantiated.
void testVulkanSupport();
......
......@@ -108,7 +108,7 @@ function(setup_test TEST_NAME TEST_SOURCES TEST_INPUT)
set_target_properties(${TEST_BINARY_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${BUILD_TYPE} ${OUTPUT_DIRECTORY})
endif()
add_test(NAME ${TEST_NAME} COMMAND ${TEST_BINARY_NAME} -input ${TEST_INPUT} -mutejamid)
add_test(NAME ${TEST_NAME} COMMAND ${TEST_BINARY_NAME} -input ${TEST_INPUT} --mutejamid)
endfunction()
# QML tests
......
......@@ -145,18 +145,12 @@ main(int argc, char** argv)
bool muteDring {false};
// Remove "-mutejamid" from argv, as quick_test_main_with_setup() will
// fail if given an invalid command-line argument.
auto end = std::remove_if(argv + 1, argv + argc, [](char* argv) {
return (strcmp(argv, "-mutejamid") == 0);
});
// We likely want to mute the daemon for log clarity.
Utils::remove_argument(argv, argc, "--mutejamid", [&]() { muteDring = true; });
if (end != argv + argc) {
muteDring = true;
// Allow the user to enable fatal warnings for certain tests.
Utils::remove_argument(argv, argc, "--failonwarn", [&]() { qputenv("QT_FATAL_WARNINGS", "1"); });
// Adjust the argument count.
argc = std::distance(argv, end);
}
#ifdef WITH_WEBENGINE
QtWebEngineQuick::initialize();
#endif
......
......@@ -39,18 +39,11 @@ main(int argc, char* argv[])
if (!envSet)
return 1;
// Remove "-mutejamid" from argv, as quick_test_main_with_setup() will
// fail if given an invalid command-line argument.
auto end = std::remove_if(argv + 1, argv + argc, [](char* argv) {
return (strcmp(argv, "-mutejamid") == 0);
});
// We likely want to mute the daemon for log clarity.
Utils::remove_argument(argv, argc, "--mutejamid", [&]() { globalEnv.muteDring = true; });
if (end != argv + argc) {
globalEnv.muteDring = true;
// Adjust the argument count.
argc = std::distance(argv, end);
}
// Allow the user to enable fatal warnings for certain tests.
Utils::remove_argument(argv, argc, "--failonwarn", [&]() { qputenv("QT_FATAL_WARNINGS", "1"); });
QApplication a(argc, argv);
a.processEvents();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment