IF Commons GitHub

physical/tests

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0008-repoctl-prove FR-011

Tests selected and run through a result cache (commons repoctl 0008-repoctl-prove FR-011, FR-012): the imports of each test file followed to every source it reads (relative imports, and the packages of the libraries through their exports), what the files of its library import of other libraries, the selection of the Logical layer applied, and each selected test run as its own program, its pass kept under a key that is the hash of the test, of the sources it imports and of the runtime. A key that is in the cache is not run again; a test that reads the checkout is never cached.

The cache is a folder outside the repository (the cache folder of the program under XDG, or the variable REPOCTL_CACHE), one small file for each key; it holds passes only, so a failure is always run again. A test that cannot be shown not to reach what changed runs. The key is exact: a changed byte of a test, of any source it reaches (a folder where an import could not be resolved to a file), or of the runtime is a new key.

import { packageIndexOf } from "./tests.ts";
typeof packageIndexOf; // "function"

Source: commons/repoctl/src/physical/tests.ts

0 of 14 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

physical.PackageIndextypeno test imports it
type PackageIndex = ReadonlyMap<string, { readonly folder: string; readonly exports: ReadonlyMap<string, string> }>;

A package of the repository by its name: its folder and the files its exports name, by subpath.

physical.packageIndexOffunctionno test imports it
function packageIndexOf(w: World, libraries: readonly { readonly package: string; readonly folder: string; }[]): Promise<PackageIndex>

The packages of the libraries with what their exports map each subpath to.

physical.readerOffunctionno test imports it
function readerOf(w: World, index: PackageIndex): { text: (path: string) => Promise<string | undefined>; edgesOf: (path: string) => Promise<Edges>; closureOf: (entry: string) => Promise<{ readonly files: readonly string[]; readonly folders: readonly string[]; }>; }

Reads the imports of the sources a run needs, once for each file.

physical.readTestsfunctionno test imports it
function readTests(w: World, node: LibraryNode, index: PackageIndex, reader?: { text: (path: string) => Promise<string | undefined>; edgesOf: (path: string) => Promise<Edges>; closureOf: (entry: string) => Promise<{ readonly files: readonly string[]; readonly folders: readonly string[]; }>; }): Promise<readonly TestReach[]>

The tests of a library: each test file of its suite/ with what it reaches, what its library imports of the others through it and whether it reads the checkout.

physical.TestOutcometypeno test imports it
type TestOutcome =
  | { readonly kind: "passed"; readonly seconds: number; readonly cached: boolean }
  | { readonly kind: "failed"; readonly seconds: number; readonly output: readonly string[]; readonly seeds: readonly string[] };

How one test ended.

physical.ResultCachetypeno test imports it
type ResultCache = { readonly folder: string; readonly runtime: string } | undefined;

The cache of results: a folder outside the repository, one file for each key; undefined where the host gives none (nothing is cached then).

physical.runTestsfunctionno test imports it
function runTests(w: World, tests: readonly TestReach[], cache: ResultCache, index: PackageIndex, width: number): Promise<ReadonlyMap<string, TestOutcome>>

Runs the tests, a few at a time, each as its own program in its library's folder; a test whose key is in the cache is not run.

PackageIndextypeno test imports it
type PackageIndex = ReadonlyMap<string, { readonly folder: string; readonly exports: ReadonlyMap<string, string> }>;

A package of the repository by its name: its folder and the files its exports name, by subpath.

packageIndexOffunctionno test imports it
function packageIndexOf(w: World, libraries: readonly { readonly package: string; readonly folder: string; }[]): Promise<PackageIndex>

The packages of the libraries with what their exports map each subpath to.

readerOffunctionno test imports it
function readerOf(w: World, index: PackageIndex): { text: (path: string) => Promise<string | undefined>; edgesOf: (path: string) => Promise<Edges>; closureOf: (entry: string) => Promise<{ readonly files: readonly string[]; readonly folders: readonly string[]; }>; }

Reads the imports of the sources a run needs, once for each file.

readTestsfunctionno test imports it
function readTests(w: World, node: LibraryNode, index: PackageIndex, reader?: { text: (path: string) => Promise<string | undefined>; edgesOf: (path: string) => Promise<Edges>; closureOf: (entry: string) => Promise<{ readonly files: readonly string[]; readonly folders: readonly string[]; }>; }): Promise<readonly TestReach[]>

The tests of a library: each test file of its suite/ with what it reaches, what its library imports of the others through it and whether it reads the checkout.

TestOutcometypeno test imports it
type TestOutcome =
  | { readonly kind: "passed"; readonly seconds: number; readonly cached: boolean }
  | { readonly kind: "failed"; readonly seconds: number; readonly output: readonly string[]; readonly seeds: readonly string[] };

How one test ended.

ResultCachetypeno test imports it
type ResultCache = { readonly folder: string; readonly runtime: string } | undefined;

The cache of results: a folder outside the repository, one file for each key; undefined where the host gives none (nothing is cached then).

runTestsfunctionno test imports it
function runTests(w: World, tests: readonly TestReach[], cache: ResultCache, index: PackageIndex, width: number): Promise<ReadonlyMap<string, TestOutcome>>

Runs the tests, a few at a time, each as its own program in its library's folder; a test whose key is in the cache is not run.

Titles, headings, exports, tables, columns and requirements. Esc closes.