Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions .ci/check-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,26 @@ set -u -o pipefail
set -x

REPO_ROOT="$(git rev-parse --show-toplevel)"
# Without 'set -e', an unchecked cd would leave the file lists below being
# gathered from wherever the script happened to be invoked, and the script
# would still exit 0.
cd "${REPO_ROOT}" || exit 1

SH_SOURCES=$(find "${REPO_ROOT}" | egrep "\.sh$")
# Ask git for the file list rather than walking the tree. 'find' also picked up
# vendored checkouts, build directories and __pycache__, which are not ours to
# format -- a local run against a working tree with any of those in it failed on
# files the project does not own. --others includes new files that are not yet
# committed, and --exclude-standard honours .gitignore and .git/info/exclude, so
# anything deliberately kept out of the repo stays out.
git_sources() {
# Filtered to what is on disk: --cached still lists a tracked file that
# has been deleted in the working tree, and shfmt and black both error
# out on a path that is not there.
git ls-files --cached --others --exclude-standard -- "$1" | sort -u |
while IFS= read -r f; do [ -f "$f" ] && printf '%s\n' "$f"; done
}

SH_SOURCES=$(git_sources '*.sh')
for file in ${SH_SOURCES}; do
shfmt -d "${file}"
done
Expand All @@ -17,7 +35,7 @@ if [ -n "${SH_SOURCES}" ]; then
SH_MISMATCH_FILE_CNT=$(shfmt -l ${SH_SOURCES} | wc -l)
fi

PY_SOURCES=$(find "${REPO_ROOT}" | egrep "\.py$")
PY_SOURCES=$(git_sources '*.py')
for file in ${PY_SOURCES}; do
echo "Checking Python file: ${file}"
black --diff "${file}"
Expand Down
27 changes: 25 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
run: |
set -euo pipefail
python -m pip install --user --upgrade pip
python -m pip install --user setuptools wheel pytest
python -m pip install --user setuptools wheel pytest pytest-cov

- name: Check out Kconfiglib source code
uses: actions/checkout@v6
Expand All @@ -83,9 +83,32 @@ jobs:
python -m pytest tests/test_preprocess.py \
-k "test_user_defined or test_success_failure or test_python_fn or test_kconfig_warn"
else
python -m pytest tests/ --ignore=tests/test_conformance.py
# Coverage on the jobs that run the whole suite. The floor is a
# backstop against a large drop, not a ratchet; raise it as
# coverage improves.
#
# 35 is set against what these runners report, which is 40. Do not
# calibrate it from a local run on Python 3.14 or newer: coverage
# switches to the sys.monitoring backend there and scores the same
# suite at 51, and a floor taken from that number fails every job
# here. COVERAGE_CORE=ctrace reproduces the runner figure locally.
python -m pytest tests/ --ignore=tests/test_conformance.py \
--cov=kconfiglib --cov=menuconfig --cov=guiconfig --cov=rawterm \
--cov-report=term --cov-report=xml:coverage.xml \
--cov-fail-under=35
fi

- name: Store coverage report
# Only the jobs that ran the full suite produce one. !cancelled() rather
# than always(), so that a coverage failure still uploads the report
# explaining it but a cancelled run doesn't stop to upload anything.
if: ${{ !cancelled() && matrix.target.headless-only != true }}
uses: actions/upload-artifact@v6
with:
name: coverage-${{ matrix.target.os }}-py${{ matrix.target.python }}
path: coverage.xml
if-no-files-found: ignore

- name: Validate rawterm and menuconfig (Unix)
# Exercises rawterm Color/Style/Region compositing, terminal init/close
# (termios on Unix), and menuconfig headless mode with style parsing.
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ build/
dist/
mconf/.git/
mconf/build/

# Coverage reports (see the selftest CI job)
coverage.xml
.coverage

# Output of running the tools on this repository's own Kconfig
/.config
/.config.old
9 changes: 6 additions & 3 deletions guiconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -1369,8 +1369,10 @@ def _img_tag(node):
def _is_y_mode_choice_sym(item):
# The choice mode is an upper bound on the visibility of choice symbols, so
# we can check the choice symbols' own visibility to see if the choice is
# in y mode
return isinstance(item, Symbol) and item.choice and item.visibility == 2
# in y mode.
#
# 'is not None' so that a non-choice symbol yields False rather than None
return isinstance(item, Symbol) and item.choice is not None and item.visibility == 2


def _tree_click(event):
Expand Down Expand Up @@ -2420,7 +2422,8 @@ def _update_jump_to_matches(msglabel, search_string):
]
except re.error as e:
msglabel["text"] = "Bad regular expression: " + e.msg
# Clear tree
# Clear the match list too, so it keeps agreeing with the tree
_jump_to_matches = []
_jump_to_tree.set_children("")
return

Expand Down
Loading