aboutsummaryrefslogtreecommitdiff
path: root/utils/getdeveloperlib.py
diff options
context:
space:
mode:
authorGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2020-11-19 15:53:54 +0100
committerGravatar Peter Korsgaard <peter@korsgaard.com>2021-01-19 15:23:01 +0100
commit8e5eebd53042cfa4ca4769c1b396c13ae9779028 (patch)
treef34035c4fcc54ae5de7c43c18155b9abb90931eb /utils/getdeveloperlib.py
parent3bdae5980c9841ff2b3976fa379aa76921daacb1 (diff)
downloadbuildroot-8e5eebd53042cfa4ca4769c1b396c13ae9779028.tar.gz
buildroot-8e5eebd53042cfa4ca4769c1b396c13ae9779028.tar.bz2
utils/getdeveloperlib.py: use relative paths for files
Using absolute paths within getdeveloperlib isn't very sensible, it makes a lot more sense to handle everything as relative paths from the top-level Buildroot source directory. parse_developers() is changed to no longer take the base path as argument: it is automatically calculated based on the location of utils/getdeveloperlib.py. Then, the rest of the logic is adjusted to use relative paths, and prepend them with the base "brpath" when needed. This commit allows pkg-stats to report correct developers information even when executed from an out of tree directory. Before this patch: $ ~/buildroot/support/scripts/pkg-stats -p ipmitool --json out.json $ cat out.json | jq '.packages.ipmitool.developers' [] $ cat out.json | jq '.defconfigs.stm32f469_disco' { "name": "stm32f469_disco", "path": "configs/stm32f469_disco_defconfig", "developers": [] } After this patch: $ ~/buildroot/support/scripts/pkg-stats -p ipmitool --json out.json $ cat out.json | jq '.packages.ipmitool.developers' [ "Floris Bos <bos@je-eigen-domein.nl>", "Heiko Thiery <heiko.thiery@gmail.com>" ] $ cat out.json | jq '.defconfigs.stm32f469_disco' { "name": "stm32f469_disco", "path": "configs/stm32f469_disco_defconfig", "developers": [ "Christophe Priouzeau <christophe.priouzeau@st.com>" ] } Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Tested-by: Heiko Thiery <heiko.thiery@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> (cherry picked from commit 40bb37bd70d46822e803aaa5169dee8ff8b51093) Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Diffstat (limited to 'utils/getdeveloperlib.py')
-rw-r--r--utils/getdeveloperlib.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/utils/getdeveloperlib.py b/utils/getdeveloperlib.py
index dc0cc07cc7..d7a90457ed 100644
--- a/utils/getdeveloperlib.py
+++ b/utils/getdeveloperlib.py
@@ -6,6 +6,8 @@ import subprocess
import sys
import unittest
+brpath = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))
+
#
# Patch parsing functions
#
@@ -94,14 +96,14 @@ def get_all_test_cases(suite):
yield (suite.__module__, suite.__class__.__name__)
-def list_unittests(path):
+def list_unittests():
"""Use the unittest module to retreive all test cases from a given
directory"""
loader = unittest.TestLoader()
- suite = loader.discover(path)
+ suite = loader.discover(os.path.join(brpath, "support", "testing"))
tests = {}
for module, test in get_all_test_cases(suite):
- module_path = os.path.join(path, *module.split('.'))
+ module_path = os.path.join("support", "testing", *module.split('.'))
tests.setdefault(module_path, []).append('%s.%s' % (module, test))
return tests
@@ -124,7 +126,6 @@ class Developer:
self.defconfigs = parse_developer_defconfigs(files)
def hasfile(self, f):
- f = os.path.abspath(f)
for fs in self.files:
if f.startswith(fs):
return True
@@ -157,7 +158,7 @@ def parse_developer_packages(fnames):
patterns, and return a list of those packages."""
packages = set()
for fname in fnames:
- for root, dirs, files in os.walk(fname):
+ for root, dirs, files in os.walk(os.path.join(brpath, fname)):
for f in files:
path = os.path.join(root, f)
if fname_get_package_infra(path):
@@ -222,7 +223,7 @@ def parse_developer_runtime_tests(fnames):
# List all files recursively
for fname in fnames:
if os.path.isdir(fname):
- for root, _dirs, files in os.walk(fname):
+ for root, _dirs, files in os.walk(os.path.join(brpath, fname)):
all_files += [os.path.join(root, f) for f in files]
else:
all_files.append(fname)
@@ -236,15 +237,13 @@ def parse_developer_runtime_tests(fnames):
return runtimes
-def parse_developers(basepath=None):
+def parse_developers():
"""Parse the DEVELOPERS file and return a list of Developer objects."""
developers = []
linen = 0
- if basepath is None:
- basepath = os.getcwd()
global unittests
- unittests = list_unittests(os.path.join(basepath, 'support/testing'))
- with open(os.path.join(basepath, "DEVELOPERS"), "r") as f:
+ unittests = list_unittests()
+ with open(os.path.join(brpath, "DEVELOPERS"), "r") as f:
files = []
name = None
for line in f:
@@ -258,11 +257,11 @@ def parse_developers(basepath=None):
name = line[2:].strip()
elif line.startswith("F:"):
fname = line[2:].strip()
- dev_files = glob.glob(os.path.join(basepath, fname))
+ dev_files = glob.glob(os.path.join(brpath, fname))
if len(dev_files) == 0:
print("WARNING: '%s' doesn't match any file" % fname,
file=sys.stderr)
- files += dev_files
+ files += [os.path.relpath(f, brpath) for f in dev_files]
elif line == "":
if not name:
continue