test Refactor unit test scripts. (#2473)

* Refactor unit test scripts.

Does the following:

1. Remove as many dependencies on the operating system shell as possible.
   For example, use of shutil.rmtree(...) instead of os.system('rm -r ...').
   This brings this script a bit closer to being able to run on Windows.
2. Switch from os.system() to subprocess.check_call().
   * This is a bit more secure as check_call() directly invokes the subprocess
     without evaluation the arguments on a command-line.
   * Removes the need to evaluate the return code as check_call() does this.
   * Can directly set environment variables (e.g. env=cmd_env) instead of
     including with subprocess invocation (e.g. BIN=test.bin).
3. Minor cleanup to main.py sys.argv parsing.
4. PEP8 formatting.

* Ignore FileNotFoundError for rmtree('report').

* Back to os.system for gcovr.

* Removed unused shutil import.
This commit is contained in:
Chris Mumford
2021-08-25 06:37:59 -07:00
committed by GitHub
parent 98b9ce5997
commit 53986b4b0e
3 changed files with 128 additions and 108 deletions

View File

@@ -24,7 +24,7 @@ minimal_monochrome = {
"LV_BUILD_EXAMPLES":1,
"LV_FONT_DEFAULT":"\\\"&lv_font_montserrat_14\\\"",
"LV_FONT_DEFAULT":"&lv_font_montserrat_14",
}
@@ -54,7 +54,7 @@ normal_8bit = {
"LV_BUILD_EXAMPLES":1,
"LV_FONT_DEFAULT":"\\\"&lv_font_montserrat_14\\\"",
"LV_FONT_DEFAULT":"&lv_font_montserrat_14",
}
@@ -83,7 +83,7 @@ minimal_16bit = {
"LV_BUILD_EXAMPLES":1,
"LV_FONT_DEFAULT":"\\\"&lv_font_montserrat_14\\\"",
"LV_FONT_DEFAULT":"&lv_font_montserrat_14",
}
@@ -114,7 +114,7 @@ normal_16bit_swap = {
"LV_BUILD_EXAMPLES":1,
"LV_FONT_DEFAULT":"\\\"&lv_font_montserrat_14\\\"",
"LV_FONT_DEFAULT":"&lv_font_montserrat_14",
}
full_32bit = {
@@ -182,7 +182,7 @@ full_32bit = {
"LV_BUILD_EXAMPLES":1,
"LV_FONT_DEFAULT":"\\\"&lv_font_montserrat_24\\\"",
"LV_FONT_DEFAULT":"&lv_font_montserrat_24",
}
test = {
@@ -227,5 +227,5 @@ test = {
"LV_BUILD_EXAMPLES":1,
"LV_FONT_DEFAULT":"\\\"&lv_font_montserrat_14\\\"",
"LV_FONT_DEFAULT":"&lv_font_montserrat_14",
}