...

Text file src/cmd/go/testdata/script/test_source_order.txt

Documentation: cmd/go/testdata/script

     1[short] skip
     2
     3# Control
     4! go test example2_test.go example1_test.go
     5
     6# This test only passes if the source order is preserved
     7go test example1_test.go example2_test.go
     8
     9-- example1_test.go --
    10// Copyright 2013 The Go Authors. All rights reserved.
    11// Use of this source code is governed by a BSD-style
    12// license that can be found in the LICENSE file.
    13
    14// Make sure that go test runs Example_Z before Example_A, preserving source order.
    15
    16package p
    17
    18import "fmt"
    19
    20var n int
    21
    22func Example_Z() {
    23	n++
    24	fmt.Println(n)
    25	// Output: 1
    26}
    27
    28func Example_A() {
    29	n++
    30	fmt.Println(n)
    31	// Output: 2
    32}
    33-- example2_test.go --
    34// Copyright 2013 The Go Authors. All rights reserved.
    35// Use of this source code is governed by a BSD-style
    36// license that can be found in the LICENSE file.
    37
    38// Make sure that go test runs Example_Y before Example_B, preserving source order.
    39
    40package p
    41
    42import "fmt"
    43
    44func Example_Y() {
    45	n++
    46	fmt.Println(n)
    47	// Output: 3
    48}
    49
    50func Example_B() {
    51	n++
    52	fmt.Println(n)
    53	// Output: 4
    54}

View as plain text