Source file src/runtime/lockrank_test.go

     1  // Copyright 2022 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 runtime_test
     6  
     7  import (
     8  	"bytes"
     9  	"internal/testenv"
    10  	"os"
    11  	"os/exec"
    12  	"testing"
    13  )
    14  
    15  // Test that the generated code for the lock rank graph is up-to-date.
    16  func TestLockRankGenerated(t *testing.T) {
    17  	testenv.MustHaveGoRun(t)
    18  	want, err := testenv.CleanCmdEnv(exec.Command(testenv.GoToolPath(t), "run", "mklockrank.go")).CombinedOutput()
    19  	if err != nil {
    20  		t.Fatal(err)
    21  	}
    22  	got, err := os.ReadFile("lockrank.go")
    23  	if err != nil {
    24  		t.Fatal(err)
    25  	}
    26  	if !bytes.Equal(want, got) {
    27  		t.Fatalf("lockrank.go is out of date. Please run go generate.")
    28  	}
    29  }
    30  

View as plain text