Browse Source

unit test runer: Add capability to use ![tag] to run all-tests-except-tag

Mostly useful for running ![ignore] to skip ignored tests.
Angus Gratton 8 years ago
parent
commit
ca4f5b9ee6

+ 10 - 0
tools/unit-test-app/README.md

@@ -10,3 +10,13 @@ ESP-IDF unit tests are run using Unit Test App. The app can be built with the un
 * `make menuconfig` to configure the Unit Test App.
 * `make menuconfig` to configure the Unit Test App.
 * `make TEST_COMPONENTS=` with `TEST_COMPONENTS` set to names of the components to be included in the test app. Or `make TESTS_ALL=1` to build the test app with all the tests for components having `test` subdirectory.
 * `make TEST_COMPONENTS=` with `TEST_COMPONENTS` set to names of the components to be included in the test app. Or `make TESTS_ALL=1` to build the test app with all the tests for components having `test` subdirectory.
 * Follow the printed instructions to flash, or run `make flash`.
 * Follow the printed instructions to flash, or run `make flash`.
+
+# Running Unit Tests
+
+The unit test loader will prompt by showing a menu of available tests to run:
+
+* Type a number to run a single test.
+* `*` to run all tests.
+* `[tagname]` to run tests with "tag"
+* `![tagname]` to run tests without "tag" (`![ignore]` is very useful as it runs all CI-enabled tests.)
+* `"test name here"` to run test with given name

+ 5 - 1
tools/unit-test-app/components/unity/unity_platform.c

@@ -97,9 +97,13 @@ void unity_run_all_tests()
 
 
 void unity_run_tests_with_filter(const char* filter)
 void unity_run_tests_with_filter(const char* filter)
 {
 {
+    bool invert = filter[0] == '!';
+    if (invert) {
+        filter++;
+    }
     for (const struct test_desc_t* test = s_unity_tests_first; test != NULL; test = test->next)
     for (const struct test_desc_t* test = s_unity_tests_first; test != NULL; test = test->next)
     {
     {
-        if (strstr(test->desc, filter) != NULL)
+        if ((strstr(test->desc, filter) != NULL) == !invert)
         {
         {
             unity_run_single_test(test);
             unity_run_single_test(test);
         }
         }