diff options
| author | tassaron | 2022-05-07 23:29:39 -0400 |
|---|---|---|
| committer | tassaron | 2022-05-07 23:29:39 -0400 |
| commit | a41b1f64ffadcd653ca7d313370bd3b018e34959 (patch) | |
| tree | 2939a9ad105e356d70cc1c7dc502566ea16db612 | |
| parent | eb74e932d8ee9ecd2221629ea84a07b8e317d89f (diff) | |
concatenate trimmed ffmpeg logs to the test report
| -rw-r--r-- | src/command.py | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/src/command.py b/src/command.py index b46498f..0ad2545 100644 --- a/src/command.py +++ b/src/command.py | |||
| @@ -8,6 +8,7 @@ import argparse | |||
| 8 | import os | 8 | import os |
| 9 | import sys | 9 | import sys |
| 10 | import time | 10 | import time |
| 11 | import glob | ||
| 11 | import signal | 12 | import signal |
| 12 | import shutil | 13 | import shutil |
| 13 | import logging | 14 | import logging |
| @@ -106,9 +107,7 @@ class Command(QtCore.QObject): | |||
| 106 | ) | 107 | ) |
| 107 | if not projPath.endswith('.avp'): | 108 | if not projPath.endswith('.avp'): |
| 108 | projPath += '.avp' | 109 | projPath += '.avp' |
| 109 | success = self.core.openProject(self, projPath) | 110 | self.core.openProject(self, projPath) |
| 110 | if not success: | ||
| 111 | quit(1) | ||
| 112 | self.core.selectedComponents = list( | 111 | self.core.selectedComponents = list( |
| 113 | reversed(self.core.selectedComponents)) | 112 | reversed(self.core.selectedComponents)) |
| 114 | self.core.componentListChanged() | 113 | self.core.componentListChanged() |
| @@ -165,7 +164,12 @@ class Command(QtCore.QObject): | |||
| 165 | elif args.no_preview: | 164 | elif args.no_preview: |
| 166 | core.Core.previewEnabled = False | 165 | core.Core.previewEnabled = False |
| 167 | 166 | ||
| 168 | elif 'help' not in sys.argv and args.projpath is None and '--debug' not in sys.argv: | 167 | elif ( |
| 168 | args.projpath is None and | ||
| 169 | 'help' not in sys.argv and | ||
| 170 | '--debug' not in sys.argv and | ||
| 171 | '--test' not in sys.argv | ||
| 172 | ): | ||
| 169 | parser.print_help() | 173 | parser.print_help() |
| 170 | quit(1) | 174 | quit(1) |
| 171 | 175 | ||
| @@ -246,8 +250,6 @@ class Command(QtCore.QObject): | |||
| 246 | return None | 250 | return None |
| 247 | 251 | ||
| 248 | def runTests(self): | 252 | def runTests(self): |
| 249 | core.FILE_LOGLVL = logging.DEBUG | ||
| 250 | core.Core.makeLogger() | ||
| 251 | from . import tests | 253 | from . import tests |
| 252 | test_report = os.path.join(core.Core.logDir, "test_report.log") | 254 | test_report = os.path.join(core.Core.logDir, "test_report.log") |
| 253 | tests.run(test_report) | 255 | tests.run(test_report) |
| @@ -279,10 +281,29 @@ class Command(QtCore.QObject): | |||
| 279 | return | 281 | return |
| 280 | try: | 282 | try: |
| 281 | shutil.copy(os.path.join(core.Core.logDir, "avp_debug.log"), filename) | 283 | shutil.copy(os.path.join(core.Core.logDir, "avp_debug.log"), filename) |
| 284 | with open(filename, "a") as f: | ||
| 285 | f.write(f"{'='*60} debug log ends {'='*60}\n") | ||
| 282 | except FileNotFoundError: | 286 | except FileNotFoundError: |
| 283 | print("No debug log found.") | 287 | with open(filename, "w") as f: |
| 288 | f.write(f"{'='*60} no debug log {'='*60}\n") | ||
| 289 | |||
| 290 | def concatenateLogs(logPattern): | ||
| 291 | nonlocal filename | ||
| 292 | renderLogs = glob.glob(os.path.join(core.Core.logDir, logPattern)) | ||
| 293 | with open(filename, "a") as fw: | ||
| 294 | for renderLog in renderLogs: | ||
| 295 | with open(renderLog, "r") as fr: | ||
| 296 | fw.write(f"{'='*60} {os.path.basename(renderLog)} {'='*60}\n") | ||
| 297 | logContents = fr.readlines() | ||
| 298 | fw.write("".join(logContents[:5])) | ||
| 299 | fw.write("...trimmed...\n") | ||
| 300 | fw.write("".join(logContents[-10:])) | ||
| 301 | fw.write(f"{'='*60} {os.path.basename(renderLog)} {'='*60}\n") | ||
| 302 | |||
| 303 | concatenateLogs("render_*.log") | ||
| 304 | concatenateLogs("preview_*.log") | ||
| 305 | |||
| 284 | # Append actual test report to debug log | 306 | # Append actual test report to debug log |
| 285 | with open(filename, "a") as f: | 307 | with open(filename, "a") as f: |
| 286 | f.write(f"{'='*59} debug log ends {'='*59}\n") | ||
| 287 | f.write(test_output) | 308 | f.write(test_output) |
| 288 | print(f"Test Report created at {filename}") | 309 | print(f"Test Report created at {filename}") |
