mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-10 19:07:17 +01:00
Some checks failed
dependency freshness / dependencies on newest stable (push) Waiting to run
file length / file-length (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
palette drift / palette (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run
crdt-sync pre-commit / pre-commit (push) Has been cancelled
crdt-sync tests / test (push) Has been cancelled
music_theory tests / test (push) Has been cancelled
settings.gradle.kts can declare any number of catalogs via from(files()); TachiyomiSY has mihon.versions.toml and sy.versions.toml beside libs. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Yc4TiPjhbQLfH35QBPfrbP
87 lines
3.1 KiB
Python
87 lines
3.1 KiB
Python
"""Which files the gate picks up, and which it deliberately does not."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from dep_freshness.discover import find_manifests, is_manifest, parse_manifest
|
|
from dep_freshness.tests.conftest import write
|
|
|
|
PUBSPEC = "name: demo\ndependencies:\n http: 1.6.0\n"
|
|
|
|
|
|
@pytest.mark.parametrize("name", [
|
|
"pubspec.yaml", "pyproject.toml", "package.json", "Cargo.toml", "go.mod",
|
|
".fvmrc", ".nvmrc", ".python-version", "requirements.txt",
|
|
"requirements-dev.txt", "libs.versions.toml", "sy.versions.toml",
|
|
"gradle-wrapper.properties",
|
|
])
|
|
def test_manifest_names_are_recognised(name):
|
|
assert is_manifest(Path(name))
|
|
|
|
|
|
@pytest.mark.parametrize("name", ["main.dart", "README.md", "pubspec.lock",
|
|
"my-requirements.md"])
|
|
def test_other_files_are_not_manifests(name):
|
|
assert not is_manifest(Path(name))
|
|
|
|
|
|
def test_find_manifests_walks_the_tree(repo):
|
|
write(repo, "pubspec.yaml", PUBSPEC)
|
|
write(repo, "packages/core/pubspec.yaml", PUBSPEC)
|
|
write(repo, "lib/main.dart", "void main() {}\n")
|
|
found = {p.name for p in find_manifests(repo)}
|
|
assert found == {"pubspec.yaml"}
|
|
assert len(find_manifests(repo)) == 2
|
|
|
|
|
|
def test_excluded_directories_are_skipped(repo):
|
|
write(repo, "build/pubspec.yaml", PUBSPEC)
|
|
write(repo, "node_modules/x/package.json", "{}")
|
|
write(repo, ".dart_tool/pubspec.yaml", PUBSPEC)
|
|
assert find_manifests(repo) == []
|
|
|
|
|
|
def test_the_shared_gate_checkout_is_not_part_of_the_repo(repo):
|
|
"""CI clones kuhyx/utils into `.utils/` inside the repo being checked.
|
|
|
|
Without this exclusion `--all` walks utils' own manifests and fails the
|
|
consuming repo for staleness in a directory it does not own -- which is
|
|
how punchme's first green local run turned red in CI.
|
|
"""
|
|
write(repo, ".utils/design_system/pubspec.yaml", PUBSPEC)
|
|
write(repo, "pubspec.yaml", PUBSPEC)
|
|
assert [str(p) for p in find_manifests(repo)] == [str(repo / "pubspec.yaml")]
|
|
|
|
|
|
def test_git_ignored_manifests_are_skipped(repo):
|
|
write(repo, ".gitignore", "generated/\n")
|
|
write(repo, "generated/pubspec.yaml", PUBSPEC)
|
|
write(repo, "pubspec.yaml", PUBSPEC)
|
|
assert [p.name for p in find_manifests(repo)] == ["pubspec.yaml"]
|
|
assert all("generated" not in str(p) for p in find_manifests(repo))
|
|
|
|
|
|
def test_outside_a_git_repo_nothing_is_treated_as_ignored(tmp_path):
|
|
write(tmp_path, "pubspec.yaml", PUBSPEC)
|
|
assert len(find_manifests(tmp_path)) == 1
|
|
|
|
|
|
def test_symlinked_manifests_are_skipped(repo):
|
|
write(repo, "real/pubspec.yaml", PUBSPEC)
|
|
(repo / "pubspec.yaml").symlink_to(repo / "real" / "pubspec.yaml")
|
|
assert [str(p) for p in find_manifests(repo)] == [
|
|
str(repo / "real" / "pubspec.yaml")
|
|
]
|
|
|
|
|
|
def test_parse_manifest_routes_by_filename(tmp_path):
|
|
path = write(tmp_path, "requirements-dev.txt", "ruff==0.16.5\n")
|
|
assert [d.name for d in parse_manifest(path)] == ["ruff"]
|
|
|
|
|
|
def test_parse_manifest_ignores_anything_else(tmp_path):
|
|
assert parse_manifest(write(tmp_path, "main.dart", "void main() {}")) == []
|