Source file src/simd/archsimd/_gen/cmd/spectasks/main_test.go
1 // Copyright 2026 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 "bytes" 9 "os" 10 "path/filepath" 11 "testing" 12 ) 13 14 // TestPlanConsistent checks SPEC-TRANSITION.md against itself. The document 15 // states its dependencies three times -- Part 3's table, Part 4's 16 // "Needs:"/"Prefers:" lines, and Part 4's "Blocks:" lines, which are the same 17 // edges reversed -- and this is what keeps the three from drifting. It also 18 // checks that the table is topologically sorted (treating Prefers as edges), 19 // that unrelated tasks are ordered by track, and that every task is in exactly 20 // one track. 21 // 22 // This runs on the checked-in document rather than on a fixture, because the 23 // checked-in document is the thing that has to be right. 24 func TestPlanConsistent(t *testing.T) { 25 md, _ := paths("") 26 for _, p := range load(md).problems() { 27 t.Errorf("%s: %s", filepath.Base(md), p) 28 } 29 } 30 31 // TestGraphUpToDate checks that SPEC-TASKS.dot still matches the document it 32 // was generated from, so that editing the plan without regenerating is caught 33 // here rather than noticed later in a stale picture. 34 func TestGraphUpToDate(t *testing.T) { 35 md, dotPath := paths("") 36 var want bytes.Buffer 37 load(md).dot(&want) 38 39 got, err := os.ReadFile(dotPath) 40 if err != nil { 41 t.Fatal(err) 42 } 43 if !bytes.Equal(got, want.Bytes()) { 44 t.Errorf("%s is out of date; regenerate with:\n\tgo run ./cmd/spectasks -w", 45 filepath.Base(dotPath)) 46 } 47 } 48