Skip to main content

SKY-A113 · AI-code defects

Tests fail when Skylos runs them

High

Skylos runs the project's tests itself and reports each test that fails. What a coding agent says about its own test run is ignored: only the results Skylos reads from its own run count.

Languages
Python (pytest, found automatically), any test command that writes JUnit XML (set test_command and junit_xml)
Turned on by
skylos done (compares uncommitted changes with HEAD) or skylos done --base origin/main for a pull request; agent hooks run it when the agent stops
Quality gate
not checked (full and diff scans). Only skylos done reports it, in its tests_pass check, which blocks by default: one failing test fails the verdict, and a run that cannot finish leaves it unfinished. A flaky test (failed once, passed on a rerun) is advice. Failures that also fail on the base commit still block unless the base sets allow_preexisting_failures = true.
Finding type
defect
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Agents often report "all tests pass" after running only some tests, an old command, or nothing at all. A change that breaks a test should not be called finished, and a reviewer should not have to rerun the suite to find out.

What Skylos flags

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

blog/slug.py · Python · changed
import re  def slugify(title):Removed:     slug = re.sub(r"[^a-z0-9]+", "-", title.lower())Added:     slug = re.sub(r"\s+", "-", title.lower())    return slug.strip("-")
2 committed files the change leaves alone
pyproject.toml · TOML
[project]name = "blog"version = "1.2.0" [tool.pytest.ini_options]testpaths = ["tests"]
tests/test_slug.py · Python
import pytest from blog.slug import slugify  def test_spaces_become_dashes():    assert slugify("Hello World") == "hello-world"  def test_punctuation_is_dropped():    assert slugify("Rock & Roll!") == "rock-roll"  @pytest.mark.xfail(reason="accents are dropped, issue 212")def test_accents_are_kept():    assert slugify("Café Crème") == "cafe-creme"

What Skylos leaves alone

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

blog/slug.py · Python · changed
import re  Removed: def slugify(title):Added: def slugify(title, max_length=80):    slug = re.sub(r"[^a-z0-9]+", "-", title.lower())Removed:     return slug.strip("-")Added:     return slug.strip("-")[:max_length].rstrip("-")
2 committed files the change leaves alone

pyproject.toml: same as in the flagged example.

tests/test_slug.py: same as in the flagged example.

Why Skylos leaves it alone

test_accents_are_kept still fails, but it is marked xfail: an expected failure that pytest reports as such, not as a failed test. The other two tests pass, so the run passes.

How Skylos decides

  1. Runs in skylos done, last among its checks, and only when no earlier blocking check failed. With --no-tests it does not run, and a blocking check that did not run leaves the verdict unfinished.
  2. Chooses the command: test_command from [tool.skylos.done] at the base, else python -m pytest when the project looks like a pytest project, using the active virtualenv, the repository's .venv or venv, or a python3 on PATH that has pytest.
  3. For pytest, adds its own --junitxml and drops PYTEST_ADDOPTS and PYTEST_PLUGINS from the environment, so neither the change nor the caller can narrow the run. Another command must write JUnit XML to the junit_xml path; an exit code alone is not accepted.
  4. Reads the JUnit results. A failing test is rerun once: failing twice is a blocking finding, passing on the rerun is flaky advice. Failing tests are also rerun on the base commit to label each failure as introduced or already there.
  5. Also reports a test in a changed test file that did not report a result although its file ran, a test file with no results, and parametrized tests that reported fewer cases than they have. A run past test_budget_seconds (300 by default) or with no results is unfinished, never passing.

How to fix it

Fix the code until the failing test passes; here, keep dropping punctuation. Run skylos done again to get a passing receipt. If the test is wrong, change the test in the same change and say why.

Fix · Python
def slugify(title):    slug = re.sub(r"[^a-z0-9]+", "-", title.lower())    return slug.strip("-")

When it can be wrong

  • A test that fails only on this machine (a missing service, a missing dependency in the chosen interpreter) is reported like any failure. Set test_command to the command your project really uses.
  • A test that already failed before the change still blocks by default; the finding says it also fails on the base.
  • JavaScript and other tests run only through test_command with junit_xml; without them, a JavaScript-only project's tests are not run.

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • skylos done findings ignore # skylos: ignore[...] comments and the [tool.skylos] ignore list. To accept failures that also fail on the base, commit this to the base branch first (the change under review cannot change its own check):

    TOML
    [tool.skylos.done]allow_preexisting_failures = true

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.