From 09ee123430d6ed8dcc9bfe81e1f632f33f1059bb Mon Sep 17 00:00:00 2001 From: leftibot Date: Mon, 23 Nov 2026 20:59:23 -0700 Subject: [PATCH 1/8] Tell roles by more directory names: hack/, tool/, listings/, blueprints/, *_bench, *_example Part of #182 and #188. Names the corpus uses for auxiliary code besides the plain ones: Kubernetes' `hack/` and Dart's `tool/` maintainer scripts (tooling), rust-lang/book's `listings/` (example), koyo's `blueprints/` (template), Flutter's and phoenix's `integration_test/` (test), and a directory whose first or last word tells its role: dart-lang/http's `flutter_http_example`, fpm's `example_packages`, ruff's `ruff_benchmark`, `tests-build`. A last word `test` does not tell: a library for testing is a product (bloc's `bloc_test`), and Racket's `foo-test` packages are told by what their info.rkt says. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt --- project_validator/facts/roles.py | 33 ++++++++++++++++++++++++-------- tests/test_settings.py | 21 ++++++++++++++++++++ 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/project_validator/facts/roles.py b/project_validator/facts/roles.py index 11d295b7..413709ad 100644 --- a/project_validator/facts/roles.py +++ b/project_validator/facts/roles.py @@ -29,17 +29,30 @@ **dict.fromkeys( ("test", "tests", "testing", "testdata", "spec", "specs", "__tests__", "fixtures", "t", "xt"), "test" ), - **dict.fromkeys(("playground", "playgrounds", "inputs"), "test"), + # Flutter's integration tests (phoenix's too). + **dict.fromkeys(("playground", "playgrounds", "inputs", "integration_test"), "test"), **dict.fromkeys( ("fuzz", "fuzzing", "fuzz_test", "fuzz_tests", "fuzztest", "stress", "stress-test", "stress-tests"), "test" ), - **dict.fromkeys(("example", "examples", "sample", "samples", "demo", "demos"), "example"), + # rust-lang/book's `listings/` are the book's example programs. + **dict.fromkeys(("example", "examples", "sample", "samples", "demo", "demos", "listings"), "example"), **dict.fromkeys(("doc", "docs", "documentation", "website"), "docs"), - **dict.fromkeys(("tools", "tooling", "scripts"), "tooling"), + # `hack/` is the Kubernetes projects' name for maintainer scripts, `tool/` Dart's. + **dict.fromkeys(("tool", "tools", "tooling", "scripts", "hack"), "tooling"), **dict.fromkeys(("bench", "benches", "benchmark", "benchmarks"), "benchmark"), - # Files rendered before they are read (a Helm chart's manifests, Jinja pages): not well formed as they are. - **dict.fromkeys(("template", "templates"), "template"), + # Files rendered before they are read (a Helm chart's manifests, Jinja pages, the projects a blueprint + # generates): not well formed as they are. + **dict.fromkeys(("template", "templates", "blueprint", "blueprints"), "template"), } +# The roles a directory's name tells by its first or last word (`tests-build`, `integration_test`, `clap_bench`, +# `flutter_http_example`, `example_packages`). A last word `test` does not: a library for testing is a product +# (bloc's `bloc_test`), and Racket's `foo-test` packages are told by what they say. +_WORDS = { + "tests": "test", + **dict.fromkeys(("example", "examples"), "example"), + **dict.fromkeys(("bench", "benchmark", "benchmarks"), "benchmark"), +} +_WORD_BREAK = re.compile(r"[-_]") # The roles `--auxiliary` may name as not the product's (see `project_validator.facts.auxiliary`); vendored code is # never judged, named or not. AUXILIARY = frozenset({"test", "example", "docs", "tooling", "benchmark"}) @@ -52,11 +65,15 @@ def _named_role(part: str) -> str | None: - """The role a directory's name tells (`tests`, `integration-tests`, `tests-build`, `examples`), if any.""" + """The role a directory's name tells (`tests`, `integration-tests`, `tests-build`, `examples`, `foo_bench`), if + any.""" if part in _ROLES: return _ROLES[part] - test_named = part.endswith(("-tests", "_tests")) or part.startswith(("tests-", "tests_", "test-", "test_")) - return "test" if test_named else None + words = _WORD_BREAK.split(part) + if len(words) < 2: + return None + first = "test" if words[0] == "test" else _WORDS.get(words[0]) + return first or _WORDS.get(words[-1]) def _vendored(posix: PurePosixPath, parts: list[str], directory: bool) -> bool: diff --git a/tests/test_settings.py b/tests/test_settings.py index eaa74c01..5f6c8eab 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -236,6 +236,27 @@ def test_the_role_of_code_is_told_by_the_directories_it_is_in(self) -> None: self.assertEqual(role("internal/tools", directory=True), "tooling") self.assertEqual(role("internal/tools/gen.go"), "product") + def test_a_directory_named_for_what_it_holds_tells_its_role(self) -> None: + """Names the corpus uses besides the plain ones (upstream #182, #188): Kubernetes' `hack/` and Dart's `tool/` + maintainer scripts, phoenix's and Flutter's `integration_test/`, dart-lang/http's `flutter_http_example/`, + clap's `clap_bench/` and ruff's `ruff_benchmark/`, rust-lang/book's `listings/`, fpm's `example_packages/` + and koyo's `blueprints/` (project templates).""" + for path, expected in ( + ("charts/a/hack/sync.py", "tooling"), + ("tool/update_readme.dart", "tooling"), + ("integration_test/docker.sh", "test"), + ("pkgs/flutter_http_example/lib/main.dart", "example"), + ("example_packages/c_includes/fpm.toml", "example"), + ("listings/ch01/hello/src/main.rs", "example"), + ("clap_bench/benches/a.rs", "benchmark"), + ("crates/ruff_benchmark/src/lib.rs", "benchmark"), + ("koyo-lib/blueprints/standard/package.json", "template"), + ): + with self.subTest(path=path): + self.assertEqual(role(path), expected) + # A library for testing is the product (bloc's bloc_test package). + self.assertEqual(role("packages/bloc_test", directory=True), "product") + def test_vendored_code_is_recorded_but_adds_no_language(self) -> None: with temp_project({"main.c": "", "web/sw.min.js": ""}) as root: context = make_context(root) From 039f8f868e814642070d7ff9afd27db133c063ec Mon Sep 17 00:00:00 2001 From: leftibot Date: Mon, 23 Nov 2026 21:42:53 -0700 Subject: [PATCH 2/8] Judge a language written only in auxiliary code as auxiliary by default Part of #182. A language whose every source is test, example, docs, tooling or benchmark code (a test fixture in C, a docs theme's script, a maintainer's script under hack/), that no build file outside auxiliary code builds and whose ecosystem has no product language (a Java project's tests in Kotlin stay its own), is judged as if --auxiliary named its role: labelled "(auxiliary: only in test code)", failures are warnings, and it weighs half in the score. A project with no product language left is judged as it is. An auxiliary unit's result says it is auxiliary once. The expected-failure regression test for #182 now passes. Tests that pinned the old default (a C++ project's lone Python release script judged as the product) now pin the new one, and that a language with product code is still the product's in its helper scripts. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt --- project_validator/facts/auxiliary.py | 49 +++++++++++++------ project_validator/facts/structure.py | 37 ++++++++++++-- project_validator/judging.py | 5 +- tests/checks/test_code_formatting.py | 3 +- tests/regressions/test_cmake.py | 2 +- tests/regressions/test_detection.py | 1 - tests/snapshots/bare_ansible.facts.json | 11 +++-- tests/snapshots/bare_beam.facts.json | 11 +++-- tests/snapshots/bare_c.facts.json | 11 +++-- tests/snapshots/bare_clojure.facts.json | 11 +++-- tests/snapshots/bare_common_lisp.facts.json | 11 +++-- tests/snapshots/bare_cpp.facts.json | 11 +++-- tests/snapshots/bare_dart.facts.json | 11 +++-- tests/snapshots/bare_data.facts.json | 11 +++-- tests/snapshots/bare_docker.facts.json | 11 +++-- tests/snapshots/bare_documentation.facts.json | 11 +++-- tests/snapshots/bare_dotnet.facts.json | 11 +++-- tests/snapshots/bare_emacs_lisp.facts.json | 11 +++-- tests/snapshots/bare_fortran.facts.json | 11 +++-- tests/snapshots/bare_github_action.facts.json | 11 +++-- tests/snapshots/bare_go.facts.json | 11 +++-- tests/snapshots/bare_graphql.facts.json | 11 +++-- tests/snapshots/bare_haskell.facts.json | 11 +++-- tests/snapshots/bare_javascript.facts.json | 11 +++-- tests/snapshots/bare_json_schema.facts.json | 11 +++-- tests/snapshots/bare_julia.facts.json | 11 +++-- tests/snapshots/bare_jupyter.facts.json | 11 +++-- tests/snapshots/bare_jvm.facts.json | 11 +++-- tests/snapshots/bare_kubernetes.facts.json | 11 +++-- tests/snapshots/bare_latex.facts.json | 11 +++-- tests/snapshots/bare_lua.facts.json | 11 +++-- tests/snapshots/bare_nix.facts.json | 11 +++-- tests/snapshots/bare_ocaml.facts.json | 11 +++-- tests/snapshots/bare_openapi.facts.json | 11 +++-- tests/snapshots/bare_perl.facts.json | 11 +++-- tests/snapshots/bare_php.facts.json | 11 +++-- tests/snapshots/bare_protobuf.facts.json | 11 +++-- tests/snapshots/bare_python.facts.json | 11 +++-- tests/snapshots/bare_r.facts.json | 11 +++-- tests/snapshots/bare_racket.facts.json | 11 +++-- tests/snapshots/bare_ruby.facts.json | 11 +++-- tests/snapshots/bare_rust.facts.json | 11 +++-- tests/snapshots/bare_scala.facts.json | 11 +++-- tests/snapshots/bare_shell.facts.json | 11 +++-- tests/snapshots/bare_sql.facts.json | 11 +++-- tests/snapshots/bare_swift.facts.json | 11 +++-- tests/snapshots/bare_tabular_data.facts.json | 11 +++-- tests/snapshots/bare_terraform.facts.json | 11 +++-- tests/snapshots/bare_typescript.facts.json | 11 +++-- tests/snapshots/bare_typst.facts.json | 11 +++-- tests/snapshots/bare_xml_schemas.facts.json | 11 +++-- tests/snapshots/bare_zig.facts.json | 11 +++-- tests/snapshots/buildable.facts.json | 11 +++-- .../well_configured_ansible.facts.json | 11 +++-- .../snapshots/well_configured_beam.facts.json | 11 +++-- tests/snapshots/well_configured_c.facts.json | 11 +++-- .../well_configured_clojure.facts.json | 11 +++-- .../well_configured_common_lisp.facts.json | 11 +++-- .../snapshots/well_configured_cpp.facts.json | 11 +++-- .../snapshots/well_configured_dart.facts.json | 11 +++-- .../snapshots/well_configured_data.facts.json | 11 +++-- .../well_configured_docker.facts.json | 11 +++-- .../well_configured_documentation.facts.json | 11 +++-- .../well_configured_dotnet.facts.json | 11 +++-- .../well_configured_emacs_lisp.facts.json | 11 +++-- .../well_configured_fortran.facts.json | 11 +++-- .../well_configured_github_action.facts.json | 11 +++-- tests/snapshots/well_configured_go.facts.json | 11 +++-- .../well_configured_graphql.facts.json | 11 +++-- .../well_configured_haskell.facts.json | 11 +++-- .../well_configured_javascript.facts.json | 11 +++-- .../well_configured_json_schema.facts.json | 11 +++-- .../well_configured_julia.facts.json | 11 +++-- .../well_configured_jupyter.facts.json | 11 +++-- .../snapshots/well_configured_jvm.facts.json | 11 +++-- .../well_configured_kubernetes.facts.json | 11 +++-- .../well_configured_latex.facts.json | 11 +++-- .../snapshots/well_configured_lua.facts.json | 11 +++-- .../snapshots/well_configured_nix.facts.json | 11 +++-- .../well_configured_ocaml.facts.json | 11 +++-- .../well_configured_openapi.facts.json | 11 +++-- .../snapshots/well_configured_perl.facts.json | 11 +++-- .../snapshots/well_configured_php.facts.json | 11 +++-- .../well_configured_protobuf.facts.json | 11 +++-- .../well_configured_python.facts.json | 11 +++-- tests/snapshots/well_configured_r.facts.json | 11 +++-- .../well_configured_racket.facts.json | 11 +++-- .../snapshots/well_configured_ruby.facts.json | 11 +++-- .../snapshots/well_configured_rust.facts.json | 11 +++-- .../well_configured_scala.facts.json | 11 +++-- .../well_configured_shell.facts.json | 11 +++-- .../snapshots/well_configured_sql.facts.json | 11 +++-- .../well_configured_swift.facts.json | 11 +++-- .../well_configured_tabular_data.facts.json | 11 +++-- .../well_configured_terraform.facts.json | 11 +++-- .../well_configured_typescript.facts.json | 11 +++-- .../well_configured_typst.facts.json | 11 +++-- .../well_configured_xml_schemas.facts.json | 11 +++-- .../snapshots/well_configured_zig.facts.json | 11 +++-- tests/test_facts.py | 4 +- tests/test_judging.py | 7 +-- tests/test_units.py | 29 ++++++++--- tests/test_views.py | 3 +- 103 files changed, 663 insertions(+), 500 deletions(-) diff --git a/project_validator/facts/auxiliary.py b/project_validator/facts/auxiliary.py index 5b4939b2..b802df12 100644 --- a/project_validator/facts/auxiliary.py +++ b/project_validator/facts/auxiliary.py @@ -1,11 +1,13 @@ """Auxiliary code: what `--auxiliary` names as not the product's, for the judging layer to hold to every practice as advisory (its failures are warnings that say so) instead of as the product's. -Every source outside vendored directories is the product's by default, whatever directory it is in: a C++ project's -`scripts/release.py` makes Python one of its languages, judged in full. `--auxiliary` names the code that is not, by -its role (`tooling`, `docs`, `example`, `benchmark`, `test`: see `project_validator.facts.roles`), by its language or -ecosystem (`python`, `c/c++`), or by a directory it is in (`scripts/`). What is named is a fact of the project -(`AuxiliaryCode`), so the questions can tell the code it names (`selectors`). +Every source outside vendored directories is the product's by default, whatever directory it is in, but for a +language written only in auxiliary code (see `implied`): a C++ project's `scripts/release.py` is tooling, and Python +not a language of its product, while a Python project's `scripts/release.py` is the product's. `--auxiliary` names +the code that is not the product's, by its role (`tooling`, `docs`, `example`, `benchmark`, `test`: see +`project_validator.facts.roles`), by its language or ecosystem (`python`, `c/c++`), or by a directory it is in +(`scripts/`). What is named is a fact of the project (`AuxiliaryCode`), so the questions can tell the code it names +(`selectors`). """ from __future__ import annotations @@ -21,9 +23,22 @@ @dataclass(frozen=True, slots=True, kw_only=True) class AuxiliaryCode(Fact): - """What `--auxiliary` named, as given.""" + """What `--auxiliary` named, as given, and the languages written only in auxiliary code (see `implied`).""" named: tuple[str, ...] + implied: tuple[str, ...] = () + + +def implied(role_: str) -> str: + """What names the code of a language written only in auxiliary code (`only in test code`), in the place of an + option given: the language is auxiliary in code of that role, though `--auxiliary` did not name it.""" + return f"only in {role_} code" + + +def as_given(name: str) -> str: + """How a name of auxiliary code reads in a finding: as the option given (`--auxiliary tooling`), or as it is + when the code is auxiliary by its language (`only in tooling code`).""" + return name if name.startswith("only in ") else f"--auxiliary {name}" def _languages_named(name: str) -> frozenset[str]: @@ -40,14 +55,16 @@ def _languages_named(name: str) -> frozenset[str]: class Selectors: """What `--auxiliary` named, resolved: each role, language (as the ecosystems spell it) and directory (without its trailing slash) to the name it was given as. A name is a role or a language before it is a directory - (`c++` is the language); a directory is anything else with a slash in it (`scripts/`, `tools/legacy`).""" + (`c++` is the language); a directory is anything else with a slash in it (`scripts/`, `tools/legacy`). The + languages written only in auxiliary code are `implied`: their code is named by its role (see `implied`).""" roles: Mapping[str, str] languages: Mapping[str, str] directories: Mapping[str, str] + implied: frozenset[str] = frozenset() @classmethod - def parse(cls, named: Iterable[str]) -> Selectors: + def parse(cls, named: Iterable[str], implied_: Iterable[str] = ()) -> Selectors: """Resolve what was named; a name that is no role, language, ecosystem or directory is a `ValueError`.""" roles: dict[str, str] = {} languages: dict[str, str] = {} @@ -65,16 +82,20 @@ def parse(cls, named: Iterable[str]) -> Selectors: raise ValueError( f"--auxiliary {name}: not a role ({roles_}), a language or ecosystem, or a directory (with a /)" ) - return cls(roles, languages, directories) + return cls(roles, languages, directories, frozenset(implied_)) def matching(self, path: str, language: str | None, *, directory: bool = False) -> str: """What names the code at `path` (a file, or a `directory`) in `language`, as it was given: its role, its - language, or a directory it is at or below; "" when nothing does (the code is the product's).""" - if found := self.roles.get(role(path, directory=directory)): + language, or a directory it is at or below, else its role when its language is written only in auxiliary + code; "" when nothing does (the code is the product's).""" + purpose = role(path, directory=directory) + if found := self.roles.get(purpose): return found if language is not None and (found := self.languages.get(language)): return found - return next((name for parent, name in self.directories.items() if within(path, parent)), "") + if found := next((name for parent, name in self.directories.items() if within(path, parent)), ""): + return found + return implied(purpose) if language in self.implied and purpose in AUXILIARY else "" def selectors(facts: Facts) -> Selectors: @@ -82,9 +103,9 @@ def selectors(facts: Facts) -> Selectors: def resolve() -> Selectors: named = facts.of(AuxiliaryCode) - return Selectors.parse(named[0].named if named else ()) + return Selectors.parse(named[0].named, named[0].implied) if named else Selectors.parse(()) return facts.shared("auxiliary", resolve) -__all__ = ["AuxiliaryCode", "Selectors", "selectors"] +__all__ = ["AuxiliaryCode", "Selectors", "as_given", "implied", "selectors"] diff --git a/project_validator/facts/structure.py b/project_validator/facts/structure.py index 6bcd4301..1ded57af 100644 --- a/project_validator/facts/structure.py +++ b/project_validator/facts/structure.py @@ -16,7 +16,7 @@ from project_validator.ecosystems import Ecosystem, Kind, build_systems, families, formats, registered from project_validator.facts import Fact, Facts, Origin from project_validator.facts.auxiliary import AuxiliaryCode, Selectors -from project_validator.facts.roles import role +from project_validator.facts.roles import AUXILIARY, role from project_validator.facts.tools import owner, within # Suffixes of files that are not source code of any language: documents, styles, media, archives, binaries and plain @@ -451,6 +451,33 @@ def _unit_roots(project: Project, builds: tuple[BuildFile, ...]) -> tuple[dict[s return roots, workspaces +def _languages_by_purpose(facts: Facts) -> tuple[set[str], set[str]]: + """The languages of the project's own sources in product code, and those in auxiliary code.""" + known = formats() + product: set[str] = set() + auxiliary: set[str] = set() + for source in facts.of(SourceFile): + if source.language is not None and source.language not in known and not source.vendored: + (auxiliary if source.role in AUXILIARY else product).add(source.language) + return product, auxiliary + + +def _auxiliary_languages(facts: Facts) -> frozenset[str]: + """The languages written only in auxiliary code (upstream #182): a test fixture in C, a docs theme's script, a + maintainer's script under `hack/`, that no build file outside auxiliary code builds, and of an ecosystem none of + whose languages is the product's (a Java project's tests in Kotlin are its own); none when the project has no + product language left (a project of examples alone is judged as it is).""" + known = formats() + product, auxiliary = _languages_by_purpose(facts) + built = (build for build in facts.of(BuildFile) if role(_directory(build), directory=True) not in AUXILIARY) + product |= given_way((language for build in built for language in build.languages), product) + product |= {name for name in _content_names(facts) if name not in known} + product |= { + language for ecosystem in registered() if ecosystem.languages & product for language in ecosystem.languages + } + return frozenset(auxiliary - product) if product else frozenset() + + def _own(languages: Iterable[str], path: str, named: Selectors, *, directory: bool = False) -> set[str]: """The languages of `languages` that the code at `path` (a file, or a `directory`) has as the product's: those `--auxiliary` does not name it in.""" @@ -520,8 +547,6 @@ def structure_facts(project: Project) -> Iterator[Fact]: ecosystems those show, and the unrecognised suffixes.""" generated = _generated(project) files = _outside(project.files(), generated) - named = Selectors.parse(project.auxiliary) - yield AuxiliaryCode(origin=Origin(path="."), named=tuple(project.auxiliary)) found, found_sources = _builds_and_sources(project, files, generated) content, located = _content(project) plain = Facts((*(fact for fact, _ in found if fact is not None), *found_sources, *content)) @@ -536,7 +561,11 @@ def structure_facts(project: Project) -> Iterator[Fact]: recognised |= {suffix for name in names for suffix in BUILT_LANGUAGE_SUFFIXES.get(name, ())} accounted = {*(path for _, path in found), *(source.path for source in sources), *located} yield from _unrecognised(files, accounted, recognised) - yield from _units(project, Facts((*plain, *ambiguous)), named) + every = Facts((*plain, *ambiguous)) + implied = _auxiliary_languages(every) + named = Selectors.parse(project.auxiliary, implied) + yield AuxiliaryCode(origin=Origin(path="."), named=tuple(project.auxiliary), implied=tuple(sorted(implied))) + yield from _units(project, every, named) __all__ = [ diff --git a/project_validator/judging.py b/project_validator/judging.py index 5cf7c012..6d64ccc6 100644 --- a/project_validator/judging.py +++ b/project_validator/judging.py @@ -14,6 +14,7 @@ from project_validator.core import Check, Context, Placed, Result, Status from project_validator.ecosystems import Ecosystem, ecosystems_for, registered from project_validator.facts import Facts +from project_validator.facts.auxiliary import as_given from project_validator.facts.roles import AUXILIARY from project_validator.facts.structure import SourceFile, Unit from project_validator.facts.tools import handling @@ -139,7 +140,7 @@ def _label(place: _Place, places: tuple[_Place, ...], auxiliary: _Auxiliary) -> def _advisory(result: Result, language: str, named: tuple[str, ...]) -> Result: """A failure of auxiliary code alone is a warning that says so, and what named the code (`--auxiliary ...`).""" - by = " ".join(f"--auxiliary {name}" for name in named) + by = " ".join(map(as_given, named)) return _warned(result, _ADVISORY.format(language=language, named=by)) @@ -193,7 +194,7 @@ def judged[A: UnitAnswer]( roles = _auxiliary_roles(context.facts) for answer, named in found: result = _advised(judge(answer, allow_unknown=context.options.allow_unknown), answer) - if role := roles.get(answer.unit): + if (role := roles.get(answer.unit)) and not named: result = _warned(result, _AUXILIARY_UNIT.format(unit=answer.unit, role=role)) results[(answer.language, answer.unit)] = _advisory(result, answer.language, named) if named else result none = "no unit of the project is written in these languages" diff --git a/tests/checks/test_code_formatting.py b/tests/checks/test_code_formatting.py index e38e8186..4e1be558 100644 --- a/tests/checks/test_code_formatting.py +++ b/tests/checks/test_code_formatting.py @@ -388,7 +388,8 @@ def test_a_language_only_auxiliary_code_uses_is_judged_as_advisory(self) -> None files = {"CMakeLists.txt": "project(app)\n", "src/a.cpp": "", "docs/conf.py": "", **CLANG_FORMAT} files |= github_job("ubuntu-latest", "clang-format -n -Werror src/a.cpp") with temp_project(files) as root: - self.assertEqual(code_formatting.run(make_context(root)).status, Status.FAIL) + # Python only in the docs is auxiliary by default (upstream #182), as it is when named. + self.assertEqual(code_formatting.run(make_context(root)).status, Status.WARN) context = make_context(root, auxiliary=("docs",)) self.assertIn("Python", context.structure.languages) result = code_formatting.run(context) diff --git a/tests/regressions/test_cmake.py b/tests/regressions/test_cmake.py index 2f1b2103..631b067c 100644 --- a/tests/regressions/test_cmake.py +++ b/tests/regressions/test_cmake.py @@ -152,7 +152,7 @@ def test_a_wrapper_around_add_custom_command_runs_its_linter(self) -> None: credited.""" files = {"CMakeLists.txt": C_PROJECT + GLOB_TARGET, "scripts/x.sh": "#!/bin/sh\n", **_built_target("lintsh")} result = _run(static_analysis, files) - self.assertIn("Shell: shellcheck runs", result.message) + self.assertIn("Shell (auxiliary: only in tooling code): shellcheck runs", result.message) def test_a_cmake_script_test_runner_runs_the_tests_it_executes(self) -> None: """neovim's unittest target runs busted through `cmake -D TEST_TYPE=unit -P cmake/RunTests.cmake`: the Lua diff --git a/tests/regressions/test_detection.py b/tests/regressions/test_detection.py index 9a55cff3..4bc17bb0 100644 --- a/tests/regressions/test_detection.py +++ b/tests/regressions/test_detection.py @@ -96,7 +96,6 @@ def _job(files: Mapping[str, str]) -> Job: class AuxiliaryLanguageTests(unittest.TestCase): - @unittest.expectedFailure # upstream #182: a fixture .c or docs .js makes a product language of the unit def test_a_language_only_in_auxiliary_files_is_not_the_products(self) -> None: """A Rust crate with a test fixture in C and a docs theme script is a Rust product: C and JavaScript are auxiliary, and tests-run does not fail for them (ripgrep, glib, fmt, ansible community.general).""" diff --git a/tests/snapshots/bare_ansible.facts.json b/tests/snapshots/bare_ansible.facts.json index 2de1072c..ab2933df 100644 --- a/tests/snapshots/bare_ansible.facts.json +++ b/tests/snapshots/bare_ansible.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -20,6 +15,12 @@ ], "origin": "." }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/bare_beam.facts.json b/tests/snapshots/bare_beam.facts.json index 2c46d5b4..941e6bf0 100644 --- a/tests/snapshots/bare_beam.facts.json +++ b/tests/snapshots/bare_beam.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Mix", "kind": "BuildFile", @@ -46,6 +41,12 @@ "origin": ".", "suffix": ".dump" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Mix" diff --git a/tests/snapshots/bare_c.facts.json b/tests/snapshots/bare_c.facts.json index 101f82e1..b3e59d49 100644 --- a/tests/snapshots/bare_c.facts.json +++ b/tests/snapshots/bare_c.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "CMake", "kind": "BuildFile", @@ -27,6 +22,12 @@ "origin": "third_party/cjson/cJSON.h", "role": "vendored" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "CMake" diff --git a/tests/snapshots/bare_clojure.facts.json b/tests/snapshots/bare_clojure.facts.json index 930163bb..d44387d6 100644 --- a/tests/snapshots/bare_clojure.facts.json +++ b/tests/snapshots/bare_clojure.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Leiningen", "kind": "BuildFile", @@ -27,6 +22,12 @@ "origin": "src/shop/core.clj", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Leiningen" diff --git a/tests/snapshots/bare_common_lisp.facts.json b/tests/snapshots/bare_common_lisp.facts.json index d057da8b..8a40af36 100644 --- a/tests/snapshots/bare_common_lisp.facts.json +++ b/tests/snapshots/bare_common_lisp.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "ASDF", "kind": "BuildFile", @@ -33,6 +28,12 @@ "origin": ".", "suffix": ".fasl" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "ASDF" diff --git a/tests/snapshots/bare_cpp.facts.json b/tests/snapshots/bare_cpp.facts.json index bb23a206..c3041887 100644 --- a/tests/snapshots/bare_cpp.facts.json +++ b/tests/snapshots/bare_cpp.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "CMake", "kind": "BuildFile", @@ -20,6 +15,12 @@ "origin": "third_party/json/json.hpp", "role": "vendored" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "CMake" diff --git a/tests/snapshots/bare_dart.facts.json b/tests/snapshots/bare_dart.facts.json index 327a5142..a24f750a 100644 --- a/tests/snapshots/bare_dart.facts.json +++ b/tests/snapshots/bare_dart.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "pub", "kind": "BuildFile", @@ -27,6 +22,12 @@ "origin": "pubspec.yaml", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "pub" diff --git a/tests/snapshots/bare_data.facts.json b/tests/snapshots/bare_data.facts.json index 1d87b6a1..27854f47 100644 --- a/tests/snapshots/bare_data.facts.json +++ b/tests/snapshots/bare_data.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -26,6 +21,12 @@ "origin": "settings.toml", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/bare_docker.facts.json b/tests/snapshots/bare_docker.facts.json index df741d08..0e041738 100644 --- a/tests/snapshots/bare_docker.facts.json +++ b/tests/snapshots/bare_docker.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -12,6 +7,12 @@ "origin": "Dockerfile", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/bare_documentation.facts.json b/tests/snapshots/bare_documentation.facts.json index 66969698..95cb436a 100644 --- a/tests/snapshots/bare_documentation.facts.json +++ b/tests/snapshots/bare_documentation.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -20,6 +15,12 @@ ], "origin": "." }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/bare_dotnet.facts.json b/tests/snapshots/bare_dotnet.facts.json index e6896047..e7afb6ad 100644 --- a/tests/snapshots/bare_dotnet.facts.json +++ b/tests/snapshots/bare_dotnet.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "MSBuild", "kind": "BuildFile", @@ -18,6 +13,12 @@ "origin": "src/App/Calculator.cs", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [], diff --git a/tests/snapshots/bare_emacs_lisp.facts.json b/tests/snapshots/bare_emacs_lisp.facts.json index 1ab59ff7..96d72446 100644 --- a/tests/snapshots/bare_emacs_lisp.facts.json +++ b/tests/snapshots/bare_emacs_lisp.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Eask", "kind": "BuildFile", @@ -27,6 +22,12 @@ "origin": "shop.elc", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Eask" diff --git a/tests/snapshots/bare_fortran.facts.json b/tests/snapshots/bare_fortran.facts.json index c4ab9e93..82297d18 100644 --- a/tests/snapshots/bare_fortran.facts.json +++ b/tests/snapshots/bare_fortran.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "fpm", "kind": "BuildFile", @@ -47,6 +42,12 @@ "origin": ".", "suffix": ".mod" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "fpm" diff --git a/tests/snapshots/bare_github_action.facts.json b/tests/snapshots/bare_github_action.facts.json index 30a081ba..a3126b69 100644 --- a/tests/snapshots/bare_github_action.facts.json +++ b/tests/snapshots/bare_github_action.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -20,6 +15,12 @@ ], "origin": "." }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/bare_go.facts.json b/tests/snapshots/bare_go.facts.json index e309af35..c8b8fd8d 100644 --- a/tests/snapshots/bare_go.facts.json +++ b/tests/snapshots/bare_go.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Go modules", "kind": "BuildFile", @@ -33,6 +28,12 @@ "origin": ".", "suffix": ".out" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Go modules" diff --git a/tests/snapshots/bare_graphql.facts.json b/tests/snapshots/bare_graphql.facts.json index b4469c9c..b2c1f59a 100644 --- a/tests/snapshots/bare_graphql.facts.json +++ b/tests/snapshots/bare_graphql.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ecosystem": "GraphQL", "kind": "ContentLanguages", @@ -20,6 +15,12 @@ "origin": "schema/schema.graphql", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/bare_haskell.facts.json b/tests/snapshots/bare_haskell.facts.json index dcfdefce..54f4e3e6 100644 --- a/tests/snapshots/bare_haskell.facts.json +++ b/tests/snapshots/bare_haskell.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Cabal", "kind": "BuildFile", @@ -33,6 +28,12 @@ "origin": ".", "suffix": ".hi" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Cabal" diff --git a/tests/snapshots/bare_javascript.facts.json b/tests/snapshots/bare_javascript.facts.json index 999ee9d8..0229df46 100644 --- a/tests/snapshots/bare_javascript.facts.json +++ b/tests/snapshots/bare_javascript.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "npm", "kind": "BuildFile", @@ -33,6 +28,12 @@ "origin": ".", "suffix": ".info" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "npm" diff --git a/tests/snapshots/bare_json_schema.facts.json b/tests/snapshots/bare_json_schema.facts.json index b8e452ab..19092f84 100644 --- a/tests/snapshots/bare_json_schema.facts.json +++ b/tests/snapshots/bare_json_schema.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -20,6 +15,12 @@ ], "origin": "schema" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/bare_julia.facts.json b/tests/snapshots/bare_julia.facts.json index f267ca5b..0fadccff 100644 --- a/tests/snapshots/bare_julia.facts.json +++ b/tests/snapshots/bare_julia.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Pkg", "kind": "BuildFile", @@ -33,6 +28,12 @@ "origin": ".", "suffix": ".cov" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Pkg" diff --git a/tests/snapshots/bare_jupyter.facts.json b/tests/snapshots/bare_jupyter.facts.json index 85d333d2..eb264f2e 100644 --- a/tests/snapshots/bare_jupyter.facts.json +++ b/tests/snapshots/bare_jupyter.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -12,6 +7,12 @@ "origin": "notebooks/prices.ipynb", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/bare_jvm.facts.json b/tests/snapshots/bare_jvm.facts.json index 3a4bb32c..ed2d6696 100644 --- a/tests/snapshots/bare_jvm.facts.json +++ b/tests/snapshots/bare_jvm.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Maven", "kind": "BuildFile", @@ -25,6 +20,12 @@ "origin": "src/main/java/com/example/App.java", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Maven" diff --git a/tests/snapshots/bare_kubernetes.facts.json b/tests/snapshots/bare_kubernetes.facts.json index 824b6cbb..b7fb7f4d 100644 --- a/tests/snapshots/bare_kubernetes.facts.json +++ b/tests/snapshots/bare_kubernetes.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -20,6 +15,12 @@ ], "origin": "." }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/bare_latex.facts.json b/tests/snapshots/bare_latex.facts.json index aae3cf48..8738c37f 100644 --- a/tests/snapshots/bare_latex.facts.json +++ b/tests/snapshots/bare_latex.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ecosystem": "LaTeX", "kind": "ContentLanguages", @@ -26,6 +21,12 @@ "origin": ".", "suffix": ".aux" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [], diff --git a/tests/snapshots/bare_lua.facts.json b/tests/snapshots/bare_lua.facts.json index f9e3fa85..c1f213eb 100644 --- a/tests/snapshots/bare_lua.facts.json +++ b/tests/snapshots/bare_lua.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "LuaRocks", "kind": "BuildFile", @@ -26,6 +21,12 @@ "origin": ".", "suffix": ".out" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "LuaRocks" diff --git a/tests/snapshots/bare_nix.facts.json b/tests/snapshots/bare_nix.facts.json index 73c63077..1ace8275 100644 --- a/tests/snapshots/bare_nix.facts.json +++ b/tests/snapshots/bare_nix.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Nix", "kind": "BuildFile", @@ -27,6 +22,12 @@ "origin": "shop.nix", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Nix" diff --git a/tests/snapshots/bare_ocaml.facts.json b/tests/snapshots/bare_ocaml.facts.json index 7da85364..b08463cb 100644 --- a/tests/snapshots/bare_ocaml.facts.json +++ b/tests/snapshots/bare_ocaml.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "dune", "kind": "BuildFile", @@ -28,6 +23,12 @@ "origin": "bin/main.ml", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "dune" diff --git a/tests/snapshots/bare_openapi.facts.json b/tests/snapshots/bare_openapi.facts.json index f03d7431..e4eb8e51 100644 --- a/tests/snapshots/bare_openapi.facts.json +++ b/tests/snapshots/bare_openapi.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -20,6 +15,12 @@ ], "origin": "." }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/bare_perl.facts.json b/tests/snapshots/bare_perl.facts.json index 9d1c9e6f..e43a69af 100644 --- a/tests/snapshots/bare_perl.facts.json +++ b/tests/snapshots/bare_perl.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "ExtUtils::MakeMaker", "kind": "BuildFile", @@ -34,6 +29,12 @@ "origin": "Makefile.PL", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "ExtUtils::MakeMaker" diff --git a/tests/snapshots/bare_php.facts.json b/tests/snapshots/bare_php.facts.json index 5e1200b5..8e1891b3 100644 --- a/tests/snapshots/bare_php.facts.json +++ b/tests/snapshots/bare_php.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Composer", "kind": "BuildFile", @@ -33,6 +28,12 @@ "origin": ".", "suffix": ".cache" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Composer" diff --git a/tests/snapshots/bare_protobuf.facts.json b/tests/snapshots/bare_protobuf.facts.json index 6d8450dd..271b530c 100644 --- a/tests/snapshots/bare_protobuf.facts.json +++ b/tests/snapshots/bare_protobuf.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -12,6 +7,12 @@ "origin": "proto/shop.proto", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/bare_python.facts.json b/tests/snapshots/bare_python.facts.json index 5edcaaf9..6d7189e6 100644 --- a/tests/snapshots/bare_python.facts.json +++ b/tests/snapshots/bare_python.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Python packaging", "kind": "BuildFile", @@ -27,6 +22,12 @@ "origin": "src/app/__init__.py", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Python packaging" diff --git a/tests/snapshots/bare_r.facts.json b/tests/snapshots/bare_r.facts.json index cfa32a93..e183ef28 100644 --- a/tests/snapshots/bare_r.facts.json +++ b/tests/snapshots/bare_r.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "R package", "kind": "BuildFile", @@ -20,6 +15,12 @@ "origin": "R/shop.R", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "R package" diff --git a/tests/snapshots/bare_racket.facts.json b/tests/snapshots/bare_racket.facts.json index 5153f3ee..aa279e96 100644 --- a/tests/snapshots/bare_racket.facts.json +++ b/tests/snapshots/bare_racket.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "raco pkg", "kind": "BuildFile", @@ -27,6 +22,12 @@ "origin": "main.rkt", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "raco pkg" diff --git a/tests/snapshots/bare_ruby.facts.json b/tests/snapshots/bare_ruby.facts.json index 01612a64..8d5452ab 100644 --- a/tests/snapshots/bare_ruby.facts.json +++ b/tests/snapshots/bare_ruby.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Bundler", "kind": "BuildFile", @@ -26,6 +21,12 @@ "origin": ".", "suffix": ".gem" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Bundler" diff --git a/tests/snapshots/bare_rust.facts.json b/tests/snapshots/bare_rust.facts.json index 801903a4..a72d2654 100644 --- a/tests/snapshots/bare_rust.facts.json +++ b/tests/snapshots/bare_rust.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Cargo", "kind": "BuildFile", @@ -34,6 +29,12 @@ "origin": "src/main.rs", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Cargo" diff --git a/tests/snapshots/bare_scala.facts.json b/tests/snapshots/bare_scala.facts.json index dc4f9ddd..4c55425b 100644 --- a/tests/snapshots/bare_scala.facts.json +++ b/tests/snapshots/bare_scala.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "sbt", "kind": "BuildFile", @@ -27,6 +22,12 @@ "origin": "build.sbt", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "sbt" diff --git a/tests/snapshots/bare_shell.facts.json b/tests/snapshots/bare_shell.facts.json index 0192971c..5125cc62 100644 --- a/tests/snapshots/bare_shell.facts.json +++ b/tests/snapshots/bare_shell.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -19,6 +14,12 @@ "origin": "src/shop.sh", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [], diff --git a/tests/snapshots/bare_sql.facts.json b/tests/snapshots/bare_sql.facts.json index 1ce51187..4a0ea0f9 100644 --- a/tests/snapshots/bare_sql.facts.json +++ b/tests/snapshots/bare_sql.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "dbt", "kind": "BuildFile", @@ -56,6 +51,12 @@ "origin": "models/orders.sql", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "dbt" diff --git a/tests/snapshots/bare_swift.facts.json b/tests/snapshots/bare_swift.facts.json index 3184237d..0355ed89 100644 --- a/tests/snapshots/bare_swift.facts.json +++ b/tests/snapshots/bare_swift.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "SwiftPM", "kind": "BuildFile", @@ -27,6 +22,12 @@ "origin": "Sources/App/main.swift", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "SwiftPM" diff --git a/tests/snapshots/bare_tabular_data.facts.json b/tests/snapshots/bare_tabular_data.facts.json index 9eede572..55fd27a2 100644 --- a/tests/snapshots/bare_tabular_data.facts.json +++ b/tests/snapshots/bare_tabular_data.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -20,6 +15,12 @@ ], "origin": "." }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/bare_terraform.facts.json b/tests/snapshots/bare_terraform.facts.json index bcd33805..e7e5fbc7 100644 --- a/tests/snapshots/bare_terraform.facts.json +++ b/tests/snapshots/bare_terraform.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -18,6 +13,12 @@ "origin": ".", "suffix": ".tfstate" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [], diff --git a/tests/snapshots/bare_typescript.facts.json b/tests/snapshots/bare_typescript.facts.json index 7e82b463..1cfc299f 100644 --- a/tests/snapshots/bare_typescript.facts.json +++ b/tests/snapshots/bare_typescript.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "npm", "kind": "BuildFile", @@ -33,6 +28,12 @@ "origin": ".", "suffix": ".info" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "npm" diff --git a/tests/snapshots/bare_typst.facts.json b/tests/snapshots/bare_typst.facts.json index bf432a23..179fdef9 100644 --- a/tests/snapshots/bare_typst.facts.json +++ b/tests/snapshots/bare_typst.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -12,6 +7,12 @@ "origin": "main.typ", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [], diff --git a/tests/snapshots/bare_xml_schemas.facts.json b/tests/snapshots/bare_xml_schemas.facts.json index 9d98d921..da674e19 100644 --- a/tests/snapshots/bare_xml_schemas.facts.json +++ b/tests/snapshots/bare_xml_schemas.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -35,6 +30,12 @@ ], "origin": "xslt" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/bare_zig.facts.json b/tests/snapshots/bare_zig.facts.json index d92c53b3..4a6e332d 100644 --- a/tests/snapshots/bare_zig.facts.json +++ b/tests/snapshots/bare_zig.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Zig build", "kind": "BuildFile", @@ -27,6 +22,12 @@ "origin": "src/main.zig", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Zig build" diff --git a/tests/snapshots/buildable.facts.json b/tests/snapshots/buildable.facts.json index 04b472e7..a84f5c9a 100644 --- a/tests/snapshots/buildable.facts.json +++ b/tests/snapshots/buildable.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "CMake", "kind": "BuildFile", @@ -13,6 +8,12 @@ ], "origin": "CMakeLists.txt" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "CMake" diff --git a/tests/snapshots/well_configured_ansible.facts.json b/tests/snapshots/well_configured_ansible.facts.json index 2ca15270..36bd2714 100644 --- a/tests/snapshots/well_configured_ansible.facts.json +++ b/tests/snapshots/well_configured_ansible.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -111,6 +106,12 @@ "origin": "roles/shop/templates/shop.conf.j2", "role": "template" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/well_configured_beam.facts.json b/tests/snapshots/well_configured_beam.facts.json index 71aea1ec..a7ac1d01 100644 --- a/tests/snapshots/well_configured_beam.facts.json +++ b/tests/snapshots/well_configured_beam.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Mix", "kind": "BuildFile", @@ -97,6 +92,12 @@ "origin": "test/test_helper.exs", "role": "test" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Mix" diff --git a/tests/snapshots/well_configured_c.facts.json b/tests/snapshots/well_configured_c.facts.json index 422799e6..7de15d53 100644 --- a/tests/snapshots/well_configured_c.facts.json +++ b/tests/snapshots/well_configured_c.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "CMake", "kind": "BuildFile", @@ -74,6 +69,12 @@ "origin": "cmake/Dependencies.cmake", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "CMake" diff --git a/tests/snapshots/well_configured_clojure.facts.json b/tests/snapshots/well_configured_clojure.facts.json index d4b5c58e..f658623c 100644 --- a/tests/snapshots/well_configured_clojure.facts.json +++ b/tests/snapshots/well_configured_clojure.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Clojure CLI", "kind": "BuildFile", @@ -83,6 +78,12 @@ "origin": "tests.edn", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Clojure CLI" diff --git a/tests/snapshots/well_configured_common_lisp.facts.json b/tests/snapshots/well_configured_common_lisp.facts.json index 1fa2c399..c28dfc62 100644 --- a/tests/snapshots/well_configured_common_lisp.facts.json +++ b/tests/snapshots/well_configured_common_lisp.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "ASDF", "kind": "BuildFile", @@ -62,6 +57,12 @@ "origin": "shop.asd", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "ASDF" diff --git a/tests/snapshots/well_configured_cpp.facts.json b/tests/snapshots/well_configured_cpp.facts.json index 51e37e9f..18c221c8 100644 --- a/tests/snapshots/well_configured_cpp.facts.json +++ b/tests/snapshots/well_configured_cpp.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "CMake", "kind": "BuildFile", @@ -74,6 +69,12 @@ "origin": "cmake/Dependencies.cmake", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "CMake" diff --git a/tests/snapshots/well_configured_dart.facts.json b/tests/snapshots/well_configured_dart.facts.json index e46066f8..ee5efca8 100644 --- a/tests/snapshots/well_configured_dart.facts.json +++ b/tests/snapshots/well_configured_dart.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "pub", "kind": "BuildFile", @@ -83,6 +78,12 @@ "origin": "test/shop_test.dart", "role": "test" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "pub" diff --git a/tests/snapshots/well_configured_data.facts.json b/tests/snapshots/well_configured_data.facts.json index 812a2fee..f9418943 100644 --- a/tests/snapshots/well_configured_data.facts.json +++ b/tests/snapshots/well_configured_data.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -112,6 +107,12 @@ ], "origin": "schema" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/well_configured_docker.facts.json b/tests/snapshots/well_configured_docker.facts.json index eaec1915..741b3c32 100644 --- a/tests/snapshots/well_configured_docker.facts.json +++ b/tests/snapshots/well_configured_docker.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -47,6 +42,12 @@ "origin": "Dockerfile", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/well_configured_documentation.facts.json b/tests/snapshots/well_configured_documentation.facts.json index 4355579d..b87ee6b2 100644 --- a/tests/snapshots/well_configured_documentation.facts.json +++ b/tests/snapshots/well_configured_documentation.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -55,6 +50,12 @@ ], "origin": "." }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/well_configured_dotnet.facts.json b/tests/snapshots/well_configured_dotnet.facts.json index 0c66f5f4..613eb905 100644 --- a/tests/snapshots/well_configured_dotnet.facts.json +++ b/tests/snapshots/well_configured_dotnet.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "MSBuild", "kind": "BuildFile", @@ -113,6 +108,12 @@ "origin": "tests/App.Tests/packages.lock.json", "role": "test" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "MSBuild" diff --git a/tests/snapshots/well_configured_emacs_lisp.facts.json b/tests/snapshots/well_configured_emacs_lisp.facts.json index 88fd3afb..d8c3bbe9 100644 --- a/tests/snapshots/well_configured_emacs_lisp.facts.json +++ b/tests/snapshots/well_configured_emacs_lisp.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Eask", "kind": "BuildFile", @@ -55,6 +50,12 @@ "origin": "test/shop-test.el", "role": "test" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Eask" diff --git a/tests/snapshots/well_configured_fortran.facts.json b/tests/snapshots/well_configured_fortran.facts.json index 4b7cc346..5a90f322 100644 --- a/tests/snapshots/well_configured_fortran.facts.json +++ b/tests/snapshots/well_configured_fortran.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "fpm", "kind": "BuildFile", @@ -76,6 +71,12 @@ "origin": "test/check.f90", "role": "test" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "fpm" diff --git a/tests/snapshots/well_configured_github_action.facts.json b/tests/snapshots/well_configured_github_action.facts.json index 4f99c62b..33401b5f 100644 --- a/tests/snapshots/well_configured_github_action.facts.json +++ b/tests/snapshots/well_configured_github_action.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -48,6 +43,12 @@ ], "origin": "." }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/well_configured_go.facts.json b/tests/snapshots/well_configured_go.facts.json index a3215396..6b7cc3e2 100644 --- a/tests/snapshots/well_configured_go.facts.json +++ b/tests/snapshots/well_configured_go.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Go modules", "kind": "BuildFile", @@ -83,6 +78,12 @@ "origin": "cmd/app/main.go", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Go modules" diff --git a/tests/snapshots/well_configured_graphql.facts.json b/tests/snapshots/well_configured_graphql.facts.json index 85582595..e412892c 100644 --- a/tests/snapshots/well_configured_graphql.facts.json +++ b/tests/snapshots/well_configured_graphql.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -62,6 +57,12 @@ "origin": "schema/schema.graphql", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/well_configured_haskell.facts.json b/tests/snapshots/well_configured_haskell.facts.json index 0255f00b..8f746e9e 100644 --- a/tests/snapshots/well_configured_haskell.facts.json +++ b/tests/snapshots/well_configured_haskell.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Cabal", "kind": "BuildFile", @@ -77,6 +72,12 @@ "origin": "test/Spec.hs", "role": "test" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Cabal" diff --git a/tests/snapshots/well_configured_javascript.facts.json b/tests/snapshots/well_configured_javascript.facts.json index 1a501f94..7b316bb7 100644 --- a/tests/snapshots/well_configured_javascript.facts.json +++ b/tests/snapshots/well_configured_javascript.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "npm", "kind": "BuildFile", @@ -97,6 +92,12 @@ "origin": "stryker.config.json", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "npm" diff --git a/tests/snapshots/well_configured_json_schema.facts.json b/tests/snapshots/well_configured_json_schema.facts.json index c654c50b..ad17eab5 100644 --- a/tests/snapshots/well_configured_json_schema.facts.json +++ b/tests/snapshots/well_configured_json_schema.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -69,6 +64,12 @@ ], "origin": "schema" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/well_configured_julia.facts.json b/tests/snapshots/well_configured_julia.facts.json index c63c6138..520fcd64 100644 --- a/tests/snapshots/well_configured_julia.facts.json +++ b/tests/snapshots/well_configured_julia.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Pkg", "kind": "BuildFile", @@ -69,6 +64,12 @@ "origin": "test/runtests.jl", "role": "test" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Pkg" diff --git a/tests/snapshots/well_configured_jupyter.facts.json b/tests/snapshots/well_configured_jupyter.facts.json index 982f0356..1e907b60 100644 --- a/tests/snapshots/well_configured_jupyter.facts.json +++ b/tests/snapshots/well_configured_jupyter.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -47,6 +42,12 @@ "origin": "ruff.toml", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/well_configured_jvm.facts.json b/tests/snapshots/well_configured_jvm.facts.json index 7aaa897e..89eb9adc 100644 --- a/tests/snapshots/well_configured_jvm.facts.json +++ b/tests/snapshots/well_configured_jvm.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Maven", "kind": "BuildFile", @@ -74,6 +69,12 @@ "origin": "src/test/java/com/example/AppTest.java", "role": "test" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Maven" diff --git a/tests/snapshots/well_configured_kubernetes.facts.json b/tests/snapshots/well_configured_kubernetes.facts.json index 117e0638..62a65705 100644 --- a/tests/snapshots/well_configured_kubernetes.facts.json +++ b/tests/snapshots/well_configured_kubernetes.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -90,6 +85,12 @@ "origin": "charts/shop/templates/_helpers.tpl", "role": "template" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/well_configured_latex.facts.json b/tests/snapshots/well_configured_latex.facts.json index f35183dd..10860ee0 100644 --- a/tests/snapshots/well_configured_latex.facts.json +++ b/tests/snapshots/well_configured_latex.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -55,6 +50,12 @@ "origin": "main.tex", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/well_configured_lua.facts.json b/tests/snapshots/well_configured_lua.facts.json index 18d251d4..bc02239e 100644 --- a/tests/snapshots/well_configured_lua.facts.json +++ b/tests/snapshots/well_configured_lua.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "LuaRocks", "kind": "BuildFile", @@ -76,6 +71,12 @@ "origin": "stylua.toml", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "LuaRocks" diff --git a/tests/snapshots/well_configured_nix.facts.json b/tests/snapshots/well_configured_nix.facts.json index 096ff38f..b61448dc 100644 --- a/tests/snapshots/well_configured_nix.facts.json +++ b/tests/snapshots/well_configured_nix.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Nix flake", "kind": "BuildFile", @@ -55,6 +50,12 @@ "origin": "shop.nix", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Nix flake" diff --git a/tests/snapshots/well_configured_ocaml.facts.json b/tests/snapshots/well_configured_ocaml.facts.json index 5aa8557b..ca1a8c63 100644 --- a/tests/snapshots/well_configured_ocaml.facts.json +++ b/tests/snapshots/well_configured_ocaml.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "dune", "kind": "BuildFile", @@ -86,6 +81,12 @@ "origin": "test/test_shop.ml", "role": "test" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "dune", diff --git a/tests/snapshots/well_configured_openapi.facts.json b/tests/snapshots/well_configured_openapi.facts.json index 657c6cdf..98495b92 100644 --- a/tests/snapshots/well_configured_openapi.facts.json +++ b/tests/snapshots/well_configured_openapi.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -55,6 +50,12 @@ ], "origin": "." }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/well_configured_perl.facts.json b/tests/snapshots/well_configured_perl.facts.json index 7155ad62..758fed9e 100644 --- a/tests/snapshots/well_configured_perl.facts.json +++ b/tests/snapshots/well_configured_perl.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "ExtUtils::MakeMaker", "kind": "BuildFile", @@ -77,6 +72,12 @@ "origin": "t/shop.t", "role": "test" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "ExtUtils::MakeMaker", diff --git a/tests/snapshots/well_configured_php.facts.json b/tests/snapshots/well_configured_php.facts.json index ac72a788..93969460 100644 --- a/tests/snapshots/well_configured_php.facts.json +++ b/tests/snapshots/well_configured_php.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Composer", "kind": "BuildFile", @@ -81,6 +76,12 @@ "origin": ".", "suffix": ".json5" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Composer" diff --git a/tests/snapshots/well_configured_protobuf.facts.json b/tests/snapshots/well_configured_protobuf.facts.json index ea83e69d..1afa3c38 100644 --- a/tests/snapshots/well_configured_protobuf.facts.json +++ b/tests/snapshots/well_configured_protobuf.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -47,6 +42,12 @@ "origin": "proto/shop/v1/shop.proto", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/well_configured_python.facts.json b/tests/snapshots/well_configured_python.facts.json index 37951a3b..d7416788 100644 --- a/tests/snapshots/well_configured_python.facts.json +++ b/tests/snapshots/well_configured_python.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Python packaging", "kind": "BuildFile", @@ -69,6 +64,12 @@ "origin": "tests/test_app.py", "role": "test" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Python packaging" diff --git a/tests/snapshots/well_configured_r.facts.json b/tests/snapshots/well_configured_r.facts.json index 257a40c5..bb49a2b9 100644 --- a/tests/snapshots/well_configured_r.facts.json +++ b/tests/snapshots/well_configured_r.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "R package", "kind": "BuildFile", @@ -69,6 +64,12 @@ "origin": "tests/testthat/test-shop.R", "role": "test" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "R package" diff --git a/tests/snapshots/well_configured_racket.facts.json b/tests/snapshots/well_configured_racket.facts.json index d39cebd9..cc9e54c6 100644 --- a/tests/snapshots/well_configured_racket.facts.json +++ b/tests/snapshots/well_configured_racket.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "raco pkg", "kind": "BuildFile", @@ -55,6 +50,12 @@ "origin": "main.rkt", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "raco pkg" diff --git a/tests/snapshots/well_configured_ruby.facts.json b/tests/snapshots/well_configured_ruby.facts.json index 2074c5af..248c06dc 100644 --- a/tests/snapshots/well_configured_ruby.facts.json +++ b/tests/snapshots/well_configured_ruby.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Bundler", "kind": "BuildFile", @@ -97,6 +92,12 @@ "origin": ".", "suffix": ".rbs" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Bundler" diff --git a/tests/snapshots/well_configured_rust.facts.json b/tests/snapshots/well_configured_rust.facts.json index 69843b5e..71e3f169 100644 --- a/tests/snapshots/well_configured_rust.facts.json +++ b/tests/snapshots/well_configured_rust.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Cargo", "kind": "BuildFile", @@ -91,6 +86,12 @@ "origin": "src/lib.rs", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Cargo" diff --git a/tests/snapshots/well_configured_scala.facts.json b/tests/snapshots/well_configured_scala.facts.json index 7262c222..4f039961 100644 --- a/tests/snapshots/well_configured_scala.facts.json +++ b/tests/snapshots/well_configured_scala.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "sbt", "kind": "BuildFile", @@ -90,6 +85,12 @@ "origin": ".", "suffix": ".properties" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "sbt" diff --git a/tests/snapshots/well_configured_shell.facts.json b/tests/snapshots/well_configured_shell.facts.json index a4355ae5..36420855 100644 --- a/tests/snapshots/well_configured_shell.facts.json +++ b/tests/snapshots/well_configured_shell.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -76,6 +71,12 @@ "origin": "PSScriptAnalyzerSettings.psd1", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/well_configured_sql.facts.json b/tests/snapshots/well_configured_sql.facts.json index 5450b4a6..8c480a43 100644 --- a/tests/snapshots/well_configured_sql.facts.json +++ b/tests/snapshots/well_configured_sql.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "dbt", "kind": "BuildFile", @@ -105,6 +100,12 @@ "origin": "tests/assert_positive_amounts.sql", "role": "test" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "dbt" diff --git a/tests/snapshots/well_configured_swift.facts.json b/tests/snapshots/well_configured_swift.facts.json index 0e9f5d30..ec44180d 100644 --- a/tests/snapshots/well_configured_swift.facts.json +++ b/tests/snapshots/well_configured_swift.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "SwiftPM", "kind": "BuildFile", @@ -104,6 +99,12 @@ "origin": "muter.conf.yml", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "SwiftPM" diff --git a/tests/snapshots/well_configured_tabular_data.facts.json b/tests/snapshots/well_configured_tabular_data.facts.json index 287e278b..c7b6975a 100644 --- a/tests/snapshots/well_configured_tabular_data.facts.json +++ b/tests/snapshots/well_configured_tabular_data.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -48,6 +43,12 @@ ], "origin": "." }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/well_configured_terraform.facts.json b/tests/snapshots/well_configured_terraform.facts.json index 5d7c99f2..accfdc08 100644 --- a/tests/snapshots/well_configured_terraform.facts.json +++ b/tests/snapshots/well_configured_terraform.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -75,6 +70,12 @@ "origin": "tests/name.tftest.hcl", "role": "test" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/well_configured_typescript.facts.json b/tests/snapshots/well_configured_typescript.facts.json index 4740816f..66bfb31b 100644 --- a/tests/snapshots/well_configured_typescript.facts.json +++ b/tests/snapshots/well_configured_typescript.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "npm", "kind": "BuildFile", @@ -104,6 +99,12 @@ "origin": "tsconfig.json", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "npm" diff --git a/tests/snapshots/well_configured_typst.facts.json b/tests/snapshots/well_configured_typst.facts.json index 802ae4d1..10c9b0d7 100644 --- a/tests/snapshots/well_configured_typst.facts.json +++ b/tests/snapshots/well_configured_typst.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -40,6 +35,12 @@ "origin": "main.typ", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/well_configured_xml_schemas.facts.json b/tests/snapshots/well_configured_xml_schemas.facts.json index af431ca9..7e508bf5 100644 --- a/tests/snapshots/well_configured_xml_schemas.facts.json +++ b/tests/snapshots/well_configured_xml_schemas.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "ambiguous": false, "kind": "SourceFile", @@ -84,6 +79,12 @@ ], "origin": "xslt" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [], "formats": [ diff --git a/tests/snapshots/well_configured_zig.facts.json b/tests/snapshots/well_configured_zig.facts.json index 3a03f264..d9dc438e 100644 --- a/tests/snapshots/well_configured_zig.facts.json +++ b/tests/snapshots/well_configured_zig.facts.json @@ -1,10 +1,5 @@ { "facts": [ - { - "kind": "AuxiliaryCode", - "named": [], - "origin": "." - }, { "build_system": "Zig build", "kind": "BuildFile", @@ -84,6 +79,12 @@ "origin": "build.zig.zon", "role": "product" }, + { + "implied": [], + "kind": "AuxiliaryCode", + "named": [], + "origin": "." + }, { "build_systems": [ "Zig build" diff --git a/tests/test_facts.py b/tests/test_facts.py index 43a36b37..4c016172 100644 --- a/tests/test_facts.py +++ b/tests/test_facts.py @@ -398,11 +398,11 @@ def test_malformed_documents_yield_what_they_can(self) -> None: facts = _facts({GITHUB_WORKFLOW: workflow, ".github/workflows/list.yml": "- a\n", ".gitlab-ci.yml": "- a\n"}) self.assertEqual(_argvs(facts), [("ctest",)]) # ctest is a test runner, but the project has no language to run it for, so there is no run; the job builds, - # on Linux. The structure facts every project has (what --auxiliary named, the three YAML files, the root + # on Linux. The structure facts every project has (the three YAML files, what is auxiliary code, the root # unit) come first, then the data files. found = [type(fact) for fact in facts if not isinstance(fact, CiConfiguration)] yaml, data = [SourceFile] * 3, [DataFile] * 3 - self.assertEqual(found, [AuxiliaryCode, *yaml, Unit, *data, CiJob, Command, Job]) + self.assertEqual(found, [*yaml, AuxiliaryCode, Unit, *data, CiJob, Command, Job]) def test_invalid_yaml_is_unknown(self) -> None: facts = _facts({GITHUB_WORKFLOW: "jobs: [\n"}) diff --git a/tests/test_judging.py b/tests/test_judging.py index 993d8456..e9825af2 100644 --- a/tests/test_judging.py +++ b/tests/test_judging.py @@ -266,9 +266,10 @@ def _result(self, files: Mapping[str, str]) -> Result: def test_a_benchmark_units_failure_beside_a_passing_product_warns(self) -> None: result = self._result({**PRODUCT, **BENCHMARK}) self.assertEqual(result.status, Status.WARN, result) - self.assertIn( - "Rust: a warning, not a failure: benches is benchmark code, not the product's", result.details, result - ) + # Rust, written only in the benchmark, is auxiliary code by its language (upstream #182), which says so once. + advisory = "a warning, not a failure: the Rust here is auxiliary code (only in benchmark code)" + self.assertIn(f"Rust (auxiliary: only in benchmark code): {advisory}", result.details, result) + self.assertFalse(any("benches is benchmark code" in detail for detail in result.details), result) def test_a_benchmark_unit_alone_is_judged_as_it_is(self) -> None: result = self._result(BENCHMARK) diff --git a/tests/test_units.py b/tests/test_units.py index d773780c..e78c70ac 100644 --- a/tests/test_units.py +++ b/tests/test_units.py @@ -282,15 +282,27 @@ def _ecosystems(result: Result) -> set[str]: class AuxiliaryCodeTests(unittest.TestCase): - """Every language is the product's and held to every practice, in whatever directory it is, until `--auxiliary` - names code (by role, language or directory) that is not: that code is still judged in full, but a failure is a + """A language is the product's and held to every practice, in whatever directory it is, until `--auxiliary` + names code (by role, language or directory) that is not, or unless it is written only in auxiliary code (tests, + examples, docs, tooling, benchmarks: upstream #182): that code is still judged in full, but a failure is a warning, and the report says what named the code.""" - def test_helper_scripts_are_judged_as_the_product_by_default(self) -> None: + def test_a_language_only_in_helper_scripts_is_auxiliary_by_default(self) -> None: + """A C++ project's release script in Python is tooling: Python is not a language of the product.""" + advisory = "a warning, not a failure: the Python here is auxiliary code (only in tooling code)" for name in (*PRACTICES, "platform-matrix"): with self.subTest(name): result = _check(name, HELPER_SCRIPTS) python = _place(result, "Python") + self.assertEqual((python.result.status, python.auxiliary), (Status.WARN, ("only in tooling code",))) + self.assertIn(advisory, python.result.details) + self.assertIn("Python (auxiliary: only in tooling code): ", result.message) + + def test_a_language_with_product_code_is_judged_as_the_products_in_its_helper_scripts_too(self) -> None: + for name in (*PRACTICES, "platform-matrix"): + with self.subTest(name): + result = _check(name, {**HELPER_SCRIPTS, "src/gen.py": ""}) + python = _place(result, "Python") self.assertEqual((python.result.status, python.auxiliary), (Status.FAIL, ())) self.assertNotIn("auxiliary", result.message + "".join(result.details)) @@ -362,7 +374,8 @@ def test_test_helpers_can_be_named_without_losing_the_tests(self) -> None: files["CMakeLists.txt"] = "project(app CXX)\nenable_testing()\nadd_test(NAME t COMMAND t)\n" files |= _workflow(("ctest --test-dir build", None)) del files["scripts/release.py"] - self.assertEqual(_place(_check("static-analysis", files), "Python").result.status, Status.FAIL) + python = _place(_check("static-analysis", files), "Python") + self.assertEqual((python.result.status, python.auxiliary), (Status.WARN, ("only in test code",))) named = _check("tests-run", files, ("test",)) self.assertEqual(_place(named, "C++").result.status, Status.PASS, named.message) python = _place(named, "Python") @@ -386,7 +399,9 @@ def test_the_json_report_and_the_grid_mark_auxiliary_code(self) -> None: places = {(place["ecosystem"], place["unit"]): place for place in report["places"]} self.assertEqual(set(places), {("C++", "."), ("Python", ".")}) python = places[("Python", ".")] - self.assertEqual((python["status"], python["auxiliary"], python["tools"]), ("FAIL", [], [])) + self.assertEqual( + (python["status"], python["auxiliary"], python["tools"]), ("WARN", ["only in tooling code"], []) + ) self.assertEqual(python["message"], "no static analyzer runs") arguments = ("--only", "static-analysis", "--auxiliary", "tooling", str(root)) code, output, _ = run_cli(*arguments, "--format", "json") @@ -398,7 +413,9 @@ def test_the_json_report_and_the_grid_mark_auxiliary_code(self) -> None: code, grid, _ = run_cli(*arguments, "--format", "markdown") self.assertIn(f"| {MARKS[Status.WARN]} (auxiliary) |", grid) code, facts, _ = run_cli(*arguments, "--facts") - self.assertIn({"kind": "AuxiliaryCode", "origin": ".", "named": ["tooling"]}, json.loads(facts)) + self.assertIn( + {"kind": "AuxiliaryCode", "origin": ".", "named": ["tooling"], "implied": ["Python"]}, json.loads(facts) + ) def test_the_answers_say_what_named_the_code(self) -> None: with temp_project({**HELPER_SCRIPTS, "benchmarks/run.py": ""}) as root: diff --git a/tests/test_views.py b/tests/test_views.py index 62345fb1..72265337 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -190,7 +190,8 @@ def test_the_skipped_checks_are_counted_unless_verbose(self) -> None: def test_a_result_of_several_places_has_a_line_for_each(self) -> None: output = self._render(_analysis()) - self.assertRegex(output, r"✘ +Python +no static analyzer runs") + self.assertRegex(output, r"✘ +C\+\+ +no static analyzer runs") + self.assertRegex(output, r"▲ +Python \(auxiliary: only in tooling code\) +no static analyzer runs") def test_long_details_are_cut_unless_verbose(self) -> None: analysis = _analysis(fixture="well_configured_cpp") From a9597e9ac2aab2faff4b433cc4a3a27b85c131c4 Mon Sep 17 00:00:00 2001 From: leftibot Date: Mon, 23 Nov 2026 22:17:40 -0700 Subject: [PATCH 3/8] Make a nested package a unit of its own; do not ask auxiliary units for product-only gates Part of #188 and #230. A build file below another of its build system's is a project of its own where the build system says so (`BuildSystem.standalone`): a nested Package.swift, mix.exs, Cargo.toml (a package or workspace), package.json with a name, pubspec, fpm.toml, dbt_project.yml, composer.json, pyproject.toml, go.mod, .cabal, Gemfile, deps.edn or project.clj. It becomes a unit with the role its directory tells: vapor's Benchmarks/, phoenix's installer/ and integration_test/, dbt-utils' integration_tests/. A CMake subdirectory, a Maven module, LuaRocks' rockspecs/, a package.json that only marks its directory's modules and a test fixture's manifest stay part of the unit above them. A unit the map names auxiliary (a cargo-fuzz crate, a benchmark package) is not judged for the gates of the product alone (NOT_FOR_AUXILIARY, now shared by the score and the checks), nor asked for tests it does not have (tests-run judges one that has tests). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt --- project_validator/build_systems/model.py | 13 +- project_validator/checks/tests_run.py | 2 + project_validator/ecosystems/beam.py | 5 +- project_validator/ecosystems/clojure.py | 17 +- project_validator/ecosystems/dart.py | 8 +- project_validator/ecosystems/fortran.py | 2 + project_validator/ecosystems/go.py | 2 + .../ecosystems/haskell/__init__.py | 2 + .../ecosystems/javascript/__init__.py | 35 +- project_validator/ecosystems/php/__init__.py | 3 +- .../ecosystems/python/__init__.py | 2 + project_validator/ecosystems/ruby/__init__.py | 3 +- project_validator/ecosystems/rust/__init__.py | 7 + project_validator/ecosystems/sql.py | 3 +- project_validator/ecosystems/swift.py | 2 + project_validator/ecosystems/zig.py | 2 + project_validator/facts/roles.py | 11 +- project_validator/facts/structure.py | 20 +- project_validator/judging.py | 54 +- project_validator/score.py | 15 +- tests/checks/test_dependency_management.py | 6 +- .../snapshots/well_configured_rust.facts.json | 27 + tests/snapshots/well_configured_rust.json | 472 +++++++++++++++++- tests/test_leaderboard.py | 5 +- tests/test_units.py | 50 +- 25 files changed, 718 insertions(+), 50 deletions(-) diff --git a/project_validator/build_systems/model.py b/project_validator/build_systems/model.py index 32538458..09e29976 100644 --- a/project_validator/build_systems/model.py +++ b/project_validator/build_systems/model.py @@ -27,6 +27,10 @@ class BuildSystem: `members` reads, from a build file, the directories (globs relative to it) of the workspace it declares; each member is a unit of the project of its own (see `project_validator.facts.structure.Unit`). `compiler_evidence` gives the words of one of its commands that show the compiler it builds with. + `standalone` tells, from its text, whether one of its build files below another of its build files is a project + of its own (a nested Package.swift, a package.json with a name; see `standalone_package`), a unit of the project + with the role its directory tells; None: a nested build file is part of the one above it (a CMake + subdirectory, a Maven module). """ name: str @@ -40,6 +44,13 @@ class BuildSystem: configured_build_types: Callable[[Command, Callable[[str], str | None]], frozenset[str]] | None = None members: Callable[[str], tuple[str, ...]] | None = None compiler_evidence: Callable[[tuple[str, ...]], tuple[str, ...]] | None = None + standalone: Callable[[str], bool] | None = None -__all__ = ["C_FAMILY", "BuildSystem"] +def standalone_package(_text: str) -> bool: + """Every build file of a build system whose nested build files are projects of their own (a nested Mix project + is a package of its own, whatever it says).""" + return True + + +__all__ = ["C_FAMILY", "BuildSystem", "standalone_package"] diff --git a/project_validator/checks/tests_run.py b/project_validator/checks/tests_run.py index 42109077..789b9379 100644 --- a/project_validator/checks/tests_run.py +++ b/project_validator/checks/tests_run.py @@ -12,4 +12,6 @@ answers=tests, judge=judge_tests, aliases=("ctest-runs",), + # A unit the map names auxiliary is asked for tests it has: a cargo-fuzz crate need hold none (upstream #230). + auxiliary_unit=lambda answer: bool(answer.definitions() or answer.unknown_definitions), ) diff --git a/project_validator/ecosystems/beam.py b/project_validator/ecosystems/beam.py index a9af8f5a..9149f150 100644 --- a/project_validator/ecosystems/beam.py +++ b/project_validator/ecosystems/beam.py @@ -11,6 +11,7 @@ import re from collections.abc import Callable, Iterator +from project_validator.build_systems.model import standalone_package from project_validator.core import Context from project_validator.ecosystems.model import BuildSystem, Ecosystem, subcommands, toolchain_patterns from project_validator.facts import Command, Facts, Origin, Setting, resolved @@ -53,7 +54,9 @@ def _umbrella_members(text: str) -> tuple[str, ...]: # A Mix project compiles the Erlang sources in `src/` too; an umbrella's applications are the units. -MIX = BuildSystem(name="Mix", files=(MIX_FILE,), languages=ELIXIR_ONLY, members=_umbrella_members) +MIX = BuildSystem( + name="Mix", files=(MIX_FILE,), languages=ELIXIR_ONLY, members=_umbrella_members, standalone=standalone_package +) REBAR3 = BuildSystem(name="rebar3", files=(REBAR_CONFIG, "rebar.config.script"), languages=ERLANG_ONLY) diff --git a/project_validator/ecosystems/clojure.py b/project_validator/ecosystems/clojure.py index d83a4b42..693460f5 100644 --- a/project_validator/ecosystems/clojure.py +++ b/project_validator/ecosystems/clojure.py @@ -10,6 +10,7 @@ import re from pathlib import Path +from project_validator.build_systems.model import standalone_package from project_validator.core import Context from project_validator.ecosystems.model import BuildSystem, Ecosystem, subcommands, toolchain_patterns from project_validator.facts import Command, Facts, Origin, resolved @@ -42,8 +43,20 @@ def _is_build_tree(directory: Path) -> bool: return directory.name == "target" and any((directory.parent / name).is_file() for name in (DEPS_EDN, PROJECT_CLJ)) -CLOJURE_CLI = BuildSystem(name="Clojure CLI", files=(DEPS_EDN,), languages=CLOJURE, is_build_tree=_is_build_tree) -LEININGEN = BuildSystem(name="Leiningen", files=(PROJECT_CLJ,), languages=CLOJURE, is_build_tree=_is_build_tree) +CLOJURE_CLI = BuildSystem( + name="Clojure CLI", + files=(DEPS_EDN,), + languages=CLOJURE, + is_build_tree=_is_build_tree, + standalone=standalone_package, +) +LEININGEN = BuildSystem( + name="Leiningen", + files=(PROJECT_CLJ,), + languages=CLOJURE, + is_build_tree=_is_build_tree, + standalone=standalone_package, +) BABASHKA = BuildSystem(name="Babashka", files=("bb.edn",), languages=CLOJURE) SHADOW_CLJS = BuildSystem( name="shadow-cljs", files=("shadow-cljs.edn",), languages=CLOJURE, is_build_tree=_is_build_tree diff --git a/project_validator/ecosystems/dart.py b/project_validator/ecosystems/dart.py index 4f825b15..c8b25f46 100644 --- a/project_validator/ecosystems/dart.py +++ b/project_validator/ecosystems/dart.py @@ -9,6 +9,7 @@ from pathlib import Path, PurePosixPath from project_validator import yaml_support +from project_validator.build_systems.model import standalone_package from project_validator.core import Project from project_validator.ecosystems.model import BuildSystem, Ecosystem, subcommands, toolchain_patterns from project_validator.facts import Command, Facts, resolved @@ -55,7 +56,12 @@ def _build_beside_pubspec(directory: Path) -> bool: PUB = BuildSystem( - name="pub", files=(PUBSPEC,), languages=DART, members=_workspace_members, is_build_tree=_build_beside_pubspec + name="pub", + files=(PUBSPEC,), + languages=DART, + members=_workspace_members, + is_build_tree=_build_beside_pubspec, + standalone=standalone_package, ) diff --git a/project_validator/ecosystems/fortran.py b/project_validator/ecosystems/fortran.py index 8717439a..32acf334 100644 --- a/project_validator/ecosystems/fortran.py +++ b/project_validator/ecosystems/fortran.py @@ -14,6 +14,7 @@ from project_validator.build_configurations import build_type_kinds from project_validator.build_systems.cmake.build import CMAKE from project_validator.build_systems.meson.build import MESON +from project_validator.build_systems.model import standalone_package from project_validator.core import Context from project_validator.ecosystems.model import BuildSystem, Ecosystem from project_validator.facts import Command, Fact, Facts, Origin, Setting, resolved @@ -63,6 +64,7 @@ def fpm_build_types(command: Command) -> frozenset[str]: files=(FPM_MANIFEST,), languages=FORTRAN_LANGUAGE, build_types=fpm_build_types, + standalone=standalone_package, ) FPM_SETTINGS = SettingsReader( name="fpm", files=(FPM_MANIFEST,), read=lambda path, text: toml_settings("fpm", path, text) diff --git a/project_validator/ecosystems/go.py b/project_validator/ecosystems/go.py index 1d9780c4..b54af09f 100644 --- a/project_validator/ecosystems/go.py +++ b/project_validator/ecosystems/go.py @@ -5,6 +5,7 @@ import re from collections.abc import Callable, Iterator, Mapping +from project_validator.build_systems.model import standalone_package from project_validator.core import Context from project_validator.ecosystems.model import BuildSystem, Ecosystem, subcommands, toolchain_patterns from project_validator.facts import Command, Fact, Facts, Origin, Setting, resolved @@ -55,6 +56,7 @@ def _go_work_members(text: str) -> tuple[str, ...]: files=("go.mod", "go.sum", "go.work", "go.work.sum"), languages=GO_LANGUAGE, members=_go_work_members, + standalone=standalone_package, ) GOLANGCI_CONFIG_FILES = (".golangci.yml", ".golangci.yaml", ".golangci.toml", ".golangci.json") diff --git a/project_validator/ecosystems/haskell/__init__.py b/project_validator/ecosystems/haskell/__init__.py index 1f494ac4..6dab33c7 100644 --- a/project_validator/ecosystems/haskell/__init__.py +++ b/project_validator/ecosystems/haskell/__init__.py @@ -13,6 +13,7 @@ from pathlib import Path, PurePosixPath from project_validator import yaml_support +from project_validator.build_systems.model import standalone_package from project_validator.ecosystems.haskell.cabal import CabalSyntaxError, parse, top_level from project_validator.ecosystems.haskell.options import HASKELL_LANGUAGE from project_validator.ecosystems.model import BuildSystem, Ecosystem, subcommands, toolchain_patterns @@ -70,6 +71,7 @@ def _hpack_languages(text: str) -> frozenset[str]: languages=HASKELL_LANGUAGE, is_build_tree=_is_build_tree, members=_members, + standalone=standalone_package, ) STACK = BuildSystem(name="Stack", files=("stack.yaml",), languages=HASKELL_LANGUAGE, members=_members) HPACK = BuildSystem( diff --git a/project_validator/ecosystems/javascript/__init__.py b/project_validator/ecosystems/javascript/__init__.py index d0ac2baf..30af7408 100644 --- a/project_validator/ecosystems/javascript/__init__.py +++ b/project_validator/ecosystems/javascript/__init__.py @@ -65,30 +65,43 @@ ENTRY_POINTS = ("main", "module", "exports", "bin") -def _declared_by_package(_path: str, text: str) -> frozenset[str]: - """package.json is everywhere, as the tooling of projects in other languages; only a package's entry points (or - JavaScript sources, recognised by their suffixes) make a project a JavaScript one.""" +def _manifest(text: str) -> dict[str, object]: + """A package.json's fields; none when it is not a JSON object.""" try: manifest = json.loads(text) except json.JSONDecodeError: - return frozenset() - is_package = isinstance(manifest, dict) and any(key in manifest for key in ENTRY_POINTS) + return {} + return manifest if isinstance(manifest, dict) else {} + + +def _declared_by_package(_path: str, text: str) -> frozenset[str]: + """package.json is everywhere, as the tooling of projects in other languages; only a package's entry points (or + JavaScript sources, recognised by their suffixes) make a project a JavaScript one.""" + is_package = any(key in _manifest(text) for key in ENTRY_POINTS) return frozenset({JAVASCRIPT}) if is_package else frozenset() +def _named_package(text: str) -> bool: + """Whether a package.json below another is a package of its own: one with a name, not one that only marks its + directory's modules (`{"type": "module"}` in `dist/`).""" + return "name" in _manifest(text) + + def _workspaces(text: str) -> tuple[str, ...]: """The workspaces a package.json declares (npm, yarn and bun: `workspaces`, as a list or under `packages`).""" - try: - manifest = json.loads(text) - except json.JSONDecodeError: - return () - found = manifest.get("workspaces") if isinstance(manifest, dict) else None + found = _manifest(text).get("workspaces") if isinstance(found, dict): found = found.get("packages") return tuple(str(member) for member in found) if isinstance(found, list) else () -NPM = BuildSystem(name="npm", files=(PACKAGE_JSON,), declared_languages=_declared_by_package, members=_workspaces) +NPM = BuildSystem( + name="npm", + files=(PACKAGE_JSON,), + declared_languages=_declared_by_package, + members=_workspaces, + standalone=_named_package, +) DENO = BuildSystem(name="Deno", files=DENO_CONFIG_FILES, languages=frozenset({TYPESCRIPT})) diff --git a/project_validator/ecosystems/php/__init__.py b/project_validator/ecosystems/php/__init__.py index cc3f06a4..a84214f8 100644 --- a/project_validator/ecosystems/php/__init__.py +++ b/project_validator/ecosystems/php/__init__.py @@ -9,6 +9,7 @@ import re from collections.abc import Callable +from project_validator.build_systems.model import standalone_package from project_validator.ecosystems.model import BuildSystem, Ecosystem, subcommands, toolchain_patterns from project_validator.facts import Command, Facts, Setting, resolved from project_validator.facts.analysis import Strictness, analysed, analyzer, type_checked, type_checker @@ -28,7 +29,7 @@ COMPOSER_JSON = "composer.json" -COMPOSER = BuildSystem(name="Composer", files=(COMPOSER_JSON,), languages=PHP_ONLY) +COMPOSER = BuildSystem(name="Composer", files=(COMPOSER_JSON,), languages=PHP_ONLY, standalone=standalone_package) PHPUNIT_CONFIG_FILES = ("phpunit.xml", "phpunit.xml.dist", "phpunit.dist.xml") diff --git a/project_validator/ecosystems/python/__init__.py b/project_validator/ecosystems/python/__init__.py index 7b6b830a..34cf0635 100644 --- a/project_validator/ecosystems/python/__init__.py +++ b/project_validator/ecosystems/python/__init__.py @@ -9,6 +9,7 @@ from pathlib import PurePosixPath from project_validator import yaml_support +from project_validator.build_systems.model import standalone_package from project_validator.core import Context from project_validator.ecosystems.model import BuildSystem, Ecosystem, toml_members, toolchain_patterns from project_validator.facts import Command, Fact, Facts, Origin, Setting, resolved @@ -37,6 +38,7 @@ files=("pyproject.toml", "setup.py"), languages=PYTHON_ONLY, members=toml_members("tool", "uv", "workspace"), + standalone=standalone_package, ) diff --git a/project_validator/ecosystems/ruby/__init__.py b/project_validator/ecosystems/ruby/__init__.py index aeb22f47..b5a24981 100644 --- a/project_validator/ecosystems/ruby/__init__.py +++ b/project_validator/ecosystems/ruby/__init__.py @@ -8,6 +8,7 @@ import re +from project_validator.build_systems.model import standalone_package from project_validator.ecosystems.model import VERSION, BuildSystem, Ecosystem, subcommands, toolchain_patterns from project_validator.facts.axes import versions_axis from project_validator.facts.dependencies import Lock, PackageManager, lockfile_reader, manifest_reader @@ -23,7 +24,7 @@ GEMFILE = "Gemfile" -BUNDLER = BuildSystem(name="Bundler", files=(GEMFILE, "*.gemspec"), languages=RUBY_ONLY) +BUNDLER = BuildSystem(name="Bundler", files=(GEMFILE, "*.gemspec"), languages=RUBY_ONLY, standalone=standalone_package) RUNS_RAKE = re.compile(r"(? tuple[str, ...]: return ("cargo", *words) +def _cargo_package(text: str) -> bool: + """Whether a Cargo.toml below another is a project of its own: a package, or a workspace (not a manifest that + only sets a virtual workspace's members' shared settings).""" + return bool(re.search(r"^\[(package|workspace)\]", text, re.MULTILINE)) + + CARGO = BuildSystem( name="Cargo", files=("Cargo.toml",), @@ -93,6 +99,7 @@ def cargo_argv(argv: tuple[str, ...]) -> tuple[str, ...]: build_types=cargo_build_types, configured_build_types=cargo_profile_build_types, members=toml_members("workspace"), + standalone=_cargo_package, ) diff --git a/project_validator/ecosystems/sql.py b/project_validator/ecosystems/sql.py index 1352b8ed..a02420d6 100644 --- a/project_validator/ecosystems/sql.py +++ b/project_validator/ecosystems/sql.py @@ -19,6 +19,7 @@ from collections.abc import Iterator, Mapping from project_validator import yaml_support +from project_validator.build_systems.model import standalone_package from project_validator.core import Project from project_validator.ecosystems.model import BuildSystem, Ecosystem, subcommands from project_validator.facts import Fact, Origin @@ -40,7 +41,7 @@ # --- dbt DBT_PROJECT = "dbt_project.yml" -DBT = BuildSystem(name="dbt", files=(DBT_PROJECT,), languages=SQL_LANGUAGE) +DBT = BuildSystem(name="dbt", files=(DBT_PROJECT,), languages=SQL_LANGUAGE, standalone=standalone_package) def _dbt_output(name: str, what: str) -> BuildOutput: diff --git a/project_validator/ecosystems/swift.py b/project_validator/ecosystems/swift.py index 7ef3cbd0..852508a3 100644 --- a/project_validator/ecosystems/swift.py +++ b/project_validator/ecosystems/swift.py @@ -10,6 +10,7 @@ from pathlib import PurePosixPath from project_validator.build_configurations import build_type_kinds +from project_validator.build_systems.model import standalone_package from project_validator.ecosystems.model import BuildSystem, Ecosystem, subcommands, toolchain_patterns from project_validator.facts import Command, Fact, Facts, Setting, Unknown, resolved from project_validator.facts.analysis import analysed, analyzer @@ -65,6 +66,7 @@ def xcode_build_types(command: Command) -> frozenset[str]: files=(PACKAGE_SWIFT,), languages=SWIFT_ONLY, build_types=swiftpm_build_types, + standalone=standalone_package, ) SWIFTPM_BUILD_DIRECTORY = BuildOutput( name="the .build directory", diff --git a/project_validator/ecosystems/zig.py b/project_validator/ecosystems/zig.py index 092238cf..9622a47c 100644 --- a/project_validator/ecosystems/zig.py +++ b/project_validator/ecosystems/zig.py @@ -10,6 +10,7 @@ from pathlib import Path from project_validator.build_configurations import build_type_kinds +from project_validator.build_systems.model import standalone_package from project_validator.ecosystems.model import BuildSystem, Ecosystem, subcommands, toolchain_patterns from project_validator.facts import Command, Facts, Origin, Setting, resolved from project_validator.facts.arguments import option_values, starts_with @@ -57,6 +58,7 @@ def _is_build_tree(directory: Path) -> bool: languages=ZIG, is_build_tree=_is_build_tree, build_types=zig_build_types, + standalone=standalone_package, ) diff --git a/project_validator/facts/roles.py b/project_validator/facts/roles.py index 413709ad..3d5a3adc 100644 --- a/project_validator/facts/roles.py +++ b/project_validator/facts/roles.py @@ -64,6 +64,15 @@ _TESTS_BELOW_SOURCE_ROOTS = frozenset({"test", "tests", "testdata", "test-data", "test_data", "__tests__", "fixtures"}) +# Directories of a test suite's data: the projects in them are inputs to the tests, not projects of the repository. +_FIXTURE_DIRECTORIES = frozenset({"fixtures", "testdata", "test-data", "test_data", "inputs"}) + + +def fixture_data(path: str) -> bool: + """Whether `path` is below a directory of test data (`tests/fixtures/`, `pkg/x/testdata/`).""" + return any(part.lower() in _FIXTURE_DIRECTORIES for part in PurePosixPath(path).parts) + + def _named_role(part: str) -> str | None: """The role a directory's name tells (`tests`, `integration-tests`, `tests-build`, `examples`, `foo_bench`), if any.""" @@ -103,4 +112,4 @@ def role(path: str, *, directory: bool = False) -> str: return "product" -__all__ = ["AUXILIARY", "VENDOR_DIRECTORIES", "role"] +__all__ = ["AUXILIARY", "VENDOR_DIRECTORIES", "fixture_data", "role"] diff --git a/project_validator/facts/structure.py b/project_validator/facts/structure.py index 1ded57af..4b54efbe 100644 --- a/project_validator/facts/structure.py +++ b/project_validator/facts/structure.py @@ -16,7 +16,7 @@ from project_validator.ecosystems import Ecosystem, Kind, build_systems, families, formats, registered from project_validator.facts import Fact, Facts, Origin from project_validator.facts.auxiliary import AuxiliaryCode, Selectors -from project_validator.facts.roles import AUXILIARY, role +from project_validator.facts.roles import AUXILIARY, fixture_data, role from project_validator.facts.tools import owner, within # Suffixes of files that are not source code of any language: documents, styles, media, archives, binaries and plain @@ -430,9 +430,20 @@ def _members(project: Project, build: BuildFile) -> list[str]: return [pattern.removeprefix("./") for pattern in patterns] +def _standalone(project: Project, builds: list[BuildFile]) -> set[str]: + """The directories of `builds` (of one build system) whose build file is a project of its own wherever it is (a + nested Package.swift: see `BuildSystem.standalone`), but for test suites' data (`tests/fixtures/`).""" + system = next((found for found in build_systems() if found.name == builds[0].build_system), None) + if system is None or system.standalone is None: + return set() + files = (build for build in builds if not build.origin.path.endswith("/") and not fixture_data(build.origin.path)) + return {_directory(build) for build in files if system.standalone(project.read_text(build.origin.path))} + + def _unit_roots(project: Project, builds: tuple[BuildFile, ...]) -> tuple[dict[str, list[str]], set[str]]: - """Unit directory -> its build systems (each build system's outermost directories, and workspace members), and - the directories of the build files that declare a workspace.""" + """Unit directory -> its build systems (each build system's outermost directories, workspace members, and the + projects of their own below them: upstream #188), and the directories of the build files that declare a + workspace.""" roots: dict[str, list[str]] = {} workspaces: set[str] = set() for system in dict.fromkeys(build.build_system for build in builds): @@ -443,10 +454,11 @@ def _unit_roots(project: Project, builds: tuple[BuildFile, ...]) -> tuple[dict[s if declared := _members(project, build): workspaces.add(_directory(build)) members += declared + standalone = _standalone(project, own) for directory in sorted(directories): declared_member = any(fnmatchcase(directory, pattern) for pattern in members) outer = not any(other != directory and within(directory, other) for other in directories) - if declared_member or outer: + if declared_member or outer or directory in standalone: roots.setdefault(directory, []).append(system) return roots, workspaces diff --git a/project_validator/judging.py b/project_validator/judging.py index 6d64ccc6..d8e77a7b 100644 --- a/project_validator/judging.py +++ b/project_validator/judging.py @@ -121,6 +121,22 @@ def check_each_ecosystem[Rules]( return by_ecosystem(_companions(results, context.facts)) +# The gates of the product alone, which auxiliary code (tests, examples, scripts) is not asked for: the score does +# not count them for it, and an answer about a unit the map names auxiliary is not judged for them. +NOT_FOR_AUXILIARY = frozenset( + { + "coverage", + "fuzz-testing", + "mutation-testing", + "sanitizers", + "hardening", + "dependency-audit", + "platform-matrix", + "ci-build-types", + "security-scanning", + } +) + type _Place = tuple[str, str] # (language, unit) type _Auxiliary = Mapping[_Place, tuple[str, ...]] # what named the auxiliary code a place's answer is about type _Found[A] = list[tuple[A, tuple[str, ...]]] # each answer with what named its code (nothing: the product's) @@ -147,7 +163,7 @@ def _advisory(result: Result, language: str, named: tuple[str, ...]) -> Result: _AUXILIARY_UNIT = "a warning, not a failure: {unit} is {role} code, not the product's" -def _auxiliary_roles(facts: Facts) -> dict[str, str]: +def auxiliary_unit_roles(facts: Facts) -> dict[str, str]: """The units the map names test, benchmark, example, docs or tooling code, with that role, when the project has a product unit with code of its own (a project of benchmarks alone is judged as it is).""" units = facts.of(Unit) @@ -191,7 +207,7 @@ def judged[A: UnitAnswer]( found = _found(languages, context, answers) auxiliary: _Auxiliary = {(answer.language, answer.unit): named for answer, named in found if named} results: dict[_Place, Result] = {} - roles = _auxiliary_roles(context.facts) + roles = auxiliary_unit_roles(context.facts) for answer, named in found: result = _advised(judge(answer, allow_unknown=context.options.allow_unknown), answer) if (role := roles.get(answer.unit)) and not named: @@ -237,6 +253,22 @@ def _placed[A: UnitAnswer]( ) +def _asked[A: UnitAnswer]( + name: str, answers: Callable[[str, Facts], LanguageAnswers[A]], auxiliary_unit: Callable[[A], bool] | None +) -> Callable[[str, Facts], LanguageAnswers[A]]: + """`answers`, but for those about units the map names auxiliary that the check does not ask (see + `answered_check`), beside a product unit.""" + if auxiliary_unit is None and name not in NOT_FOR_AUXILIARY: + return answers + keep = auxiliary_unit or (lambda _answer: False) + + def asked(language: str, facts: Facts) -> LanguageAnswers[A]: + found, roles = answers(language, facts), auxiliary_unit_roles(facts) + return replace(found, units=tuple(answer for answer in found.units if answer.unit not in roles or keep(answer))) + + return asked + + def answered_check[A: UnitAnswer]( *, name: str, @@ -246,24 +278,36 @@ def answered_check[A: UnitAnswer]( aspect: str | None = None, languages: Callable[[], frozenset[str]] | None = None, aliases: tuple[str, ...] = (), + auxiliary_unit: Callable[[A], bool] | None = None, ) -> Check: """A check that judges a question's answers by a policy, for each ecosystem the project uses (its findings labelled by ecosystem as other checks' are). It applies to the languages its known tools handle (`aspect`), or to - `languages`.""" + `languages`. An answer about a unit the map names auxiliary (a cargo-fuzz crate, a benchmark package) is judged + when `auxiliary_unit` says so; by default unless the check is a gate of the product alone (`NOT_FOR_AUXILIARY`).""" if languages is None: if aspect is None: raise TypeError("answered_check needs an aspect or languages") languages = handling(aspect) handled = component_cache(languages) + asked = _asked(name, answers, auxiliary_unit) def run(context: Context) -> Result: now = handled() by_ecosystem_ = {e: e.languages & now for e in registered() if e.languages & now} return check_each_ecosystem( - context, by_ecosystem_, lambda judged_languages, found: judged(judged_languages, found, answers, judge) + context, by_ecosystem_, lambda judged_languages, found: judged(judged_languages, found, asked, judge) ) return Check(name=name, description=description, run=run, languages_from=handled, aspect=aspect, aliases=aliases) -__all__ = ["answered_check", "by_ecosystem", "check_each_ecosystem", "combined", "judged", "labelled"] +__all__ = [ + "NOT_FOR_AUXILIARY", + "answered_check", + "auxiliary_unit_roles", + "by_ecosystem", + "check_each_ecosystem", + "combined", + "judged", + "labelled", +] diff --git a/project_validator/score.py b/project_validator/score.py index 534966d3..68d5f3fc 100644 --- a/project_validator/score.py +++ b/project_validator/score.py @@ -26,6 +26,7 @@ from dataclasses import dataclass, field from project_validator.core import Result, Status +from project_validator.judging import NOT_FOR_AUXILIARY from project_validator.runner import Report SCORE_VERSION = "1" @@ -49,20 +50,6 @@ # Reported, never scored: what a README shows is not a quality gate. UNSCORED = frozenset({"status-badges"}) -# The gates of the product alone, which auxiliary code (tests, examples, scripts) is not asked for. -NOT_FOR_AUXILIARY = frozenset( - { - "coverage", - "fuzz-testing", - "mutation-testing", - "sanitizers", - "hardening", - "dependency-audit", - "platform-matrix", - "ci-build-types", - "security-scanning", - } -) # The gates where each more tool finds more: two analysers are stronger than one; two formatters are not. EXTRA_CREDIT = frozenset( { diff --git a/tests/checks/test_dependency_management.py b/tests/checks/test_dependency_management.py index 78c9a984..2f0d0544 100644 --- a/tests/checks/test_dependency_management.py +++ b/tests/checks/test_dependency_management.py @@ -56,7 +56,11 @@ def test_the_fixtures(self) -> None: cases = { "well_configured_cpp": _declared("cmake/Dependencies.cmake", "FetchContent"), "well_configured_python": _declared("pyproject.toml", "Python packages", "uv.lock"), - "well_configured_rust": _declared("fuzz/Cargo.toml", "Cargo", "fuzz/Cargo.lock"), + # The fuzz crate is a unit of its own (upstream #188): the product declares no dependencies. + "well_configured_rust": Result.passed( + "the root: no dependencies are declared; fuzz: dependencies are declared in fuzz/Cargo.toml (Cargo) " + "and locked in fuzz/Cargo.lock" + ), "well_configured_go": NO_DEPENDENCIES, } for fixture, expected in cases.items(): diff --git a/tests/snapshots/well_configured_rust.facts.json b/tests/snapshots/well_configured_rust.facts.json index 71e3f169..adcdc358 100644 --- a/tests/snapshots/well_configured_rust.facts.json +++ b/tests/snapshots/well_configured_rust.facts.json @@ -107,6 +107,20 @@ "origin": ".", "role": "product" }, + { + "build_systems": [ + "Cargo" + ], + "formats": [ + "TOML" + ], + "kind": "Unit", + "languages": [ + "Rust" + ], + "origin": "fuzz", + "role": "test" + }, { "column": null, "format": "YAML", @@ -7196,6 +7210,19 @@ "Rust" ], "role": "product" + }, + { + "build_systems": [ + "Cargo" + ], + "directory": "fuzz", + "formats": [ + "TOML" + ], + "languages": [ + "Rust" + ], + "role": "test" } ], "unrecognised_suffixes": [] diff --git a/tests/snapshots/well_configured_rust.json b/tests/snapshots/well_configured_rust.json index cbad2f4f..33abfa27 100644 --- a/tests/snapshots/well_configured_rust.json +++ b/tests/snapshots/well_configured_rust.json @@ -220,6 +220,80 @@ }, "unit": ".", "unknowns": [] + }, + { + "branch": { + "answer": "yes", + "gated": [], + "known": [ + "cargo llvm-cov --branch", + "cargo tarpaulin --branch", + "grcov --branch" + ], + "reported": [ + "cargo-llvm-cov" + ], + "rung": "reported", + "tools": [ + "cargo-llvm-cov" + ] + }, + "language": "Rust", + "line": { + "answer": "yes", + "gated": [], + "known": [ + "cargo llvm-cov", + "cargo tarpaulin", + "grcov" + ], + "reported": [ + "cargo-llvm-cov" + ], + "rung": "reported", + "tools": [ + "cargo-llvm-cov" + ] + }, + "path": { + "answer": "yes", + "gated": [], + "known": [ + "cargo llvm-cov --mcdc", + "RUSTFLAGS=-Zcoverage-options=mcdc" + ], + "reported": [ + "cargo-llvm-cov" + ], + "rung": "reported", + "tools": [ + "cargo-llvm-cov" + ] + }, + "region": { + "answer": "yes", + "gated": [], + "known": [ + "cargo llvm-cov" + ], + "reported": [ + "cargo-llvm-cov" + ], + "rung": "reported", + "tools": [ + "cargo-llvm-cov" + ] + }, + "statement": { + "answer": "impossible", + "gated": [], + "known": [], + "reported": [], + "rung": null, + "tools": [] + }, + "unit": "fuzz", + "unknowns": [] } ] } @@ -290,6 +364,68 @@ "unit": ".", "unknown_definitions": [], "unknowns": [] + }, + { + "advisory": {}, + "answer": "yes", + "defined": {}, + "known": { + "GitLab Dependency Scanning": { + "can": { + "runs": "GitLab Dependency Scanning (Security/Dependency-Scanning.gitlab-ci.yml)" + }, + "needs_definition": false, + "required": false + }, + "cargo audit": { + "can": { + "runs": "cargo audit" + }, + "needs_definition": false, + "required": false + }, + "cargo deny": { + "can": { + "runs": "cargo deny check advisories" + }, + "needs_definition": false, + "required": false + }, + "osv-scanner": { + "can": { + "runs": "osv-scanner" + }, + "needs_definition": false, + "required": false + }, + "snyk": { + "can": { + "runs": "snyk test" + }, + "needs_definition": false, + "required": false + }, + "trivy": { + "can": { + "runs": "trivy fs" + }, + "needs_definition": false, + "required": false + } + }, + "language": "Rust", + "level": "runs", + "runs": { + "cargo audit": { + "levels": [ + "runs" + ], + "read": [] + } + }, + "unit": "fuzz", + "unknown_definitions": [], + "unknowns": [] } ] } @@ -299,6 +435,15 @@ "auxiliary": {}, "language": "Rust", "units": [ + { + "answer": "yes", + "declared": [], + "language": "Rust", + "lock_required": false, + "locked": [], + "unit": ".", + "unknowns": [] + }, { "answer": "yes", "declared": [ @@ -312,7 +457,7 @@ "locked": [ "fuzz/Cargo.lock" ], - "unit": ".", + "unit": "fuzz", "unknowns": [] } ] @@ -350,6 +495,34 @@ "unit": ".", "unknown_definitions": [], "unknowns": [] + }, + { + "advisory": {}, + "answer": "yes", + "defined": {}, + "known": { + "rustfmt": { + "can": { + "apply": "cargo fmt", + "check": "cargo fmt --check" + }, + "needs_definition": false, + "required": false + } + }, + "language": "Rust", + "level": "check", + "runs": { + "rustfmt": { + "levels": [ + "check" + ], + "read": [] + } + }, + "unit": "fuzz", + "unknown_definitions": [], + "unknowns": [] } ] } @@ -386,6 +559,34 @@ "unit": ".", "unknown_definitions": [], "unknowns": [] + }, + { + "advisory": {}, + "answer": "yes", + "defined": {}, + "known": { + "lizard": { + "can": { + "limits": "lizard --length 30" + }, + "needs_definition": false, + "required": false + } + }, + "language": "Rust", + "level": "limits", + "runs": { + "lizard": { + "levels": [ + "limits", + "measures" + ], + "read": [] + } + }, + "unit": "fuzz", + "unknown_definitions": [], + "unknowns": [] } ] } @@ -432,6 +633,44 @@ "unknowns": [] }, "unit": "." + }, + { + "answer": "yes", + "language": "Rust", + "other_runs": [], + "property_files": [], + "tools": { + "advisory": {}, + "answer": "yes", + "defined": { + "cargo-fuzz": [ + "fuzz/fuzz_targets/parse.rs" + ] + }, + "known": { + "cargo-fuzz": { + "can": { + "runs": "cargo fuzz run -- -max_total_time=60" + }, + "needs_definition": true, + "required": false + } + }, + "language": "Rust", + "level": "runs", + "runs": { + "cargo-fuzz": { + "levels": [ + "runs" + ], + "read": [] + } + }, + "unit": "fuzz", + "unknown_definitions": [], + "unknowns": [] + }, + "unit": "fuzz" } ] } @@ -497,6 +736,18 @@ "unit": ".", "unknown_definitions": [], "unknowns": [] + }, + { + "advisory": {}, + "answer": "impossible", + "defined": {}, + "known": {}, + "language": "Rust", + "level": "checked", + "runs": {}, + "unit": "fuzz", + "unknown_definitions": [], + "unknowns": [] } ] } @@ -517,6 +768,18 @@ "unit": ".", "unknown_definitions": [], "unknowns": [] + }, + { + "advisory": {}, + "answer": "impossible", + "defined": {}, + "known": {}, + "language": "Rust", + "level": "linted", + "runs": {}, + "unit": "fuzz", + "unknown_definitions": [], + "unknowns": [] } ] } @@ -558,6 +821,35 @@ "unit": ".", "unknown_definitions": [], "unknowns": [] + }, + { + "advisory": {}, + "answer": "yes", + "defined": {}, + "known": { + "cargo-mutants": { + "can": { + "incremental": "cargo mutants --in-diff ", + "runs": "cargo mutants" + }, + "needs_definition": false, + "required": false + } + }, + "language": "Rust", + "level": "runs", + "runs": { + "cargo-mutants": { + "levels": [ + "incremental", + "runs" + ], + "read": [] + } + }, + "unit": "fuzz", + "unknown_definitions": [], + "unknowns": [] } ] } @@ -690,6 +982,18 @@ "unit": ".", "unknown_definitions": [], "unknowns": [] + }, + { + "advisory": {}, + "answer": "impossible", + "defined": {}, + "known": {}, + "language": "Rust", + "level": "breaking", + "runs": {}, + "unit": "fuzz", + "unknown_definitions": [], + "unknowns": [] } ] } @@ -711,6 +1015,18 @@ "unit": ".", "unknown_definitions": [], "unknowns": [] + }, + { + "advisory": {}, + "answer": "impossible", + "defined": {}, + "known": {}, + "language": "Rust", + "level": "checked", + "runs": {}, + "unit": "fuzz", + "unknown_definitions": [], + "unknowns": [] } ] } @@ -731,6 +1047,18 @@ "unit": ".", "unknown_definitions": [], "unknowns": [] + }, + { + "advisory": {}, + "answer": "impossible", + "defined": {}, + "known": {}, + "language": "Rust", + "level": "validates", + "runs": {}, + "unit": "fuzz", + "unknown_definitions": [], + "unknowns": [] } ] } @@ -812,6 +1140,62 @@ "unit": ".", "unknown_definitions": [], "unknowns": [] + }, + { + "advisory": {}, + "answer": "yes", + "defined": {}, + "known": { + "CodeQL": { + "can": { + "scans": "CodeQL (github/codeql-action)" + }, + "needs_definition": false, + "required": false + }, + "GitLab SAST": { + "can": { + "scans": "GitLab SAST (Security/SAST.gitlab-ci.yml)" + }, + "needs_definition": false, + "required": false + }, + "semgrep": { + "can": { + "scans": "semgrep ci" + }, + "needs_definition": false, + "required": false + }, + "unsafe_code forbidden": { + "can": { + "scans": "unsafe_code = \"forbid\" in [lints.rust]" + }, + "needs_definition": false, + "required": false + } + }, + "language": "Rust", + "level": "scans", + "runs": { + "CodeQL": { + "levels": [ + "scans" + ], + "read": [] + }, + "unsafe_code forbidden": { + "levels": [ + "scans" + ], + "read": [ + "Cargo.toml" + ] + } + }, + "unit": "fuzz", + "unknown_definitions": [], + "unknowns": [] } ] } @@ -851,6 +1235,37 @@ "unit": ".", "unknown_definitions": [], "unknowns": [] + }, + { + "advisory": {}, + "answer": "yes", + "defined": { + "clippy": [ + "Cargo.toml" + ] + }, + "known": { + "clippy": { + "can": { + "checks": "cargo clippy" + }, + "needs_definition": false, + "required": false + } + }, + "language": "Rust", + "level": "checks", + "runs": { + "clippy": { + "levels": [ + "checks" + ], + "read": [] + } + }, + "unit": "fuzz", + "unknown_definitions": [], + "unknowns": [] } ] } @@ -890,6 +1305,33 @@ "unit": ".", "unknown_definitions": [], "unknowns": [] + }, + { + "advisory": {}, + "answer": "yes", + "defined": {}, + "known": { + "cargo test": { + "can": { + "runs": "cargo test" + }, + "needs_definition": true, + "required": false + } + }, + "language": "Rust", + "level": "runs", + "runs": { + "cargo test": { + "levels": [ + "runs" + ], + "read": [] + } + }, + "unit": "fuzz", + "unknown_definitions": [], + "unknowns": [] } ] } @@ -917,6 +1359,18 @@ "unit": ".", "unknown_definitions": [], "unknowns": [] + }, + { + "advisory": {}, + "answer": "impossible", + "defined": {}, + "known": {}, + "language": "Rust", + "level": "checks", + "runs": {}, + "unit": "fuzz", + "unknown_definitions": [], + "unknowns": [] } ] } @@ -977,11 +1431,21 @@ "Cargo.toml" ], "problems": [], + "test_data": [], + "test_problems": [], + "unit": ".", + "unread": {} + }, + { + "answer": "yes", + "language": "TOML", + "parsed": [], + "problems": [], "test_data": [ "fuzz/Cargo.toml" ], "test_problems": [], - "unit": ".", + "unit": "fuzz", "unread": {} } ] @@ -1082,7 +1546,7 @@ }, "data-wellformed": { "details": [], - "message": "TOML: 1 TOML file parses; YAML: 6 YAML files parse", + "message": "TOML in the root: 1 TOML file parses; TOML in fuzz: 1 TOML file of test data, not judged; YAML in the root: 6 YAML files parse", "status": "PASS" }, "dependency-audit": { @@ -1092,7 +1556,7 @@ }, "dependency-management": { "details": [], - "message": "dependencies are declared in fuzz/Cargo.toml (Cargo) and locked in fuzz/Cargo.lock", + "message": "the root: no dependencies are declared; fuzz: dependencies are declared in fuzz/Cargo.toml (Cargo) and locked in fuzz/Cargo.lock", "status": "PASS" }, "dependency-updates": { diff --git a/tests/test_leaderboard.py b/tests/test_leaderboard.py index fa78f81b..03a95a6b 100644 --- a/tests/test_leaderboard.py +++ b/tests/test_leaderboard.py @@ -259,7 +259,10 @@ def test_the_full_html_report_is_written_beside_the_result(self) -> None: def test_the_entry_s_auxiliary_and_exclude_reach_the_validator(self) -> None: with _directory() as root: shutil.copytree(FIXTURES / "well_configured_python", root / "p") - shutil.copytree(FIXTURES / "bare_cpp", root / "p" / "examples" / "c") + # Examples in the product's language: naming them auxiliary changes the score (a language only examples + # are written in is auxiliary already). + shutil.copytree(FIXTURES / "bare_python", root / "p" / "examples" / "py") + (root / "p" / "examples" / "py" / "broken.json").write_text("{\n") percents = {} for label, entry in ( ("plain", self.ENTRY), diff --git a/tests/test_units.py b/tests/test_units.py index e78c70ac..b5c2724b 100644 --- a/tests/test_units.py +++ b/tests/test_units.py @@ -74,8 +74,9 @@ def test_workspace_members_are_units_of_their_own(self) -> None: _units(cargo), [(".", ("Cargo",), []), ("crates/x", ("Cargo",), ["Rust"]), ("crates/y", ("Cargo",), ["Rust"])], ) + # A broken root declares no workspace; the named package below it is a package of its own all the same. broken = {"package.json": "{", **_package("a")} - self.assertEqual([unit for unit, _, _ in _units(broken)], ["."]) + self.assertEqual([unit for unit, _, _ in _units(broken)], [".", "packages/a"]) go = {"go.work": "go 1.23\n\nuse (\n\t./api\n\t./cli\n)\n", "api/go.mod": "", "api/a.go": "", "cli/go.mod": ""} self.assertEqual([unit for unit, _, _ in _units(go)], [".", "api", "cli"]) @@ -88,6 +89,53 @@ def test_yarn_workspaces_under_packages_and_vendored_projects(self) -> None: def test_a_mixed_language_project_has_a_unit_per_build_root(self) -> None: self.assertEqual(_units(MIXED), [(".", ("CMake",), ["C++"]), ("python", ("Python packaging",), ["Python"])]) + def test_a_nested_package_is_a_unit_with_the_role_its_directory_tells(self) -> None: + """A package below another of its build system's is a project of its own (upstream #188): vapor's + Benchmarks/Package.swift, phoenix's installer/ and integration_test/ Mix projects, dbt-utils' test project.""" + for files, expected in ( + ( + {"Package.swift": "", "Sources/a.swift": "", "Benchmarks/Package.swift": "", "Benchmarks/b.swift": ""}, + [(".", "product"), ("Benchmarks", "benchmark")], + ), + ( + {"mix.exs": "", "installer/mix.exs": "", "integration_test/mix.exs": ""}, + [(".", "product"), ("installer", "product"), ("integration_test", "test")], + ), + ( + {"dbt_project.yml": "name: utils\n", "integration_tests/dbt_project.yml": "name: utils_tests\n"}, + [(".", "product"), ("integration_tests", "test")], + ), + ): + with self.subTest(files=files), temp_project(files) as root: + units = make_context(root).facts.of(Unit) + self.assertEqual([(unit.directory, unit.role) for unit in units], expected) + + def test_an_auxiliary_unit_without_tests_of_its_own_is_not_asked_for_them(self) -> None: + """A cargo-fuzz crate or a benchmark package beside the product holds no tests, and need not (upstream #230); + one that has tests is judged for them.""" + files = { + "Cargo.toml": "[package]\nname = 'app'\n", + "src/lib.rs": "#[test]\nfn t() {}\n", + "fuzz/Cargo.toml": "[package]\nname = 'app-fuzz'\n", + "fuzz/fuzz_targets/a.rs": "", + **_workflow(("cargo test", None)), + } + result = _check("tests-run", files) + self.assertEqual((result.status, [place.unit for place in result.places]), (Status.PASS, ["."]), result) + files["fuzz/src/lib.rs"] = "#[test]\nfn t() {}\n" + self.assertEqual([place.unit for place in _check("tests-run", files).places], [".", "fuzz"]) + + def test_a_nested_build_file_that_is_no_project_of_its_own_is_its_parents(self) -> None: + """A CMake subdirectory, a package.json that only marks its directory's modules (`{"type": "module"}`), and a + test fixture's manifest belong to the unit above them.""" + for files in ( + {"CMakeLists.txt": "", "lib/CMakeLists.txt": "", "lib/a.cpp": ""}, + {"package.json": json.dumps({"name": "app"}), "dist/package.json": json.dumps({"type": "module"})}, + {"pyproject.toml": "[project]\nname = 'app'\n", "tests/fixtures/x/pyproject.toml": "[project]\n"}, + ): + with self.subTest(files=files): + self.assertEqual([unit for unit, _, _ in _units(files)], ["."]) + class MonorepoCoverageTests(unittest.TestCase): def test_each_unit_needs_coverage_and_findings_name_the_unit(self) -> None: From 51d964338644b8e6517b168bceab888a37e4e199 Mon Sep 17 00:00:00 2001 From: leftibot Date: Mon, 23 Nov 2026 22:33:42 -0700 Subject: [PATCH 4/8] Read pnpm-workspace.yaml as the workspace it declares: each member is a unit Part of #188. pnpm declares its workspace in pnpm-workspace.yaml, not package.json (graphql-eslint, graphql-inspector). The npm build system now reads it as it reads package.json's `workspaces`, so a member is a unit of its own whether or not its package.json has a name, with the role its directory tells (`examples/*`). The command-scoping reader of the same file now shares its parser. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt --- .../ecosystems/javascript/__init__.py | 29 +++++++++++++------ tests/test_units.py | 18 ++++++++++++ 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/project_validator/ecosystems/javascript/__init__.py b/project_validator/ecosystems/javascript/__init__.py index 30af7408..e61fcb93 100644 --- a/project_validator/ecosystems/javascript/__init__.py +++ b/project_validator/ecosystems/javascript/__init__.py @@ -60,6 +60,7 @@ JAVASCRIPT = "JavaScript" TYPESCRIPT = "TypeScript" PACKAGE_JSON = "package.json" +PNPM_WORKSPACE = "pnpm-workspace.yaml" DENO_CONFIG_FILES = ("deno.json", "deno.jsonc") # A package.json that names what it provides is a JavaScript package, even before any source is found. ENTRY_POINTS = ("main", "module", "exports", "bin") @@ -87,6 +88,21 @@ def _named_package(text: str) -> bool: return "name" in _manifest(text) +def _pnpm_packages(text: str) -> tuple[str, ...]: + """The packages a pnpm-workspace.yaml declares (`packages:`, globs; `!` before one leaves it out).""" + try: + declared = yaml_support.load(text) + except yaml_support.YamlError: + return () + packages = declared.get("packages") if isinstance(declared, dict) else None + return tuple(str(pattern) for pattern in packages) if isinstance(packages, list) else () + + +def _declared_workspace(text: str) -> tuple[str, ...]: + """The workspace members a package.json or a pnpm-workspace.yaml declares, each a unit of its own.""" + return _workspaces(text) or _pnpm_packages(text) + + def _workspaces(text: str) -> tuple[str, ...]: """The workspaces a package.json declares (npm, yarn and bun: `workspaces`, as a list or under `packages`).""" found = _manifest(text).get("workspaces") @@ -97,9 +113,9 @@ def _workspaces(text: str) -> tuple[str, ...]: NPM = BuildSystem( name="npm", - files=(PACKAGE_JSON,), + files=(PACKAGE_JSON, PNPM_WORKSPACE), declared_languages=_declared_by_package, - members=_workspaces, + members=_declared_workspace, standalone=_named_package, ) DENO = BuildSystem(name="Deno", files=DENO_CONFIG_FILES, languages=frozenset({TYPESCRIPT})) @@ -174,13 +190,8 @@ def workspace_members(context: Context, directory: str | None) -> list[str]: if context.project.exists(path := joined(directory, PACKAGE_JSON)) else [] ) - if context.project.exists(pnpm := joined(directory, "pnpm-workspace.yaml")): - try: - declared = yaml_support.load(context.project.read_text(pnpm)) - except yaml_support.YamlError: - declared = None - packages = declared.get("packages") if isinstance(declared, dict) else None - patterns += [str(pattern) for pattern in packages] if isinstance(packages, list) else [] + if context.project.exists(pnpm := joined(directory, PNPM_WORKSPACE)): + patterns += _pnpm_packages(context.project.read_text(pnpm)) globs = [ joined(directory, pattern.removeprefix("./").rstrip("/")) for pattern in patterns if not pattern.startswith("!") ] diff --git a/tests/test_units.py b/tests/test_units.py index b5c2724b..26425ca5 100644 --- a/tests/test_units.py +++ b/tests/test_units.py @@ -86,6 +86,24 @@ def test_yarn_workspaces_under_packages_and_vendored_projects(self) -> None: vendored = {"CMakeLists.txt": "", "main.c": "", "deps/lib/package.json": "{}", "deps/lib/x.js": ""} self.assertEqual([unit for unit, _, _ in _units(vendored)], ["."]) + def test_pnpm_workspace_members_are_units_of_their_own(self) -> None: + """pnpm declares its workspace in pnpm-workspace.yaml, not package.json (graphql-eslint, graphql-inspector: + upstream #188): each member is a unit, named or not, with the role its directory tells.""" + unnamed = {"packages/c/package.json": json.dumps({"private": True, "main": "x.js"}), "packages/c/x.js": ""} + files = { + "package.json": json.dumps({"private": True}), + "pnpm-workspace.yaml": "packages:\n - packages/*\n - examples/*\n - '!packages/skipped'\n", + **unnamed, + "examples/b/package.json": json.dumps({"private": True}), + "examples/b/index.js": "", + } + with temp_project(files) as root: + units = make_context(root).facts.of(Unit) + self.assertEqual( + [(unit.directory, unit.role) for unit in units], + [(".", "product"), ("examples/b", "example"), ("packages/c", "product")], + ) + def test_a_mixed_language_project_has_a_unit_per_build_root(self) -> None: self.assertEqual(_units(MIXED), [(".", ("CMake",), ["C++"]), ("python", ("Python packaging",), ["Python"])]) From 01f8a5329d786035387fd3ef98a40537ab1e9788 Mon Sep 17 00:00:00 2001 From: leftibot Date: Mon, 23 Nov 2026 22:39:46 -0700 Subject: [PATCH 5/8] Follow `yarn c8 yarn test` into the c8 binary it runs Part of #188. pnpm, yarn and bun run the binary of a name that is no script of the package: `yarn c8 yarn test` is `yarn exec c8 yarn test`. That command was dropped, so prettier's coverage job (`yarn c8 yarn test`) was never seen to run c8; its c8 credit came only from a nested tooling package's script, folded into the root until that package became a unit of its own. The command now launches the binary it names, and its own `yarn test` runs the package's test script. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt --- .../ecosystems/javascript/__init__.py | 20 +++++++++++++++++-- tests/test_javascript.py | 11 +++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/project_validator/ecosystems/javascript/__init__.py b/project_validator/ecosystems/javascript/__init__.py index e61fcb93..5b3da8b2 100644 --- a/project_validator/ecosystems/javascript/__init__.py +++ b/project_validator/ecosystems/javascript/__init__.py @@ -36,7 +36,15 @@ from project_validator.facts.coverage import Granularity, coverage_tool, measured, reported from project_validator.facts.dependencies import PackageManager, lockfile_reader, manifest_reader from project_validator.facts.exit_status import POSIX -from project_validator.facts.expansion import CommandExpander, Expansion, Script, found_at, joined, launcher +from project_validator.facts.expansion import ( + CommandExpander, + Expansion, + Launched, + Script, + found_at, + joined, + launcher, +) from project_validator.facts.formatting import Enforcement, flagged, format_tool from project_validator.facts.licenses import declared_license_reader from project_validator.facts.outputs import BuildOutput, directories, ignored_at_top_level @@ -227,7 +235,7 @@ def _package_scripts(command: Command, context: Context) -> Iterator[Expansion] scripts = _json_strings(json_value(context, path, "scripts")) if run.name not in scripts: if not run.explicit: - return None + return _binary(command, run) return iter((Unknown(origin=command.origin, subject=f"the script {run.name}", reason=f"{path} has none"),)) names = [f"{prefix}{run.name}" for prefix in (("pre", "", "post") if command.argv[0] in ("npm", "yarn") else ("",))] return ( @@ -238,6 +246,14 @@ def _package_scripts(command: Command, context: Context) -> Iterator[Expansion] ) +def _binary(command: Command, run: _ScriptRun) -> Iterator[Expansion] | None: + """`yarn c8 yarn test`, where the package has no script c8: the c8 binary it runs, as `yarn exec c8 yarn test` + does (prettier, upstream #188).""" + if run.name not in command.argv: + return None + return iter((Launched(argv=command.argv[command.argv.index(run.name) :]),)) + + PACKAGE_SCRIPTS = CommandExpander(name="package.json scripts", expand=_package_scripts) # Monorepo task runners, which run a script in each workspace package that has it. _TASK_RUNNERS = frozenset({"turbo", "lerna", "nx"}) diff --git a/tests/test_javascript.py b/tests/test_javascript.py index 6d1138ee..77da6eca 100644 --- a/tests/test_javascript.py +++ b/tests/test_javascript.py @@ -175,6 +175,14 @@ def test_c8_and_nyc_gate_on_the_thresholds_check_coverage_is_given(self) -> None lines = self._run(coverage, _ci("npx c8 --check-coverage node --test")) self.assertEqual(lines, Result.passed("branch coverage is reported with c8", _GATE_HINT)) + def test_a_package_manager_runs_the_binary_a_name_that_is_no_script_names(self) -> None: + """`yarn c8 yarn test` runs the c8 binary, as `yarn exec c8` does, when the package has no script c8 + (prettier, upstream #188); its own `yarn test` runs the package's test script.""" + files = {**_package(scripts={"test": "node --test"}), **_ci("yarn c8 yarn test")} + self.assertEqual(self._run(coverage, files), Result.passed("branch coverage is reported with c8", _GATE_HINT)) + script = {**_package(scripts={"c8": "echo nothing"}), **_ci("yarn c8")} + self.assertEqual(self._run(coverage, script).status, Status.FAIL) + def test_one_linter_is_enough(self) -> None: # oxlint is one too: vite was told "no JavaScript linters found" while static-analysis credited it (#248). for command, linter in ( @@ -409,9 +417,10 @@ def test_package_manager_commands_are_not_scripts(self) -> None: "pnpm install", "yarn add left-pad", "bun test", - "pnpm vitest", ) self.assertEqual(self._expanded(*commands), []) + # A name that is no script runs the binary of that name (upstream #188). + self.assertEqual(self._expanded("pnpm vitest"), [("vitest",)]) def test_a_script_that_does_not_exist_is_unknown(self) -> None: with temp_project({**PACKAGES, **github_job("ubuntu-latest", "npm run build", "deno task nope")}) as root: From 769895253c11c5ec0c68de1c0af2f21da7922061 Mon Sep 17 00:00:00 2001 From: leftibot Date: Mon, 23 Nov 2026 22:44:44 -0700 Subject: [PATCH 6/8] Ask template and auxiliary units for no lock file; vendor-bin/ is tooling Part of #188. Found in the corpus once nested packages became units: - A template unit (fluentd's templates/new_gem, the gem its plugin generator writes) is not the product's: it counts with the auxiliary units, so it is not asked for tests or the product's gates. - dependency-management is a gate of the product alone: a benchmark app or a test project that locks nothing (puma's benchmarks/local/sinatra, tokio's tests-integration) no longer warns. - `vendor-bin/` holds the tools bamarni/composer-bin-plugin installs (guzzle): tooling, not product units without tests. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt --- project_validator/facts/roles.py | 8 ++++++-- project_validator/judging.py | 9 +++++---- tests/checks/test_dependency_management.py | 7 ++----- tests/snapshots/well_configured_rust.json | 2 +- tests/test_settings.py | 2 ++ tests/test_units.py | 19 +++++++++++++++++++ 6 files changed, 35 insertions(+), 12 deletions(-) diff --git a/project_validator/facts/roles.py b/project_validator/facts/roles.py index 3d5a3adc..fa6c7e75 100644 --- a/project_validator/facts/roles.py +++ b/project_validator/facts/roles.py @@ -38,7 +38,8 @@ **dict.fromkeys(("example", "examples", "sample", "samples", "demo", "demos", "listings"), "example"), **dict.fromkeys(("doc", "docs", "documentation", "website"), "docs"), # `hack/` is the Kubernetes projects' name for maintainer scripts, `tool/` Dart's. - **dict.fromkeys(("tool", "tools", "tooling", "scripts", "hack"), "tooling"), + # `vendor-bin/` holds the tools bamarni/composer-bin-plugin installs, each a Composer project (guzzle). + **dict.fromkeys(("tool", "tools", "tooling", "scripts", "hack", "vendor-bin"), "tooling"), **dict.fromkeys(("bench", "benches", "benchmark", "benchmarks"), "benchmark"), # Files rendered before they are read (a Helm chart's manifests, Jinja pages, the projects a blueprint # generates): not well formed as they are. @@ -56,6 +57,9 @@ # The roles `--auxiliary` may name as not the product's (see `project_validator.facts.auxiliary`); vendored code is # never judged, named or not. AUXILIARY = frozenset({"test", "example", "docs", "tooling", "benchmark"}) +# The roles of units that are not the product's (see `project_validator.judging`): the auxiliary ones, and a +# template of a project (a generator's scaffold, fluentd's templates/new_gem). +AUXILIARY_UNITS = AUXILIARY | {"template"} # Directories that hold a unit's sources: below them, directory names are the code's own (`com/example/App.java`), @@ -112,4 +116,4 @@ def role(path: str, *, directory: bool = False) -> str: return "product" -__all__ = ["AUXILIARY", "VENDOR_DIRECTORIES", "fixture_data", "role"] +__all__ = ["AUXILIARY", "AUXILIARY_UNITS", "VENDOR_DIRECTORIES", "fixture_data", "role"] diff --git a/project_validator/judging.py b/project_validator/judging.py index d8e77a7b..00d4831c 100644 --- a/project_validator/judging.py +++ b/project_validator/judging.py @@ -15,7 +15,7 @@ from project_validator.ecosystems import Ecosystem, ecosystems_for, registered from project_validator.facts import Facts from project_validator.facts.auxiliary import as_given -from project_validator.facts.roles import AUXILIARY +from project_validator.facts.roles import AUXILIARY_UNITS from project_validator.facts.structure import SourceFile, Unit from project_validator.facts.tools import handling from project_validator.policy import Judge @@ -126,6 +126,7 @@ def check_each_ecosystem[Rules]( NOT_FOR_AUXILIARY = frozenset( { "coverage", + "dependency-management", "fuzz-testing", "mutation-testing", "sanitizers", @@ -164,12 +165,12 @@ def _advisory(result: Result, language: str, named: tuple[str, ...]) -> Result: def auxiliary_unit_roles(facts: Facts) -> dict[str, str]: - """The units the map names test, benchmark, example, docs or tooling code, with that role, when the project has - a product unit with code of its own (a project of benchmarks alone is judged as it is).""" + """The units the map names test, benchmark, example, docs or tooling code, or a template, with that role, when the + project has a product unit with code of its own (a project of benchmarks alone is judged as it is).""" units = facts.of(Unit) if not any(unit.role == "product" and (unit.languages or unit.formats) for unit in units): return {} - return {unit.directory: unit.role for unit in units if unit.role in AUXILIARY} + return {unit.directory: unit.role for unit in units if unit.role in AUXILIARY_UNITS} def _advised(result: Result, answer: object) -> Result: diff --git a/tests/checks/test_dependency_management.py b/tests/checks/test_dependency_management.py index 2f0d0544..915bf12d 100644 --- a/tests/checks/test_dependency_management.py +++ b/tests/checks/test_dependency_management.py @@ -56,11 +56,8 @@ def test_the_fixtures(self) -> None: cases = { "well_configured_cpp": _declared("cmake/Dependencies.cmake", "FetchContent"), "well_configured_python": _declared("pyproject.toml", "Python packages", "uv.lock"), - # The fuzz crate is a unit of its own (upstream #188): the product declares no dependencies. - "well_configured_rust": Result.passed( - "the root: no dependencies are declared; fuzz: dependencies are declared in fuzz/Cargo.toml (Cargo) " - "and locked in fuzz/Cargo.lock" - ), + # The fuzz crate is a unit of its own, not judged for the product's dependencies (upstream #188). + "well_configured_rust": NO_DEPENDENCIES, "well_configured_go": NO_DEPENDENCIES, } for fixture, expected in cases.items(): diff --git a/tests/snapshots/well_configured_rust.json b/tests/snapshots/well_configured_rust.json index 33abfa27..6906c541 100644 --- a/tests/snapshots/well_configured_rust.json +++ b/tests/snapshots/well_configured_rust.json @@ -1556,7 +1556,7 @@ }, "dependency-management": { "details": [], - "message": "the root: no dependencies are declared; fuzz: dependencies are declared in fuzz/Cargo.toml (Cargo) and locked in fuzz/Cargo.lock", + "message": "no dependencies are declared", "status": "PASS" }, "dependency-updates": { diff --git a/tests/test_settings.py b/tests/test_settings.py index 5f6c8eab..e42d6f82 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -251,6 +251,8 @@ def test_a_directory_named_for_what_it_holds_tells_its_role(self) -> None: ("clap_bench/benches/a.rs", "benchmark"), ("crates/ruff_benchmark/src/lib.rs", "benchmark"), ("koyo-lib/blueprints/standard/package.json", "template"), + # bamarni/composer-bin-plugin's tool installs (guzzle). + ("vendor-bin/phpstan/composer.json", "tooling"), ): with self.subTest(path=path): self.assertEqual(role(path), expected) diff --git a/tests/test_units.py b/tests/test_units.py index 26425ca5..1c56d621 100644 --- a/tests/test_units.py +++ b/tests/test_units.py @@ -143,6 +143,25 @@ def test_an_auxiliary_unit_without_tests_of_its_own_is_not_asked_for_them(self) files["fuzz/src/lib.rs"] = "#[test]\nfn t() {}\n" self.assertEqual([place.unit for place in _check("tests-run", files).places], [".", "fuzz"]) + def test_a_template_or_benchmark_unit_is_not_asked_for_the_products_gates(self) -> None: + """fluentd's templates/new_gem is the gem `fluentd plugin-generator` writes, and puma's benchmark apps lock no + dependencies (upstream #188): neither is asked for tests or a lock file beside the product.""" + files = { + "Gemfile": "source 'https://rubygems.org'\ngem 'rake'\n", + "Gemfile.lock": "GEM\n", + "lib/app.rb": "", + "spec/app_spec.rb": "describe 'app' do\nend\n", + "templates/new_gem/Gemfile": "gem 'rspec'\n", + "templates/new_gem/lib/x.rb": "", + "benchmarks/sinatra/Gemfile": "gem 'sinatra'\n", + "benchmarks/sinatra/app.rb": "", + **_workflow(("bundle exec rspec", None)), + } + for name in ("tests-run", "dependency-management"): + with self.subTest(name), temp_project(files) as root: + result = checks_named(name)[0].run(make_context(root)) + self.assertEqual([place.unit for place in result.places], ["."], result) + def test_a_nested_build_file_that_is_no_project_of_its_own_is_its_parents(self) -> None: """A CMake subdirectory, a package.json that only marks its directory's modules (`{"type": "module"}`), and a test fixture's manifest belong to the unit above them.""" From d7f752324c474deec51a0ceb8d2d072e8ad56d8d Mon Sep 17 00:00:00 2001 From: leftibot Date: Mon, 23 Nov 2026 22:55:46 -0700 Subject: [PATCH 7/8] Credit a test project's tests to the units it tests, not to every unit Part of #230. A unit of tests (a separate test project) counted, and its CI runs counted, for every unit of the project: tokio's tests-integration lent its 9 test files to benches/, examples/ and stress-test/, and hledger-web/test/browser's Playwright specs to the root package. A unit of tests now tests the units its build files depend on by path (Cargo's `path = "../tokio"`, package.json's `file:../x`: the new `BuildSystem.path_dependencies`) and the unit it is in, but for the root (`Unit.tests`); one that says neither still tests every unit (serde's test_suite, .NET's and OCaml's test projects). One predicate, `tests_unit`, now answers it for both the test files and the test runs. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt --- project_validator/build_systems/model.py | 3 ++ .../ecosystems/javascript/__init__.py | 9 +++++ project_validator/ecosystems/rust/__init__.py | 15 ++++++++ project_validator/facts/structure.py | 38 +++++++++++++++++++ project_validator/questions/__init__.py | 18 ++++----- project_validator/questions/tooling.py | 12 ++---- tests/regressions/test_detection.py | 37 +++++++++++++++++- tests/snapshots/bare_ansible.facts.json | 3 +- tests/snapshots/bare_beam.facts.json | 3 +- tests/snapshots/bare_c.facts.json | 3 +- tests/snapshots/bare_clojure.facts.json | 3 +- tests/snapshots/bare_common_lisp.facts.json | 3 +- tests/snapshots/bare_cpp.facts.json | 3 +- tests/snapshots/bare_dart.facts.json | 3 +- tests/snapshots/bare_data.facts.json | 3 +- tests/snapshots/bare_docker.facts.json | 3 +- tests/snapshots/bare_documentation.facts.json | 3 +- tests/snapshots/bare_dotnet.facts.json | 6 ++- tests/snapshots/bare_emacs_lisp.facts.json | 3 +- tests/snapshots/bare_fortran.facts.json | 3 +- tests/snapshots/bare_github_action.facts.json | 3 +- tests/snapshots/bare_go.facts.json | 3 +- tests/snapshots/bare_graphql.facts.json | 3 +- tests/snapshots/bare_haskell.facts.json | 3 +- tests/snapshots/bare_javascript.facts.json | 3 +- tests/snapshots/bare_json_schema.facts.json | 3 +- tests/snapshots/bare_julia.facts.json | 3 +- tests/snapshots/bare_jupyter.facts.json | 3 +- tests/snapshots/bare_jvm.facts.json | 3 +- tests/snapshots/bare_kubernetes.facts.json | 3 +- tests/snapshots/bare_latex.facts.json | 3 +- tests/snapshots/bare_lua.facts.json | 3 +- tests/snapshots/bare_nix.facts.json | 3 +- tests/snapshots/bare_ocaml.facts.json | 3 +- tests/snapshots/bare_openapi.facts.json | 3 +- tests/snapshots/bare_perl.facts.json | 3 +- tests/snapshots/bare_php.facts.json | 3 +- tests/snapshots/bare_protobuf.facts.json | 3 +- tests/snapshots/bare_python.facts.json | 3 +- tests/snapshots/bare_r.facts.json | 3 +- tests/snapshots/bare_racket.facts.json | 3 +- tests/snapshots/bare_ruby.facts.json | 3 +- tests/snapshots/bare_rust.facts.json | 3 +- tests/snapshots/bare_scala.facts.json | 3 +- tests/snapshots/bare_shell.facts.json | 3 +- tests/snapshots/bare_sql.facts.json | 3 +- tests/snapshots/bare_swift.facts.json | 3 +- tests/snapshots/bare_tabular_data.facts.json | 3 +- tests/snapshots/bare_terraform.facts.json | 3 +- tests/snapshots/bare_typescript.facts.json | 3 +- tests/snapshots/bare_typst.facts.json | 3 +- tests/snapshots/bare_xml_schemas.facts.json | 3 +- tests/snapshots/bare_zig.facts.json | 3 +- tests/snapshots/buildable.facts.json | 3 +- .../well_configured_ansible.facts.json | 3 +- .../snapshots/well_configured_beam.facts.json | 3 +- tests/snapshots/well_configured_c.facts.json | 3 +- .../well_configured_clojure.facts.json | 3 +- .../well_configured_common_lisp.facts.json | 3 +- .../snapshots/well_configured_cpp.facts.json | 3 +- .../snapshots/well_configured_dart.facts.json | 3 +- .../snapshots/well_configured_data.facts.json | 3 +- .../well_configured_docker.facts.json | 3 +- .../well_configured_documentation.facts.json | 3 +- .../well_configured_dotnet.facts.json | 3 +- .../well_configured_emacs_lisp.facts.json | 3 +- .../well_configured_fortran.facts.json | 3 +- .../well_configured_github_action.facts.json | 3 +- tests/snapshots/well_configured_go.facts.json | 3 +- .../well_configured_graphql.facts.json | 3 +- .../well_configured_haskell.facts.json | 3 +- .../well_configured_javascript.facts.json | 3 +- .../well_configured_json_schema.facts.json | 3 +- .../well_configured_julia.facts.json | 3 +- .../well_configured_jupyter.facts.json | 3 +- .../snapshots/well_configured_jvm.facts.json | 3 +- .../well_configured_kubernetes.facts.json | 3 +- .../well_configured_latex.facts.json | 3 +- .../snapshots/well_configured_lua.facts.json | 3 +- .../snapshots/well_configured_nix.facts.json | 3 +- .../well_configured_ocaml.facts.json | 3 +- .../well_configured_openapi.facts.json | 3 +- .../snapshots/well_configured_perl.facts.json | 3 +- .../snapshots/well_configured_php.facts.json | 3 +- .../well_configured_protobuf.facts.json | 3 +- .../well_configured_python.facts.json | 3 +- tests/snapshots/well_configured_r.facts.json | 3 +- .../well_configured_racket.facts.json | 3 +- .../snapshots/well_configured_ruby.facts.json | 3 +- .../snapshots/well_configured_rust.facts.json | 8 +++- .../well_configured_scala.facts.json | 3 +- .../well_configured_shell.facts.json | 3 +- .../snapshots/well_configured_sql.facts.json | 3 +- .../well_configured_swift.facts.json | 3 +- .../well_configured_tabular_data.facts.json | 3 +- .../well_configured_terraform.facts.json | 3 +- .../well_configured_typescript.facts.json | 3 +- .../well_configured_typst.facts.json | 3 +- .../well_configured_xml_schemas.facts.json | 3 +- .../snapshots/well_configured_zig.facts.json | 3 +- 100 files changed, 302 insertions(+), 117 deletions(-) diff --git a/project_validator/build_systems/model.py b/project_validator/build_systems/model.py index 09e29976..00d27b39 100644 --- a/project_validator/build_systems/model.py +++ b/project_validator/build_systems/model.py @@ -31,6 +31,8 @@ class BuildSystem: of its own (a nested Package.swift, a package.json with a name; see `standalone_package`), a unit of the project with the role its directory tells; None: a nested build file is part of the one above it (a CMake subdirectory, a Maven module). + `path_dependencies` reads, from a build file, the directories (relative to it) of the packages it depends on by + path (Cargo's `path = "../x"`): what a unit of tests tests (see `project_validator.facts.structure.Unit`). """ name: str @@ -45,6 +47,7 @@ class BuildSystem: members: Callable[[str], tuple[str, ...]] | None = None compiler_evidence: Callable[[tuple[str, ...]], tuple[str, ...]] | None = None standalone: Callable[[str], bool] | None = None + path_dependencies: Callable[[str], tuple[str, ...]] | None = None def standalone_package(_text: str) -> bool: diff --git a/project_validator/ecosystems/javascript/__init__.py b/project_validator/ecosystems/javascript/__init__.py index 5b3da8b2..3fc09dff 100644 --- a/project_validator/ecosystems/javascript/__init__.py +++ b/project_validator/ecosystems/javascript/__init__.py @@ -111,6 +111,14 @@ def _declared_workspace(text: str) -> tuple[str, ...]: return _workspaces(text) or _pnpm_packages(text) +def _path_dependencies(text: str) -> tuple[str, ...]: + """The directories of the packages a package.json depends on by path (`file:../x`, `link:../x`).""" + manifest = _manifest(text) + tables = (manifest.get(kind) for kind in ("dependencies", "devDependencies", "peerDependencies")) + specs = (spec for table in tables if isinstance(table, dict) for spec in table.values() if isinstance(spec, str)) + return tuple(dict.fromkeys(spec.partition(":")[2] for spec in specs if spec.startswith(("file:", "link:")))) + + def _workspaces(text: str) -> tuple[str, ...]: """The workspaces a package.json declares (npm, yarn and bun: `workspaces`, as a list or under `packages`).""" found = _manifest(text).get("workspaces") @@ -125,6 +133,7 @@ def _workspaces(text: str) -> tuple[str, ...]: declared_languages=_declared_by_package, members=_declared_workspace, standalone=_named_package, + path_dependencies=_path_dependencies, ) DENO = BuildSystem(name="Deno", files=DENO_CONFIG_FILES, languages=frozenset({TYPESCRIPT})) diff --git a/project_validator/ecosystems/rust/__init__.py b/project_validator/ecosystems/rust/__init__.py index d88cc64b..52f084b7 100644 --- a/project_validator/ecosystems/rust/__init__.py +++ b/project_validator/ecosystems/rust/__init__.py @@ -91,6 +91,20 @@ def _cargo_package(text: str) -> bool: return bool(re.search(r"^\[(package|workspace)\]", text, re.MULTILINE)) +def _path_dependencies(text: str) -> tuple[str, ...]: + """The directories of the crates a Cargo.toml depends on by path, in any of its dependency tables.""" + try: + manifest = tomllib.loads(text) + except tomllib.TOMLDecodeError: + return () + targets = manifest.get("target") + holders = [manifest, *(targets.values() if isinstance(targets, dict) else ())] + kinds = ("dependencies", "dev-dependencies", "build-dependencies") + tables = [holder.get(kind) for holder in holders if isinstance(holder, dict) for kind in kinds] + specs = (spec for table in tables if isinstance(table, dict) for spec in table.values() if isinstance(spec, dict)) + return tuple(dict.fromkeys(spec["path"] for spec in specs if isinstance(spec.get("path"), str))) + + CARGO = BuildSystem( name="Cargo", files=("Cargo.toml",), @@ -100,6 +114,7 @@ def _cargo_package(text: str) -> bool: configured_build_types=cargo_profile_build_types, members=toml_members("workspace"), standalone=_cargo_package, + path_dependencies=_path_dependencies, ) diff --git a/project_validator/facts/structure.py b/project_validator/facts/structure.py index 4b54efbe..fd8737a1 100644 --- a/project_validator/facts/structure.py +++ b/project_validator/facts/structure.py @@ -6,6 +6,7 @@ from __future__ import annotations +import posixpath from collections import Counter from collections.abc import Callable, Iterable, Iterator from dataclasses import dataclass, replace @@ -110,6 +111,9 @@ class Unit(Fact): formats: frozenset[str] = frozenset() # What the unit is for, by its directory (see `role`); a name, not a judgement. role: str = "product" + # For a unit of tests, the units it tests: those it depends on by path and the unit it is in (upstream #230); + # none: every unit (see `tests_unit`). + tests: tuple[str, ...] = () @property def directory(self) -> str: @@ -537,9 +541,42 @@ def _units(project: Project, facts: Facts, named: Selectors) -> Iterator[Unit]: build_systems=tuple(roots.get(directory, ())), languages=frozenset(languages[directory]), formats=frozenset(formats_.get(directory, ())), + tests=_tested(project, facts, directory, tuple(languages)) if purpose == "test" else (), ) +def _tested(project: Project, facts: Facts, directory: str, units: tuple[str, ...]) -> tuple[str, ...]: + """The units a unit of tests at `directory` tests: those its build files depend on by path, and the unit it is in + but for the root (hledger-web/test/browser tests hledger-web); none when neither is known (it tests every unit).""" + others = tuple(unit for unit in units if unit != directory) + found = [owner(path, others) for path in _path_dependencies(project, facts, directory)] + if directory != "." and (parent := owner(str(PurePosixPath(directory).parent), others)) != ".": + found.append(parent) + return tuple(dict.fromkeys(unit for unit in found if unit != directory)) + + +def _path_dependencies(project: Project, facts: Facts, directory: str) -> Iterator[str]: + """The project paths of the packages the build files at `directory` depend on by path.""" + systems = {system.name: system for system in build_systems()} + for build in facts.of(BuildFile): + system = systems.get(build.build_system) + if _directory(build) != directory or system is None or system.path_dependencies is None: + continue + for path in system.path_dependencies(project.read_text(build.origin.path)): + yield posixpath.normpath(posixpath.join(directory, path)) + + +def tests_unit(facts: Facts) -> Callable[[str, str], bool]: + """Whether a path is in a unit of tests (a separate test project) that tests a unit (see `Unit.tests`).""" + units = {found.directory: found for found in facts.of(Unit)} + + def tests(path: str, unit: str) -> bool: + found = units.get(owner(path, units)) + return found is not None and found.role == "test" and (not found.tests or unit in found.tests) + + return tests + + type _Found = list[tuple[BuildFile | None, str]] @@ -593,4 +630,5 @@ def structure_facts(project: Project) -> Iterator[Fact]: "source_languages", "source_signal", "structure_facts", + "tests_unit", ] diff --git a/project_validator/questions/__init__.py b/project_validator/questions/__init__.py index 7e1d71d0..ff6a2387 100644 --- a/project_validator/questions/__init__.py +++ b/project_validator/questions/__init__.py @@ -18,7 +18,7 @@ from project_validator.ecosystems import Kind from project_validator.facts import Facts, Unknown from project_validator.facts.auxiliary import Selectors, selectors -from project_validator.facts.structure import SourceFile, Unit +from project_validator.facts.structure import SourceFile, Unit, tests_unit from project_validator.facts.testing import TEST from project_validator.facts.tools import Tool, ToolRun, owner @@ -141,26 +141,22 @@ def runs_of( Runs that cannot fail the pipeline enforce nothing: they are left out, or, with `advisory`, are all there is.""" units = [found.directory for found in facts.of(Unit)] or ["."] concerns, named = frozenset(auxiliary), selectors(facts) - tests = _test_units(facts) if aspect == TEST else frozenset() + in_test_unit = tests_unit(facts) if aspect == TEST else None return tuple( run for run in facts.of(ToolRun) if aspect in run.provides and language in run.languages - and (run.covers(unit, units) or _in_test_unit(run, units, tests)) + and (run.covers(unit, units) or _in_test_unit(run, unit, in_test_unit)) and not _auxiliary(run, language, concerns, named) and bool(run.advisory) == advisory ) -def _test_units(facts: Facts) -> frozenset[str]: - return frozenset(found.directory for found in facts.of(Unit) if found.role == "test") - - -def _in_test_unit(run: ToolRun, units: list[str], tests: frozenset[str]) -> bool: - """Whether a test run is in a unit of tests (serde's test_suite), whose tests count for every unit: it runs them - for every unit.""" - return bool(tests) and any(owner(scope, units) in tests for scope in run.scope) +def _in_test_unit(run: ToolRun, unit: str, in_test_unit: Callable[[str, str], bool] | None) -> bool: + """Whether a test run is in a unit of tests (serde's test_suite) that tests `unit`: it runs the tests it has for + that unit (see `project_validator.facts.structure.Unit.tests`).""" + return in_test_unit is not None and any(in_test_unit(scope, unit) for scope in run.scope) def unknowns_for( diff --git a/project_validator/questions/tooling.py b/project_validator/questions/tooling.py index 66d66406..5bc33e20 100644 --- a/project_validator/questions/tooling.py +++ b/project_validator/questions/tooling.py @@ -16,7 +16,7 @@ from project_validator.facts import Facts from project_validator.facts.auxiliary import selectors from project_validator.facts.roles import role -from project_validator.facts.structure import Unit +from project_validator.facts.structure import Unit, tests_unit from project_validator.facts.tools import Tool, known_tools, owner, within from project_validator.questions import Answer, LanguageAnswers, answer_dict, per_unit, runs_of, unknowns_for @@ -189,21 +189,15 @@ def _known(tool: Tool, aspect: str) -> KnownTool: type _Defined = tuple[tuple[str, tuple[str, ...]], ...] -def _test_unit_files(facts: Facts) -> Callable[[str], bool]: - """Whether a file is in a unit of tests (a separate test project).""" - units = {found.directory: found.role for found in facts.of(Unit)} - return lambda path: units.get(owner(path, units), "product") == "test" - - def _defined(aspect: str, known: tuple[Tool, ...], facts: Facts, unit: str, auxiliary: tuple[str, ...]) -> _Defined: """Each known tool whose definition a file that applies to `unit` (or to the auxiliary code the answer is about) holds, with those files.""" - in_test_unit = _test_unit_files(facts) + in_test_unit = tests_unit(facts) def applies(tool: Tool, path: str) -> bool: definition = tool.definitions.get(aspect) relevant = _relevant(path, unit, facts, auxiliary) - return relevant or (definition is not None and definition.from_test_units and in_test_unit(path)) + return relevant or (definition is not None and definition.from_test_units and in_test_unit(path, unit)) found = ((tool.name, tuple(path for path in tool.defined(aspect, facts) if applies(tool, path))) for tool in known) return tuple((name, paths) for name, paths in found if paths) diff --git a/tests/regressions/test_detection.py b/tests/regressions/test_detection.py index 4bc17bb0..7b8cd1a3 100644 --- a/tests/regressions/test_detection.py +++ b/tests/regressions/test_detection.py @@ -181,7 +181,8 @@ def test_a_content_detected_format_belongs_to_the_unit_holding_the_files(self) - class TestUnitRunTests(unittest.TestCase): def test_a_test_units_test_run_runs_the_tests_of_every_unit(self) -> None: """serde's CI runs `cd test_suite && cargo test`: the workspace's unit of tests, whose tests count for every - unit, runs them for every unit (#230). Its clippy run still lints only test_suite.""" + unit when it names none it tests, runs them for every unit (#230). Its clippy run still lints only + test_suite.""" lib = "[package]\nname = '{}'\nversion = '0.1.0'\n" files = { "Cargo.toml": "[workspace]\nmembers = ['serde', 'test_suite']\n", @@ -201,10 +202,42 @@ def test_a_test_units_test_run_runs_the_tests_of_every_unit(self) -> None: ) +class TestUnitCreditTests(unittest.TestCase): + """A unit of tests counts for the units it tests (upstream #230): those it depends on by path, and the unit it is + in; for every unit only when it says neither.""" + + def test_a_test_crate_counts_for_the_crates_it_depends_on(self) -> None: + """tokio's tests-integration depends on tokio by path: its tests are tokio's, not the benches' nor another + crate's.""" + lib = "[package]\nname = '{}'\nversion = '0.1.0'\n" + files = { + "Cargo.toml": "[workspace]\nmembers = ['tokio', 'benches', 'other', 'tests-integration']\n", + **{f"{name}/Cargo.toml": lib.format(name) for name in ("tokio", "benches", "other")}, + **{f"{name}/src/lib.rs": "" for name in ("tokio", "benches", "other")}, + "tests-integration/Cargo.toml": lib.format("ti") + "\n[dependencies]\ntokio = { path = '../tokio' }\n", + "tests-integration/tests/a.rs": "#[test]\nfn a() {}\n", + **github_job("ubuntu-latest", "cargo test --workspace"), + } + places = {place.unit: place.result.status for place in _result(tests_run, files).places} + self.assertEqual(places, {"tokio": Status.PASS, "other": Status.FAIL, "tests-integration": Status.PASS}) + + def test_a_test_project_inside_a_unit_counts_for_that_unit(self) -> None: + """hledger-web/test/browser's Playwright specs test hledger-web, not the root package (hledger).""" + files = { + "app.cabal": "name: app\n", + "static/root.js": "", + "web/web.cabal": "name: web\n", + "web/static/app.js": "", + "web/test/browser/package.json": json.dumps({"name": "e2e", "devDependencies": {"@playwright/test": "1"}}), + "web/test/browser/a.spec.js": "test('a', () => {})\n", + } + self.assertEqual(_root_unit_tests(files, "JavaScript"), ()) + + class TestsCountedPerUnitTests(unittest.TestCase): def test_a_unit_reports_only_the_test_files_it_owns(self) -> None: """The root unit, which owns no tests, has none: a child package's test files are its own (bloc, drift, - Pluto.jl). (A separate test project's tests, hledger's web/test/browser, count for every unit by design.)""" + Pluto.jl). (A separate test project's tests count for the units it tests: see `TestUnitCreditTests`.)""" dart = { "tool/gen.dart": "void main() {}\n", "packages/a/pubspec.yaml": "name: a\nenvironment:\n sdk: ^3.5.0\n", diff --git a/tests/snapshots/bare_ansible.facts.json b/tests/snapshots/bare_ansible.facts.json index ab2933df..18457f31 100644 --- a/tests/snapshots/bare_ansible.facts.json +++ b/tests/snapshots/bare_ansible.facts.json @@ -30,7 +30,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_beam.facts.json b/tests/snapshots/bare_beam.facts.json index 941e6bf0..65c759a6 100644 --- a/tests/snapshots/bare_beam.facts.json +++ b/tests/snapshots/bare_beam.facts.json @@ -58,7 +58,8 @@ "Erlang" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_c.facts.json b/tests/snapshots/bare_c.facts.json index b3e59d49..16ad4d89 100644 --- a/tests/snapshots/bare_c.facts.json +++ b/tests/snapshots/bare_c.facts.json @@ -38,7 +38,8 @@ "C" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_clojure.facts.json b/tests/snapshots/bare_clojure.facts.json index d44387d6..1e05807b 100644 --- a/tests/snapshots/bare_clojure.facts.json +++ b/tests/snapshots/bare_clojure.facts.json @@ -38,7 +38,8 @@ "Clojure" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_common_lisp.facts.json b/tests/snapshots/bare_common_lisp.facts.json index 8a40af36..ad8e8f7d 100644 --- a/tests/snapshots/bare_common_lisp.facts.json +++ b/tests/snapshots/bare_common_lisp.facts.json @@ -44,7 +44,8 @@ "Common Lisp" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_cpp.facts.json b/tests/snapshots/bare_cpp.facts.json index c3041887..dbdc46bc 100644 --- a/tests/snapshots/bare_cpp.facts.json +++ b/tests/snapshots/bare_cpp.facts.json @@ -31,7 +31,8 @@ "C++" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_dart.facts.json b/tests/snapshots/bare_dart.facts.json index a24f750a..8e57276d 100644 --- a/tests/snapshots/bare_dart.facts.json +++ b/tests/snapshots/bare_dart.facts.json @@ -40,7 +40,8 @@ "Dart" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_data.facts.json b/tests/snapshots/bare_data.facts.json index 27854f47..04ef2511 100644 --- a/tests/snapshots/bare_data.facts.json +++ b/tests/snapshots/bare_data.facts.json @@ -37,7 +37,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": 1, diff --git a/tests/snapshots/bare_docker.facts.json b/tests/snapshots/bare_docker.facts.json index 0e041738..9d87ebdf 100644 --- a/tests/snapshots/bare_docker.facts.json +++ b/tests/snapshots/bare_docker.facts.json @@ -21,7 +21,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": 1, diff --git a/tests/snapshots/bare_documentation.facts.json b/tests/snapshots/bare_documentation.facts.json index 95cb436a..8c6bacb2 100644 --- a/tests/snapshots/bare_documentation.facts.json +++ b/tests/snapshots/bare_documentation.facts.json @@ -30,7 +30,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_dotnet.facts.json b/tests/snapshots/bare_dotnet.facts.json index e7afb6ad..c99a9d78 100644 --- a/tests/snapshots/bare_dotnet.facts.json +++ b/tests/snapshots/bare_dotnet.facts.json @@ -25,7 +25,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "build_systems": [ @@ -37,7 +38,8 @@ "C#" ], "origin": "src/App", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_emacs_lisp.facts.json b/tests/snapshots/bare_emacs_lisp.facts.json index 96d72446..9ff76fd4 100644 --- a/tests/snapshots/bare_emacs_lisp.facts.json +++ b/tests/snapshots/bare_emacs_lisp.facts.json @@ -38,7 +38,8 @@ "Emacs Lisp" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_fortran.facts.json b/tests/snapshots/bare_fortran.facts.json index 82297d18..e12d118d 100644 --- a/tests/snapshots/bare_fortran.facts.json +++ b/tests/snapshots/bare_fortran.facts.json @@ -60,7 +60,8 @@ "Fortran" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_github_action.facts.json b/tests/snapshots/bare_github_action.facts.json index a3126b69..56a9b38b 100644 --- a/tests/snapshots/bare_github_action.facts.json +++ b/tests/snapshots/bare_github_action.facts.json @@ -30,7 +30,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_go.facts.json b/tests/snapshots/bare_go.facts.json index c8b8fd8d..bbee8195 100644 --- a/tests/snapshots/bare_go.facts.json +++ b/tests/snapshots/bare_go.facts.json @@ -44,7 +44,8 @@ "Go" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_graphql.facts.json b/tests/snapshots/bare_graphql.facts.json index b2c1f59a..aaf91c62 100644 --- a/tests/snapshots/bare_graphql.facts.json +++ b/tests/snapshots/bare_graphql.facts.json @@ -29,7 +29,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] } ], "map": { diff --git a/tests/snapshots/bare_haskell.facts.json b/tests/snapshots/bare_haskell.facts.json index 54f4e3e6..439c8e46 100644 --- a/tests/snapshots/bare_haskell.facts.json +++ b/tests/snapshots/bare_haskell.facts.json @@ -44,7 +44,8 @@ "Haskell" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_javascript.facts.json b/tests/snapshots/bare_javascript.facts.json index 0229df46..f6205735 100644 --- a/tests/snapshots/bare_javascript.facts.json +++ b/tests/snapshots/bare_javascript.facts.json @@ -46,7 +46,8 @@ "JavaScript" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_json_schema.facts.json b/tests/snapshots/bare_json_schema.facts.json index 19092f84..796d73e4 100644 --- a/tests/snapshots/bare_json_schema.facts.json +++ b/tests/snapshots/bare_json_schema.facts.json @@ -30,7 +30,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_julia.facts.json b/tests/snapshots/bare_julia.facts.json index 0fadccff..cb78ff02 100644 --- a/tests/snapshots/bare_julia.facts.json +++ b/tests/snapshots/bare_julia.facts.json @@ -46,7 +46,8 @@ "Julia" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_jupyter.facts.json b/tests/snapshots/bare_jupyter.facts.json index eb264f2e..0f2143ef 100644 --- a/tests/snapshots/bare_jupyter.facts.json +++ b/tests/snapshots/bare_jupyter.facts.json @@ -21,7 +21,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_jvm.facts.json b/tests/snapshots/bare_jvm.facts.json index ed2d6696..fe818335 100644 --- a/tests/snapshots/bare_jvm.facts.json +++ b/tests/snapshots/bare_jvm.facts.json @@ -38,7 +38,8 @@ "Java" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_kubernetes.facts.json b/tests/snapshots/bare_kubernetes.facts.json index b7fb7f4d..3e824398 100644 --- a/tests/snapshots/bare_kubernetes.facts.json +++ b/tests/snapshots/bare_kubernetes.facts.json @@ -30,7 +30,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_latex.facts.json b/tests/snapshots/bare_latex.facts.json index 8738c37f..dc3cdc4e 100644 --- a/tests/snapshots/bare_latex.facts.json +++ b/tests/snapshots/bare_latex.facts.json @@ -35,7 +35,8 @@ "LaTeX" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_lua.facts.json b/tests/snapshots/bare_lua.facts.json index c1f213eb..9776946b 100644 --- a/tests/snapshots/bare_lua.facts.json +++ b/tests/snapshots/bare_lua.facts.json @@ -37,7 +37,8 @@ "Lua" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_nix.facts.json b/tests/snapshots/bare_nix.facts.json index 1ace8275..d1315da0 100644 --- a/tests/snapshots/bare_nix.facts.json +++ b/tests/snapshots/bare_nix.facts.json @@ -38,7 +38,8 @@ "Nix" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_ocaml.facts.json b/tests/snapshots/bare_ocaml.facts.json index b08463cb..a2e03df4 100644 --- a/tests/snapshots/bare_ocaml.facts.json +++ b/tests/snapshots/bare_ocaml.facts.json @@ -39,7 +39,8 @@ "OCaml" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_openapi.facts.json b/tests/snapshots/bare_openapi.facts.json index e4eb8e51..5531bfd8 100644 --- a/tests/snapshots/bare_openapi.facts.json +++ b/tests/snapshots/bare_openapi.facts.json @@ -30,7 +30,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_perl.facts.json b/tests/snapshots/bare_perl.facts.json index e43a69af..bbfe650c 100644 --- a/tests/snapshots/bare_perl.facts.json +++ b/tests/snapshots/bare_perl.facts.json @@ -47,7 +47,8 @@ "Perl" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_php.facts.json b/tests/snapshots/bare_php.facts.json index 8e1891b3..aeb6ea3d 100644 --- a/tests/snapshots/bare_php.facts.json +++ b/tests/snapshots/bare_php.facts.json @@ -46,7 +46,8 @@ "PHP" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_protobuf.facts.json b/tests/snapshots/bare_protobuf.facts.json index 271b530c..4c05815a 100644 --- a/tests/snapshots/bare_protobuf.facts.json +++ b/tests/snapshots/bare_protobuf.facts.json @@ -21,7 +21,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "declared": { diff --git a/tests/snapshots/bare_python.facts.json b/tests/snapshots/bare_python.facts.json index 6d7189e6..ce9b7ffa 100644 --- a/tests/snapshots/bare_python.facts.json +++ b/tests/snapshots/bare_python.facts.json @@ -40,7 +40,8 @@ "Python" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_r.facts.json b/tests/snapshots/bare_r.facts.json index e183ef28..1b64022d 100644 --- a/tests/snapshots/bare_r.facts.json +++ b/tests/snapshots/bare_r.facts.json @@ -31,7 +31,8 @@ "R" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_racket.facts.json b/tests/snapshots/bare_racket.facts.json index aa279e96..64035a6b 100644 --- a/tests/snapshots/bare_racket.facts.json +++ b/tests/snapshots/bare_racket.facts.json @@ -38,7 +38,8 @@ "Racket" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_ruby.facts.json b/tests/snapshots/bare_ruby.facts.json index 8d5452ab..feb22ab9 100644 --- a/tests/snapshots/bare_ruby.facts.json +++ b/tests/snapshots/bare_ruby.facts.json @@ -37,7 +37,8 @@ "Ruby" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_rust.facts.json b/tests/snapshots/bare_rust.facts.json index a72d2654..6f0bc56c 100644 --- a/tests/snapshots/bare_rust.facts.json +++ b/tests/snapshots/bare_rust.facts.json @@ -47,7 +47,8 @@ "Rust" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_scala.facts.json b/tests/snapshots/bare_scala.facts.json index 4c55425b..4c363886 100644 --- a/tests/snapshots/bare_scala.facts.json +++ b/tests/snapshots/bare_scala.facts.json @@ -38,7 +38,8 @@ "Scala" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_shell.facts.json b/tests/snapshots/bare_shell.facts.json index 5125cc62..8a83baea 100644 --- a/tests/snapshots/bare_shell.facts.json +++ b/tests/snapshots/bare_shell.facts.json @@ -29,7 +29,8 @@ "Shell" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "ConfigurationFile", diff --git a/tests/snapshots/bare_sql.facts.json b/tests/snapshots/bare_sql.facts.json index 4a0ea0f9..ea6ff86b 100644 --- a/tests/snapshots/bare_sql.facts.json +++ b/tests/snapshots/bare_sql.facts.json @@ -70,7 +70,8 @@ "SQL" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_swift.facts.json b/tests/snapshots/bare_swift.facts.json index 0355ed89..bdc23372 100644 --- a/tests/snapshots/bare_swift.facts.json +++ b/tests/snapshots/bare_swift.facts.json @@ -38,7 +38,8 @@ "Swift" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_tabular_data.facts.json b/tests/snapshots/bare_tabular_data.facts.json index 55fd27a2..d68e0ffa 100644 --- a/tests/snapshots/bare_tabular_data.facts.json +++ b/tests/snapshots/bare_tabular_data.facts.json @@ -30,7 +30,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_terraform.facts.json b/tests/snapshots/bare_terraform.facts.json index e7e5fbc7..2dedd096 100644 --- a/tests/snapshots/bare_terraform.facts.json +++ b/tests/snapshots/bare_terraform.facts.json @@ -27,7 +27,8 @@ "Terraform" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/bare_typescript.facts.json b/tests/snapshots/bare_typescript.facts.json index 1cfc299f..a797c1e3 100644 --- a/tests/snapshots/bare_typescript.facts.json +++ b/tests/snapshots/bare_typescript.facts.json @@ -46,7 +46,8 @@ "TypeScript" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_typst.facts.json b/tests/snapshots/bare_typst.facts.json index 179fdef9..178e99ee 100644 --- a/tests/snapshots/bare_typst.facts.json +++ b/tests/snapshots/bare_typst.facts.json @@ -21,7 +21,8 @@ "Typst" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "documents (*.typ)", diff --git a/tests/snapshots/bare_xml_schemas.facts.json b/tests/snapshots/bare_xml_schemas.facts.json index da674e19..92cb8701 100644 --- a/tests/snapshots/bare_xml_schemas.facts.json +++ b/tests/snapshots/bare_xml_schemas.facts.json @@ -46,7 +46,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/bare_zig.facts.json b/tests/snapshots/bare_zig.facts.json index 4a6e332d..76fb209d 100644 --- a/tests/snapshots/bare_zig.facts.json +++ b/tests/snapshots/bare_zig.facts.json @@ -38,7 +38,8 @@ "Zig" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "CommittedOutput", diff --git a/tests/snapshots/buildable.facts.json b/tests/snapshots/buildable.facts.json index a84f5c9a..3d58fdeb 100644 --- a/tests/snapshots/buildable.facts.json +++ b/tests/snapshots/buildable.facts.json @@ -24,7 +24,8 @@ "C" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "kind": "ConfigurationFile", diff --git a/tests/snapshots/well_configured_ansible.facts.json b/tests/snapshots/well_configured_ansible.facts.json index 36bd2714..3440ca07 100644 --- a/tests/snapshots/well_configured_ansible.facts.json +++ b/tests/snapshots/well_configured_ansible.facts.json @@ -121,7 +121,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_beam.facts.json b/tests/snapshots/well_configured_beam.facts.json index a7ac1d01..f9163163 100644 --- a/tests/snapshots/well_configured_beam.facts.json +++ b/tests/snapshots/well_configured_beam.facts.json @@ -111,7 +111,8 @@ "Erlang" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_c.facts.json b/tests/snapshots/well_configured_c.facts.json index 7de15d53..e04e3168 100644 --- a/tests/snapshots/well_configured_c.facts.json +++ b/tests/snapshots/well_configured_c.facts.json @@ -87,7 +87,8 @@ "C" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_clojure.facts.json b/tests/snapshots/well_configured_clojure.facts.json index f658623c..b3e6bcfe 100644 --- a/tests/snapshots/well_configured_clojure.facts.json +++ b/tests/snapshots/well_configured_clojure.facts.json @@ -96,7 +96,8 @@ "Clojure" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_common_lisp.facts.json b/tests/snapshots/well_configured_common_lisp.facts.json index c28dfc62..c1902607 100644 --- a/tests/snapshots/well_configured_common_lisp.facts.json +++ b/tests/snapshots/well_configured_common_lisp.facts.json @@ -75,7 +75,8 @@ "Common Lisp" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_cpp.facts.json b/tests/snapshots/well_configured_cpp.facts.json index 18c221c8..c4fa2dea 100644 --- a/tests/snapshots/well_configured_cpp.facts.json +++ b/tests/snapshots/well_configured_cpp.facts.json @@ -87,7 +87,8 @@ "C++" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_dart.facts.json b/tests/snapshots/well_configured_dart.facts.json index ee5efca8..1ec2f257 100644 --- a/tests/snapshots/well_configured_dart.facts.json +++ b/tests/snapshots/well_configured_dart.facts.json @@ -96,7 +96,8 @@ "Dart" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_data.facts.json b/tests/snapshots/well_configured_data.facts.json index f9418943..aa5c6669 100644 --- a/tests/snapshots/well_configured_data.facts.json +++ b/tests/snapshots/well_configured_data.facts.json @@ -126,7 +126,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_docker.facts.json b/tests/snapshots/well_configured_docker.facts.json index 741b3c32..43e6c7be 100644 --- a/tests/snapshots/well_configured_docker.facts.json +++ b/tests/snapshots/well_configured_docker.facts.json @@ -57,7 +57,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_documentation.facts.json b/tests/snapshots/well_configured_documentation.facts.json index b87ee6b2..28e579e6 100644 --- a/tests/snapshots/well_configured_documentation.facts.json +++ b/tests/snapshots/well_configured_documentation.facts.json @@ -65,7 +65,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_dotnet.facts.json b/tests/snapshots/well_configured_dotnet.facts.json index 613eb905..f6d4c7ea 100644 --- a/tests/snapshots/well_configured_dotnet.facts.json +++ b/tests/snapshots/well_configured_dotnet.facts.json @@ -127,7 +127,8 @@ "C#" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_emacs_lisp.facts.json b/tests/snapshots/well_configured_emacs_lisp.facts.json index d8c3bbe9..459bd28c 100644 --- a/tests/snapshots/well_configured_emacs_lisp.facts.json +++ b/tests/snapshots/well_configured_emacs_lisp.facts.json @@ -68,7 +68,8 @@ "Emacs Lisp" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_fortran.facts.json b/tests/snapshots/well_configured_fortran.facts.json index 5a90f322..8bb6b650 100644 --- a/tests/snapshots/well_configured_fortran.facts.json +++ b/tests/snapshots/well_configured_fortran.facts.json @@ -90,7 +90,8 @@ "Fortran" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_github_action.facts.json b/tests/snapshots/well_configured_github_action.facts.json index 33401b5f..76818769 100644 --- a/tests/snapshots/well_configured_github_action.facts.json +++ b/tests/snapshots/well_configured_github_action.facts.json @@ -58,7 +58,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_go.facts.json b/tests/snapshots/well_configured_go.facts.json index 6b7cc3e2..1528237e 100644 --- a/tests/snapshots/well_configured_go.facts.json +++ b/tests/snapshots/well_configured_go.facts.json @@ -96,7 +96,8 @@ "Go" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_graphql.facts.json b/tests/snapshots/well_configured_graphql.facts.json index e412892c..f50a4bad 100644 --- a/tests/snapshots/well_configured_graphql.facts.json +++ b/tests/snapshots/well_configured_graphql.facts.json @@ -72,7 +72,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_haskell.facts.json b/tests/snapshots/well_configured_haskell.facts.json index 8f746e9e..053ced40 100644 --- a/tests/snapshots/well_configured_haskell.facts.json +++ b/tests/snapshots/well_configured_haskell.facts.json @@ -90,7 +90,8 @@ "Haskell" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_javascript.facts.json b/tests/snapshots/well_configured_javascript.facts.json index 7b316bb7..ea3612bc 100644 --- a/tests/snapshots/well_configured_javascript.facts.json +++ b/tests/snapshots/well_configured_javascript.facts.json @@ -111,7 +111,8 @@ "JavaScript" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_json_schema.facts.json b/tests/snapshots/well_configured_json_schema.facts.json index ad17eab5..961310a4 100644 --- a/tests/snapshots/well_configured_json_schema.facts.json +++ b/tests/snapshots/well_configured_json_schema.facts.json @@ -80,7 +80,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_julia.facts.json b/tests/snapshots/well_configured_julia.facts.json index 520fcd64..2de6b0b0 100644 --- a/tests/snapshots/well_configured_julia.facts.json +++ b/tests/snapshots/well_configured_julia.facts.json @@ -83,7 +83,8 @@ "Julia" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_jupyter.facts.json b/tests/snapshots/well_configured_jupyter.facts.json index 1e907b60..dd320101 100644 --- a/tests/snapshots/well_configured_jupyter.facts.json +++ b/tests/snapshots/well_configured_jupyter.facts.json @@ -58,7 +58,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_jvm.facts.json b/tests/snapshots/well_configured_jvm.facts.json index 89eb9adc..0ac2eb3c 100644 --- a/tests/snapshots/well_configured_jvm.facts.json +++ b/tests/snapshots/well_configured_jvm.facts.json @@ -88,7 +88,8 @@ "Java" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_kubernetes.facts.json b/tests/snapshots/well_configured_kubernetes.facts.json index 62a65705..6e4f990b 100644 --- a/tests/snapshots/well_configured_kubernetes.facts.json +++ b/tests/snapshots/well_configured_kubernetes.facts.json @@ -100,7 +100,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_latex.facts.json b/tests/snapshots/well_configured_latex.facts.json index 10860ee0..e93dff9a 100644 --- a/tests/snapshots/well_configured_latex.facts.json +++ b/tests/snapshots/well_configured_latex.facts.json @@ -66,7 +66,8 @@ "LaTeX" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_lua.facts.json b/tests/snapshots/well_configured_lua.facts.json index bc02239e..24fb8b0b 100644 --- a/tests/snapshots/well_configured_lua.facts.json +++ b/tests/snapshots/well_configured_lua.facts.json @@ -91,7 +91,8 @@ "Lua" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_nix.facts.json b/tests/snapshots/well_configured_nix.facts.json index b61448dc..c9589fa4 100644 --- a/tests/snapshots/well_configured_nix.facts.json +++ b/tests/snapshots/well_configured_nix.facts.json @@ -68,7 +68,8 @@ "Nix" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_ocaml.facts.json b/tests/snapshots/well_configured_ocaml.facts.json index ca1a8c63..e8a31839 100644 --- a/tests/snapshots/well_configured_ocaml.facts.json +++ b/tests/snapshots/well_configured_ocaml.facts.json @@ -100,7 +100,8 @@ "OCaml" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_openapi.facts.json b/tests/snapshots/well_configured_openapi.facts.json index 98495b92..60f11986 100644 --- a/tests/snapshots/well_configured_openapi.facts.json +++ b/tests/snapshots/well_configured_openapi.facts.json @@ -65,7 +65,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_perl.facts.json b/tests/snapshots/well_configured_perl.facts.json index 758fed9e..30151eaa 100644 --- a/tests/snapshots/well_configured_perl.facts.json +++ b/tests/snapshots/well_configured_perl.facts.json @@ -91,7 +91,8 @@ "Perl" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_php.facts.json b/tests/snapshots/well_configured_php.facts.json index 93969460..7b6aa4af 100644 --- a/tests/snapshots/well_configured_php.facts.json +++ b/tests/snapshots/well_configured_php.facts.json @@ -95,7 +95,8 @@ "PHP" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_protobuf.facts.json b/tests/snapshots/well_configured_protobuf.facts.json index 1afa3c38..214528f4 100644 --- a/tests/snapshots/well_configured_protobuf.facts.json +++ b/tests/snapshots/well_configured_protobuf.facts.json @@ -57,7 +57,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_python.facts.json b/tests/snapshots/well_configured_python.facts.json index d7416788..3b2d3346 100644 --- a/tests/snapshots/well_configured_python.facts.json +++ b/tests/snapshots/well_configured_python.facts.json @@ -83,7 +83,8 @@ "Python" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_r.facts.json b/tests/snapshots/well_configured_r.facts.json index bb49a2b9..8f5c0c66 100644 --- a/tests/snapshots/well_configured_r.facts.json +++ b/tests/snapshots/well_configured_r.facts.json @@ -82,7 +82,8 @@ "R" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_racket.facts.json b/tests/snapshots/well_configured_racket.facts.json index cc9e54c6..631d5a87 100644 --- a/tests/snapshots/well_configured_racket.facts.json +++ b/tests/snapshots/well_configured_racket.facts.json @@ -68,7 +68,8 @@ "Racket" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_ruby.facts.json b/tests/snapshots/well_configured_ruby.facts.json index 248c06dc..2ca31aef 100644 --- a/tests/snapshots/well_configured_ruby.facts.json +++ b/tests/snapshots/well_configured_ruby.facts.json @@ -110,7 +110,8 @@ "Ruby" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_rust.facts.json b/tests/snapshots/well_configured_rust.facts.json index adcdc358..32673d1f 100644 --- a/tests/snapshots/well_configured_rust.facts.json +++ b/tests/snapshots/well_configured_rust.facts.json @@ -105,7 +105,8 @@ "Rust" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "build_systems": [ @@ -119,7 +120,10 @@ "Rust" ], "origin": "fuzz", - "role": "test" + "role": "test", + "tests": [ + "." + ] }, { "column": null, diff --git a/tests/snapshots/well_configured_scala.facts.json b/tests/snapshots/well_configured_scala.facts.json index 4f039961..361da507 100644 --- a/tests/snapshots/well_configured_scala.facts.json +++ b/tests/snapshots/well_configured_scala.facts.json @@ -103,7 +103,8 @@ "Scala" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_shell.facts.json b/tests/snapshots/well_configured_shell.facts.json index 36420855..5a1d15f1 100644 --- a/tests/snapshots/well_configured_shell.facts.json +++ b/tests/snapshots/well_configured_shell.facts.json @@ -88,7 +88,8 @@ "Shell" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_sql.facts.json b/tests/snapshots/well_configured_sql.facts.json index 8c480a43..7eb7d60d 100644 --- a/tests/snapshots/well_configured_sql.facts.json +++ b/tests/snapshots/well_configured_sql.facts.json @@ -118,7 +118,8 @@ "SQL" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_swift.facts.json b/tests/snapshots/well_configured_swift.facts.json index ec44180d..170a1212 100644 --- a/tests/snapshots/well_configured_swift.facts.json +++ b/tests/snapshots/well_configured_swift.facts.json @@ -117,7 +117,8 @@ "Swift" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_tabular_data.facts.json b/tests/snapshots/well_configured_tabular_data.facts.json index c7b6975a..e1302c47 100644 --- a/tests/snapshots/well_configured_tabular_data.facts.json +++ b/tests/snapshots/well_configured_tabular_data.facts.json @@ -59,7 +59,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_terraform.facts.json b/tests/snapshots/well_configured_terraform.facts.json index accfdc08..d49b2d64 100644 --- a/tests/snapshots/well_configured_terraform.facts.json +++ b/tests/snapshots/well_configured_terraform.facts.json @@ -86,7 +86,8 @@ "Terraform" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_typescript.facts.json b/tests/snapshots/well_configured_typescript.facts.json index 66bfb31b..8344b572 100644 --- a/tests/snapshots/well_configured_typescript.facts.json +++ b/tests/snapshots/well_configured_typescript.facts.json @@ -118,7 +118,8 @@ "TypeScript" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_typst.facts.json b/tests/snapshots/well_configured_typst.facts.json index 10c9b0d7..8f6aa127 100644 --- a/tests/snapshots/well_configured_typst.facts.json +++ b/tests/snapshots/well_configured_typst.facts.json @@ -51,7 +51,8 @@ "Typst" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_xml_schemas.facts.json b/tests/snapshots/well_configured_xml_schemas.facts.json index 7e508bf5..af63e831 100644 --- a/tests/snapshots/well_configured_xml_schemas.facts.json +++ b/tests/snapshots/well_configured_xml_schemas.facts.json @@ -96,7 +96,8 @@ "kind": "Unit", "languages": [], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, diff --git a/tests/snapshots/well_configured_zig.facts.json b/tests/snapshots/well_configured_zig.facts.json index d9dc438e..79ac8903 100644 --- a/tests/snapshots/well_configured_zig.facts.json +++ b/tests/snapshots/well_configured_zig.facts.json @@ -97,7 +97,8 @@ "Zig" ], "origin": ".", - "role": "product" + "role": "product", + "tests": [] }, { "column": null, From cd46495d5d8473aab68a9ed4105fa67fcdf85a0a Mon Sep 17 00:00:00 2001 From: leftibot Date: Mon, 23 Nov 2026 23:07:52 -0700 Subject: [PATCH 8/8] Do not name a test fixture's manifest or tool configuration as the product's Part of #188. A manifest or a tool's configuration below a test suite's data directory (`tests/fixtures/`, `tests/**/Fixtures/`, `testdata/`) is test data, set apart from the code around it as code --auxiliary names is (`Selectors.apart`): PHP_CodeSniffer's fixture phpcs.xml.dist files no longer define its formatting, nor composer's and poetry's fixture manifests and lock files its dependencies. An example's files are not set apart: a Flutter plugin's tests are its example app's. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt --- project_validator/facts/auxiliary.py | 10 +++++++++- project_validator/questions/dependencies.py | 6 +++--- project_validator/questions/tooling.py | 6 +++--- tests/test_units.py | 18 ++++++++++++++++++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/project_validator/facts/auxiliary.py b/project_validator/facts/auxiliary.py index b802df12..4eb8f71c 100644 --- a/project_validator/facts/auxiliary.py +++ b/project_validator/facts/auxiliary.py @@ -17,7 +17,7 @@ from project_validator.ecosystems import registered from project_validator.facts import Fact, Facts -from project_validator.facts.roles import AUXILIARY, role +from project_validator.facts.roles import AUXILIARY, fixture_data, role from project_validator.facts.tools import within @@ -97,6 +97,14 @@ def matching(self, path: str, language: str | None, *, directory: bool = False) return found return implied(purpose) if language in self.implied and purpose in AUXILIARY else "" + def apart(self, path: str) -> str: + """What sets a file of no language (a manifest, a tool's configuration) apart from the code around it: what + names it (see `matching`), else being a test suite's data (`tests/fixtures/`: upstream #188); "" when it is + the code's around it. An example's files are not set apart: a Flutter plugin's tests are its example app's.""" + if found := self.matching(path, None): + return found + return implied("test") if fixture_data(path) else "" + def selectors(facts: Facts) -> Selectors: """What `--auxiliary` named for the project the facts are about, resolved once.""" diff --git a/project_validator/questions/dependencies.py b/project_validator/questions/dependencies.py index f3fdd194..1401b29b 100644 --- a/project_validator/questions/dependencies.py +++ b/project_validator/questions/dependencies.py @@ -76,9 +76,9 @@ def __init__(self, facts: Facts, unit: str, auxiliary: tuple[str, ...] = ()) -> def owns(self, path: str) -> bool: """Whether a manifest is the unit's own: in its directory, outside the units below it, and neither vendored - nor auxiliary code (what `--auxiliary` names) the answer is not about (`concerns`: what named the code it - is about).""" - by = self.named.matching(path, None) + nor auxiliary code (what `--auxiliary` names, a test fixture, an example: see `Selectors.apart`) the answer + is not about (`concerns`: what named the code it is about).""" + by = self.named.apart(path) apart = role(path) == "vendored" or (by != "" and by not in self.concerns) return owner(directory_of(path), self.units) == self.unit and not apart diff --git a/project_validator/questions/tooling.py b/project_validator/questions/tooling.py index 5bc33e20..3c4b6a3c 100644 --- a/project_validator/questions/tooling.py +++ b/project_validator/questions/tooling.py @@ -141,12 +141,12 @@ def as_dict(self) -> dict[str, object]: def _relevant(path: str, unit: str, facts: Facts, auxiliary: tuple[str, ...]) -> bool: """Whether a definition file applies to code in `unit`: tools look for theirs in a file's directory and the directories above it, so one at or above the unit applies to all of it, and one inside it (not in a unit of its - own) to part of it, unless that part is vendored or auxiliary code (an example's own configuration, with - `--auxiliary example`) the answer is not about (`auxiliary`: what named the code it is about).""" + own) to part of it, unless that part is vendored or auxiliary code (an example's own configuration, a test + fixture's: see `Selectors.apart`) the answer is not about (`auxiliary`: what named the code it is about).""" directory = str(PurePosixPath(path).parent) if within(unit, directory): return True - named = selectors(facts).matching(path, None) + named = selectors(facts).apart(path) inside = within(directory, unit) and _owner(path, facts) == unit return inside and role(path) != "vendored" and (not named or named in auxiliary) diff --git a/tests/test_units.py b/tests/test_units.py index 1c56d621..17df17e6 100644 --- a/tests/test_units.py +++ b/tests/test_units.py @@ -466,6 +466,24 @@ def test_test_helpers_can_be_named_without_losing_the_tests(self) -> None: python = _place(named, "Python") self.assertEqual((python.result.status, python.auxiliary), (Status.WARN, ("test",))) + def test_test_fixtures_configure_nothing_of_the_product(self) -> None: + """A test fixture's manifest or tool configuration is not the product's (upstream #188: PHP_CodeSniffer's + tests/**/Fixtures/phpcs.xml.dist, composer's fixture composer.json files).""" + files = { + "composer.json": json.dumps({"require": {"php": ">=8.1"}}), + "composer.lock": "{}", + "src/A.php": "\n", + "tests/Fixtures/a/composer.json": json.dumps({"require": {"x/y": "1"}}), + "tests/Fixtures/a/phpcs.xml.dist": "\n", + **_workflow(("vendor/bin/phpcs", None)), + } + dependencies = _check("dependency-management", files) + self.assertNotIn("Fixtures", dependencies.message) + formatting = _check("code-formatting", files) + self.assertIn("phpcs.xml.dist is defined", formatting.message) + self.assertNotIn("Fixtures", formatting.message) + def test_what_is_named_must_be_a_role_a_language_or_a_directory(self) -> None: with temp_project(HELPER_SCRIPTS) as root: for named in ("scripts", "vendored", "product", "/"):