twister: Add Twister execution options to twister.json

Store Twister command line options in twister.json report as
`environment.options` object. It allows to keep the actual
execution context for test results analysis and history comparison.

A new command line option `--report-all-options` enables to report all
command line options applied, including these set as default values.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
This commit is contained in:
Dmitrii Golovanov 2024-05-07 09:11:47 +02:00 committed by Alberto Escolar
commit d45dbc26f0
4 changed files with 40 additions and 8 deletions

View file

@ -11,6 +11,7 @@ from colorama import Fore
import xml.etree.ElementTree as ET
import string
from datetime import datetime
from pathlib import PosixPath
logger = logging.getLogger('twister')
logger.setLevel(logging.DEBUG)
@ -235,12 +236,23 @@ class Reporting:
def json_report(self, filename, version="NA", platform=None):
logger.info(f"Writing JSON report {filename}")
if self.env.options.report_all_options:
report_options = vars(self.env.options)
else:
report_options = self.env.non_default_options()
# Resolve known JSON serialization problems.
for k,v in report_options.items():
report_options[k] = str(v) if type(v) in [PosixPath] else v
report = {}
report["environment"] = {"os": os.name,
"zephyr_version": version,
"toolchain": self.env.toolchain,
"commit_date": self.env.commit_date,
"run_date": self.env.run_date
"run_date": self.env.run_date,
"options": report_options
}
suites = []