Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pkgs/mcpx/internal/buildcheck/checkphase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ const derivedList = `go list -f '{{if or .TestGoFiles .XTestGoFiles}}{{.ImportPa

var excludeBlock = regexp.MustCompile(`(?s)checkExclude = \[(.*?)\];`)

// preCheckBlock matches the preCheck attribute: its regeneration
// invocation names internal/api on purpose (that is the generator's
// home), so the hand-named-package scan below carves it out — the
// guard is about the check phase narrowing its own list, and the
// preCheck is not the check phase.
var preCheckBlock = regexp.MustCompile(`(?s)preCheck = ''.*?'';`)

func readPackageNix(t *testing.T) string {
t.Helper()
b, err := os.ReadFile(filepath.Join(moduleRoot, "package.nix"))
Expand Down Expand Up @@ -88,7 +95,7 @@ func TestCheckPhaseTestsEveryPackageWithTests(t *testing.T) {
}
// A hand-written package list next to the computed one would silently
// narrow it again.
if regexp.MustCompile(`go test[^\n]*\./internal/`).MatchString(nix) {
if regexp.MustCompile(`go test[^\n]*\./internal/`).MatchString(preCheckBlock.ReplaceAllString(nix, "")) {
t.Fatal("checkPhase names packages by hand; exclude them via checkExclude instead")
}

Expand Down
13 changes: 13 additions & 0 deletions pkgs/mcpx/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ buildGo127Module {
python3
git
];
# ops.gen.ts is generated from the /v1 table (internal/api's
# PluginTS) but checked in, because the TypeScript plugin consumes
# it from the source tree. Regenerate it here, in the build tree,
# before the check phase compares it: a nix build then never fails
# on a stale checked-in copy (code#4806), while the freshness test
# still guards the checked-in file where that matters — plain
# `go test` runs outside nix.
preCheck = ''
export HOME=$TMPDIR/home MCPX_STATE_DIR=$TMPDIR/state MCPX_CACHE_DIR=$TMPDIR/cache
mkdir -p "$HOME"
go test ./internal/api -run TestPluginOpsAreGenerated -update
'';

checkPhase =
let
checkExclude = [
Expand Down
Loading
Loading