keysForResults

tcmts.cli.vitest.keysForResults · #cfi23yfr · term · runs on the server

uses process

The keys tests' results are kept under, by hash: the runtime and the test framework (resultKey), and the platform too (darwin-arm64) for a test whose code reaches files, the environment or other processes, which differ from one to another. A result travels to another machine only under its own key.

import type { Codebase } from "#codebase/tcmts/cli/codebase";
import { reaches } from "#codebase/tcmts/cli/effects";
import { PLATFORM_BOUND, resultKey } from "#codebase/tcmts/cli/vitest";
import type { DefSource } from "#codebase/tcmts/loader";

export function keysForResults(
  cb: Codebase,
  hashes: Iterable<string>,
  src?: DefSource,
): Map<string, string> {
  const base = resultKey(cb);
  const platform = `${process.platform}-${process.arch}`;
  const out = new Map<string, string>();
  for (const [h, effects] of reaches(cb, hashes, src))
    out.set(h, effects.some((e) => PLATFORM_BOUND.includes(e)) ? `${base} ${platform}` : base);
  return out;
}

uses

used by