modernc.org/xdmcp@v1.0.17/all_test.go (about)

     1  // Copyright 2021 The Xdmcp-Go Authors. All rights reserved.
     2  // Use of the source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package xdmcp // import "modernc.org/xdmcp"
     6  
     7  import (
     8  	"fmt"
     9  	"os"
    10  	"path"
    11  	"runtime"
    12  	"runtime/debug"
    13  	"strings"
    14  	"testing"
    15  
    16  	"modernc.org/ccgo/v3/lib"
    17  )
    18  
    19  func caller(s string, va ...interface{}) {
    20  	if s == "" {
    21  		s = strings.Repeat("%v ", len(va))
    22  	}
    23  	_, fn, fl, _ := runtime.Caller(2)
    24  	fmt.Fprintf(os.Stderr, "# caller: %s:%d: ", path.Base(fn), fl)
    25  	fmt.Fprintf(os.Stderr, s, va...)
    26  	fmt.Fprintln(os.Stderr)
    27  	_, fn, fl, _ = runtime.Caller(1)
    28  	fmt.Fprintf(os.Stderr, "# \tcallee: %s:%d: ", path.Base(fn), fl)
    29  	fmt.Fprintln(os.Stderr)
    30  	os.Stderr.Sync()
    31  }
    32  
    33  func dbg(s string, va ...interface{}) {
    34  	if s == "" {
    35  		s = strings.Repeat("%v ", len(va))
    36  	}
    37  	_, fn, fl, _ := runtime.Caller(1)
    38  	fmt.Fprintf(os.Stderr, "# dbg %s:%d: ", path.Base(fn), fl)
    39  	fmt.Fprintf(os.Stderr, s, va...)
    40  	fmt.Fprintln(os.Stderr)
    41  	os.Stderr.Sync()
    42  }
    43  
    44  func TODO(...interface{}) string { //TODOOK
    45  	_, fn, fl, _ := runtime.Caller(1)
    46  	return fmt.Sprintf("# TODO: %s:%d:\n", path.Base(fn), fl) //TODOOK
    47  }
    48  
    49  func stack() string { return string(debug.Stack()) }
    50  
    51  func use(...interface{}) {}
    52  
    53  func init() {
    54  	use(caller, dbg, TODO, stack) //TODOOK
    55  }
    56  
    57  // ----------------------------------------------------------------------------
    58  
    59  func Test(t *testing.T) {
    60  	if _, err := ccgo.Shell("go", "run", fmt.Sprintf("./internal/test/main_%s_%s.go", runtime.GOOS, runtime.GOARCH)); err != nil {
    61  		t.Fatal(err)
    62  	}
    63  }