suitesIn

tcmts.cli.suites.suitesIn · #zh55dssl · term · runs on the server

uses tcmts.cli.manifests.packagesIn, which uses tcmts.cli.config.configValue, which uses node:path

The suites the packages declare (suites: command → namespaces of test definitions that run it, relative to the package), those in ns.

import type { Codebase } from "#codebase/tcmts/cli/codebase";
import { absolute, packagesIn } from "#codebase/tcmts/cli/manifests";
import type { Suite } from "#codebase/tcmts/cli/suites";
import { isTestPath } from "#codebase/tcmts/cli/testing";

export function suitesIn(cb: Codebase, ns: string): Suite[] {
  const within = (p: string, under: string) => !under || p === under || p.startsWith(`${under}.`);
  const names = cb.store.names();
  const out: Suite[] = [];
  for (const pkg of packagesIn(cb, names)) {
    for (const [bin, entries] of Object.entries(pkg.manifest.suites)) {
      const main = absolute(pkg.namespace, pkg.manifest.bin[bin]!);
      for (const entry of entries) {
        const under = absolute(pkg.namespace, entry);
        for (const n of names) if (n.kind !== "type" && isTestPath(n.path) && within(n.path, under) && within(n.path, ns)) out.push({ pkg: pkg.namespace, bin, main, path: n.path, hash: n.hash });
      }
    }
  }
  return out.sort((a, b) => (a.path < b.path ? -1 : 1));
}

uses

used by