From 40aefa1ba4d0e4e1ae420804cbf20a51a91386ab Mon Sep 17 00:00:00 2001 From: Francesc Elies Date: Tue, 10 Dec 2019 18:32:41 +0100 Subject: [PATCH] [windows] cannot run test-misra (binary not found) (#2441) set PYTHONPATH=addons python -m pytest addons/test/test-misra.py --- addons/test/util.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/addons/test/util.py b/addons/test/util.py index c027d74b3..fc4c528f9 100644 --- a/addons/test/util.py +++ b/addons/test/util.py @@ -1,9 +1,25 @@ # Helpers for pytest tests import subprocess import json +import os + + +def find_cppcheck_binary(): + possible_locations = [ + "./cppcheck", + r".\bin\cppcheck.exe", + ] + for location in possible_locations: + if os.path.exists(location): + break + else: + raise RuntimeError("Could not fine cppcheck binary") + + return location def dump_create(fpath, *argv): - cmd = ["./cppcheck", "--dump", "--quiet", fpath] + list(argv) + cppcheck_binary = find_cppcheck_binary() + cmd = [cppcheck_binary, "--dump", "--quiet", fpath] + list(argv) p = subprocess.Popen(cmd) p.communicate() if p.returncode != 0: