GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #21 from CortexLM/ci/shard-top-level-tests · CortexLM/hypertrain@2708b7d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • ci.yml
  • tests
    • conftest.py
    • systemd_probe.py
    • test_systemd_probe_classify.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/ci.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/ci.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
shell: bash
8888
run: |
8989
set -euo pipefail
90-
mapfile -t ALL < <(git ls-files 'tests/**/test_*.py' \
90+
mapfile -t ALL < <(git ls-files ':(glob)tests/**/test_*.py' \
9191
| grep -v '^tests/sim/' | grep -v '^tests/e2e/' | sort)
9292
SEL=()
9393
for i in "${!ALL[@]}"; do
Collapse file

‎tests/conftest.py‎

Copy file name to clipboardExpand all lines: tests/conftest.py
+3-18Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
import subprocess
66
import uuid
77
from pathlib import Path
8-
from typing import Literal
98

109
import numpy as np
1110
import pytest
1211

12+
from systemd_probe import classify_systemd_probe
13+
1314
SEQ_LEN = 1024
1415
SAMPLES_PER_SHARD = 128
1516

@@ -115,22 +116,6 @@ def corpus_dir(tmp_path_factory: pytest.TempPathFactory) -> Path:
115116
return d
116117

117118

118-
# Messages meaning "this user/host has no usable system manager", not "the probe broke".
119-
_SYSTEMD_UNAVAILABLE = (
120-
"Interactive authentication required",
121-
"Access denied",
122-
"Failed to connect to bus",
123-
"System has not been booted with systemd",
124-
"Permission denied",
125-
)
126-
127-
128-
def _classify_systemd_probe(returncode: int, stderr: str) -> Literal["ok", "unavailable", "error"]:
129-
if returncode == 0:
130-
return "ok"
131-
return "unavailable" if any(m in stderr for m in _SYSTEMD_UNAVAILABLE) else "error"
132-
133-
134119
@pytest.fixture(scope="session")
135120
def systemd_manager() -> None:
136121
"""Skip unless this user may start transient units on the system manager, as the product does.
@@ -158,7 +143,7 @@ def systemd_manager() -> None:
158143
timeout=30,
159144
check=False,
160145
)
161-
verdict = _classify_systemd_probe(probe.returncode, probe.stderr)
146+
verdict = classify_systemd_probe(probe.returncode, probe.stderr)
162147
reason = f"rc={probe.returncode} {probe.stderr.strip()[-500:]}"
163148
except FileNotFoundError as exc:
164149
verdict, reason = "unavailable", repr(exc)
Collapse file

‎tests/systemd_probe.py‎

Copy file name to clipboard
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Classification of the `systemd-run` probe result (imported by conftest and its unit test)."""
2+
3+
from __future__ import annotations
4+
5+
from typing import Literal
6+
7+
# Messages meaning "this user/host has no usable system manager", not "the probe broke".
8+
_SYSTEMD_UNAVAILABLE = (
9+
"Interactive authentication required",
10+
"Access denied",
11+
"Failed to connect to bus",
12+
"System has not been booted with systemd",
13+
"Permission denied",
14+
)
15+
16+
17+
def classify_systemd_probe(returncode: int, stderr: str) -> Literal["ok", "unavailable", "error"]:
18+
if returncode == 0:
19+
return "ok"
20+
return "unavailable" if any(m in stderr for m in _SYSTEMD_UNAVAILABLE) else "error"
Collapse file

‎tests/test_systemd_probe_classify.py‎

Copy file name to clipboardExpand all lines: tests/test_systemd_probe_classify.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44

5-
from conftest import _classify_systemd_probe
5+
from systemd_probe import classify_systemd_probe
66

77
DENIED = [
88
"Failed to start transient service unit: Interactive authentication required.",
@@ -14,17 +14,17 @@
1414

1515

1616
def test_ok() -> None:
17-
assert _classify_systemd_probe(0, "") == "ok"
17+
assert classify_systemd_probe(0, "") == "ok"
1818

1919

2020
@pytest.mark.parametrize("stderr", DENIED)
2121
def test_unavailable(stderr: str) -> None:
22-
assert _classify_systemd_probe(1, stderr) == "unavailable"
22+
assert classify_systemd_probe(1, stderr) == "unavailable"
2323

2424

2525
@pytest.mark.parametrize(
2626
"stderr",
2727
["Failed to start transient service unit: Resource temporarily unavailable (EAGAIN)", ""],
2828
)
2929
def test_error(stderr: str) -> None:
30-
assert _classify_systemd_probe(1, stderr) == "error"
30+
assert classify_systemd_probe(1, stderr) == "error"

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.