github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/go/internal/script/scripttest/scripttest.go (about)

     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 scripttest adapts the script engine for use in tests.
     6  package scripttest
     7  
     8  import (
     9  	"github.com/shogo82148/std/cmd/go/internal/script"
    10  	"github.com/shogo82148/std/io"
    11  	"github.com/shogo82148/std/testing"
    12  )
    13  
    14  // DefaultCmds returns a set of broadly useful script commands.
    15  //
    16  // This set includes all of the commands in script.DefaultCmds,
    17  // as well as a "skip" command that halts the script and causes the
    18  // testing.TB passed to Run to be skipped.
    19  func DefaultCmds() map[string]script.Cmd
    20  
    21  // DefaultConds returns a set of broadly useful script conditions.
    22  //
    23  // This set includes all of the conditions in script.DefaultConds,
    24  // as well as:
    25  //
    26  //   - Conditions of the form "exec:foo" are active when the executable "foo" is
    27  //     found in the test process's PATH, and inactive when the executable is
    28  //     not found.
    29  //
    30  //   - "short" is active when testing.Short() is true.
    31  //
    32  //   - "verbose" is active when testing.Verbose() is true.
    33  func DefaultConds() map[string]script.Cond
    34  
    35  // Run runs the script from the given filename starting at the given initial state.
    36  // When the script completes, Run closes the state.
    37  func Run(t testing.TB, e *script.Engine, s *script.State, filename string, testScript io.Reader)
    38  
    39  // Skip returns a sentinel error that causes Run to mark the test as skipped.
    40  func Skip() script.Cmd
    41  
    42  // CachedExec returns a Condition that reports whether the PATH of the test
    43  // binary itself (not the script's current environment) contains the named
    44  // executable.
    45  func CachedExec() script.Cond