aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/testing/kunit/kunit_json.py
diff options
context:
space:
mode:
authorDaniel Latypov <dlatypov@google.com>2022-01-18 11:09:22 -0800
committerShuah Khan <skhan@linuxfoundation.org>2022-04-04 14:25:58 -0600
commitaa1c05558e71422564a664fc4cafbf5999f1de0f (patch)
tree33ce19c2e0a6ef281b58259a18dcf7714a6ef9f8 /tools/testing/kunit/kunit_json.py
parentkunit: tool: drop last uses of collections.namedtuple (diff)
downloadwireguard-linux-aa1c05558e71422564a664fc4cafbf5999f1de0f.tar.xz
wireguard-linux-aa1c05558e71422564a664fc4cafbf5999f1de0f.zip
kunit: tool: simplify code since build_dir can't be None
--build_dir is set to a default of '.kunit' since commit ddbd60c779b4 ("kunit: use --build_dir=.kunit as default"), but even before then it was explicitly set to ''. So outside of one unit test, there was no way for the build_dir to be ever be None, and we can simplify code by fixing the unit test and enforcing that via updated type annotations. E.g. this lets us drop `get_file_path()` since it's now exactly equivalent to os.path.join(). Note: there's some `if build_dir` checks that also fail if build_dir is explicitly set to '' that just guard against passing "O=" to make. But running `make O=` works just fine, so drop these checks. Signed-off-by: Daniel Latypov <dlatypov@google.com> Reviewed-by: David Gow <davidgow@google.com> Reviewed-by: Brendan Higgins <brendanhiggins@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/testing/kunit/kunit_json.py')
-rw-r--r--tools/testing/kunit/kunit_json.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/tools/testing/kunit/kunit_json.py b/tools/testing/kunit/kunit_json.py
index 61091878f51e..24d103049bca 100644
--- a/tools/testing/kunit/kunit_json.py
+++ b/tools/testing/kunit/kunit_json.py
@@ -12,12 +12,11 @@ import os
import kunit_parser
from kunit_parser import Test, TestStatus
-from typing import Any, Dict, Optional
+from typing import Any, Dict
JsonObj = Dict[str, Any]
-def _get_group_json(test: Test, def_config: str,
- build_dir: Optional[str]) -> JsonObj:
+def _get_group_json(test: Test, def_config: str, build_dir: str) -> JsonObj:
sub_groups = [] # List[JsonObj]
test_cases = [] # List[JsonObj]
@@ -50,8 +49,7 @@ def _get_group_json(test: Test, def_config: str,
}
return test_group
-def get_json_result(test: Test, def_config: str,
- build_dir: Optional[str]) -> str:
+def get_json_result(test: Test, def_config: str, build_dir: str) -> str:
test_group = _get_group_json(test, def_config, build_dir)
test_group["name"] = "KUnit Test Group"
return json.dumps(test_group, indent=4)