Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/bbannier/upgrade-string-fo…
Browse files Browse the repository at this point in the history
…rmatting'

* origin/topic/bbannier/upgrade-string-formatting:
  Bump used GH actions
  Add python-3.13 to CI
  Bump pre-commit hooks
  Prefer format or f-strings over percent formatting
  • Loading branch information
timwoj committed Dec 5, 2024
2 parents 11ed25a + 51d5cd8 commit a939b12
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 29 deletions.
24 changes: 17 additions & 7 deletions .github/workflows/btest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ jobs:
Run-BTest:
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
os: [macos-latest, ubuntu-latest, windows-latest]

runs-on: ${{ matrix.os }}
Expand All @@ -24,9 +29,9 @@ jobs:
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies (Windows)
Expand All @@ -53,16 +58,21 @@ jobs:
Test-SetupPY:
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: "Install pip and the btest package"
run: |
python3 -m pip install --upgrade pip
Expand All @@ -82,7 +92,7 @@ jobs:
needs: [Run-BTest, Test-SetupPY]
if: github.repository == 'zeek/btest' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Check release version
# This fails e.g. if VERSION contains a dev commits suffix,
# since we don't want to push these to PyPI. Accepts two-
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ repos:
args: ["-w", "-i", "4", "-ci"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude: ^testing/Baseline
- id: end-of-file-fixer
exclude: ^testing/Baseline|examples/.*Baseline.*

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.5
rev: v0.8.1
hooks:
- id: ruff
args: [--fix]
Expand Down
10 changes: 10 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
1.1-28 | 2024-12-05 12:37:47 -0700

* Bump used GH actions (Benjamin Bannier, Corelight)

* Add python-3.13 to CI (Benjamin Bannier, Corelight)

* Bump pre-commit hooks (Benjamin Bannier, Corelight)

* Prefer format or f-strings over percent formatting (Benjamin Bannier, Corelight)

1.1-23 | 2024-12-04 19:18:04 +0100

* btest-setsid: Fail on setsid() error (Arne Welzel, Corelight)
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
..
.. Version number is filled in automatically.

.. |version| replace:: 1.1-23
.. |version| replace:: 1.1-28

==================================================
BTest - A Generic Driver for Powerful System Tests
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1-23
1.1-28
34 changes: 17 additions & 17 deletions btest
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ else:
import multiprocessing.managers as mp_managers
import multiprocessing.sharedctypes as mp_sharedctypes

VERSION = "1.1-23" # Automatically filled in.
VERSION = "1.1-28" # Automatically filled in.

Name = "btest"
Config = None
Expand Down Expand Up @@ -493,7 +493,7 @@ class TestManager(mp_managers.SyncManager):
# zeek processes, but runner processes executing individual test commands.
for i in range(Options.threads):
t = mp.Process(
name="#%d" % (i + 1), target=lambda: self.threadRun(i, mgr_data)
name=f"#{i+1}", target=lambda: self.threadRun(i, mgr_data)
)
t.start()
threads += [t]
Expand Down Expand Up @@ -829,7 +829,7 @@ class TestManager(mp_managers.SyncManager):
out = open(path, "w")

for k, v in timing.items():
print("%s %u" % (k, v), file=out)
print(f"{k} {v}", file=out)

out.close()

Expand Down Expand Up @@ -1068,7 +1068,7 @@ class Test:

if increment:
clone.number = self.number + 1
clone.name = "%s-%d" % (self.basename, clone.number)
clone.name = f"{self.basename}-{clone.number}"
elif self.name:
clone.name = self.name

Expand Down Expand Up @@ -1607,8 +1607,8 @@ class OutputHandler:
# TestManager.run() defines the process names to "#<n>". Align the
# prefixes by using enough space for the number of threads
# requested, plus 1 for "#".
pat = "[%%+%ds]" % (len(str(self.options().threads)) + 1)
return pat % mp.current_process().name
width = len(str(self.options().threads)) + 1
return f"[%+{mp.current_process().name:>{width}}]"
else:
return ""

Expand Down Expand Up @@ -1813,7 +1813,7 @@ class Console(OutputHandler):
OutputHandler.__init__(self, options, reopen_std_file(sys.__stdout__))

def testStart(self, test):
msg = "[%3d%%] %s ..." % (test.mgr.percentage(), test.displayName())
msg = f"[{test.mgr.percentage():>3}%] {test.displayName()} ..."
self.output(test, msg, nl=False)

def testProgress(self, test, msg):
Expand Down Expand Up @@ -1912,7 +1912,7 @@ class CompactConsole(Console):
self._outfile.flush()

def _consoleOutput(self, test, msg, sticky):
line = "[%3d%%] %s ..." % (test.mgr.percentage(), test.displayName())
line = f"[{test.mgr.percentage():>3.0f}%] {test.displayName()} ..."

if msg:
line += " " + msg
Expand Down Expand Up @@ -1976,7 +1976,7 @@ class Verbose(OutputHandler):
part = ""

if cmdline.part > 1:
part = " [part #%d]" % cmdline.part
part = f" [part #{cmdline.part}]"

self.output(test, self.threadPrefix(), nl=False)
self.output(test, f" > {cmdline.cmdline}{part}")
Expand Down Expand Up @@ -3319,17 +3319,16 @@ if __name__ == "__main__":
mgr.shutdown()
sys.exit(1)

skip = (", %d skipped" % skipped) if skipped > 0 else ""
unstablestr = (", %d unstable" % unstable) if unstable > 0 else ""
skip = f", {skipped} skipped" if skipped > 0 else ""
unstablestr = f", {unstable} unstable" if unstable > 0 else ""
failed_expectedstr = (
(" (with %d expected to fail)" % failed_expected) if failed_expected > 0 else ""
f" (with {failed_expected} expected to fail)" if failed_expected > 0 else ""
)

if failed > 0:
if not Options.quiet:
output(
"%d of %d test%s failed%s%s%s"
% (
"{} of {} test{} failed{}{}{}".format(
failed,
total,
"s" if total > 1 else "",
Expand All @@ -3347,14 +3346,15 @@ if __name__ == "__main__":
elif skipped > 0 or unstable > 0:
if not Options.quiet:
output(
"%d test%s successful%s%s"
% (succeeded, "s" if succeeded != 1 else "", skip, unstablestr)
"{} test{} successful{}{}".format(
succeeded, "s" if succeeded != 1 else "", skip, unstablestr
)
)

sys.exit(0)

else:
if not Options.quiet:
output("all %d tests successful" % total)
output(f"all {total} tests successful")

sys.exit(0)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
py_modules = ["btest-sphinx"]

setup(
version="1.1.dev23", # Filled in automatically.
version="1.1.dev28", # Filled in automatically.
py_modules=py_modules,
)

0 comments on commit a939b12

Please sign in to comment.