mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
53986b4b0e
* 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.
56 lines
1.6 KiB
Python
Executable File
56 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import defines
|
|
import build
|
|
import shutil
|
|
import test
|
|
import sys
|
|
import os
|
|
|
|
|
|
def build_conf(title, defs):
|
|
print("")
|
|
print("")
|
|
print("============================================")
|
|
print(title)
|
|
print("============================================")
|
|
print("", flush=True)
|
|
|
|
build.clean()
|
|
build.build(defs)
|
|
|
|
|
|
test_only = "test" in sys.argv
|
|
test_report = "report" in sys.argv
|
|
test_noclean = "noclean" in sys.argv
|
|
|
|
if not test_only:
|
|
build_conf("Minimal config monochrome", defines.minimal_monochrome)
|
|
build_conf("Normal config, 8 bit color depth", defines.normal_8bit)
|
|
build_conf("Minimal config, 16 bit color depth", defines.minimal_16bit)
|
|
build_conf("Normal config, 16 bit color depth swapped",
|
|
defines.normal_16bit_swap)
|
|
build_conf("Full config, 32 bit color depth", defines.full_32bit)
|
|
|
|
|
|
files = test.prepare()
|
|
if test_noclean == False:
|
|
build.clean()
|
|
|
|
for f in files:
|
|
name = f[:-2] # test_foo.c -> test_foo
|
|
build.build_test(defines.test, name)
|
|
|
|
if test_report:
|
|
print("")
|
|
print("Generating report")
|
|
print("-----------------------", flush=True)
|
|
try:
|
|
shutil.rmtree('report')
|
|
except FileNotFoundError:
|
|
pass
|
|
os.mkdir('report')
|
|
os.system("gcovr -r ../ --html-details -o report/index.html --exclude-directories '\.\./examples' --exclude-directories 'src/.*' --exclude-directories 'unity' --exclude 'lv_test_.*\.c'")
|
|
os.system("gcovr -r ../ -x report/coverage.xml --exclude-directories '\.\./examples' --exclude-directories 'src/.*' --exclude-directories 'unity' --exclude 'lv_test_.*\.c'")
|
|
print("Done: See report/index.html", flush=True)
|