Documentation ¶
Index ¶
- Constants
- Variables
- func QuoteCommand(shell Shell, args ...string) string
- func RunningOnCI() bool
- type Dirs
- type Session
- func (s *Session) ClearCache() error
- func (s *Session) Close() error
- func (s *Session) CommitID() string
- func (s *Session) CopyExeToDir(from, to string) string
- func (s *Session) DebugLogs() map[string]string
- func (s *Session) DebugLogsDump() string
- func (s *Session) DebugMessage(prefix string) string
- func (s *Session) DeleteUUIDProjects(org string)
- func (s *Session) ExecutablePath() string
- func (s *Session) IgnoreLogErrors()
- func (s *Session) InstallerLog() string
- func (s *Session) LogFiles() []string
- func (s *Session) LoginAsPersistentUser()
- func (s *Session) LogoutUser()
- func (s *Session) NotifyProjectCreated(org, name string)
- func (s *Session) PrepareActiveStateYAML(contents string)
- func (s *Session) PrepareBuildScript(contents string)
- func (s *Session) PrepareCommitIdFile(commitID string)
- func (s *Session) PrepareEmptyProject()
- func (s *Session) PrepareFile(path, contents string)
- func (s *Session) PrepareProject(namespace, commitID string)
- func (s *Session) PrepareProjectAndBuildScript(namespace, commitID string)
- func (s *Session) SetT(t *testing.T)
- func (s *Session) SetupRCFile()
- func (s *Session) SetupRCFileCustom(subshell subshell.SubShell)
- func (s *Session) Spawn(args ...string) *SpawnedCmd
- func (s *Session) SpawnCmd(cmdName string, args ...string) *SpawnedCmd
- func (s *Session) SpawnCmdWithOpts(exe string, optSetters ...SpawnOptSetter) *SpawnedCmd
- func (s *Session) SpawnDebuggerWithOpts(opts ...SpawnOptSetter) *SpawnedCmd
- func (s *Session) SpawnShellWithOpts(shell Shell, opts ...SpawnOptSetter) *SpawnedCmd
- func (s *Session) SpawnWithOpts(opts ...SpawnOptSetter) *SpawnedCmd
- func (s *Session) SvcLog() string
- type Shell
- type SpawnOptSetter
- type SpawnOpts
- type SpawnedCmd
- func (s *SpawnedCmd) Executable() string
- func (s *SpawnedCmd) ExpectInput(opts ...termtest.SetExpectOpt) error
- func (s *SpawnedCmd) ExpectRe(v string, opts ...termtest.SetExpectOpt) error
- func (s *SpawnedCmd) Send(value string) error
- func (s *SpawnedCmd) SendEnter() error
- func (s *SpawnedCmd) SendKeyDown() error
- func (s *SpawnedCmd) SendKeyLeft() error
- func (s *SpawnedCmd) SendKeyRight() error
- func (s *SpawnedCmd) SendKeyUp() error
- func (s *SpawnedCmd) SendLine(value string) error
- func (s *SpawnedCmd) StrippedSnapshot() string
- func (s *SpawnedCmd) Wait() error
- func (s *SpawnedCmd) WorkDirectory() string
Constants ¶
const ( Bash Shell = "bash" Zsh = "zsh" Tcsh = "tcsh" Fish = "fish" Cmd = "cmd.exe" )
const CommitIDNotChecked = "00000000-0000-0000-0000-000000000000"
CommitIDNotChecked is to satisfy state tool requiring commit ID's, while also making explicit that this test does not test anything related to commit ID's.
const RuntimeBuildSourcingTimeout = 6 * time.Minute
Variables ¶
var ( RuntimeSolvingTimeoutOpt = termtest.OptExpectTimeout(90 * time.Second) RuntimeSourcingTimeoutOpt = termtest.OptExpectTimeout(3 * time.Minute) RuntimeBuildSourcingTimeoutOpt = termtest.OptExpectTimeout(RuntimeBuildSourcingTimeout) )
Functions ¶
func QuoteCommand ¶
QuoteCommand constructs and returns a command line string from the given list of arguments. The returned string can be passed to the given shell for evaluation.
func RunningOnCI ¶
func RunningOnCI() bool
Types ¶
type Dirs ¶
type Dirs struct { Base string // Config is where configuration files are stored Config string // Cache is the directory where cached files including downloaded artifacts are stored Cache string // Bin is the directory where executables are stored Bin string // Work is the working directory where the activestate.yaml file would live, and that is the PWD for tested console processes Work string // DefaultBin is the bin directory for our default installation DefaultBin string // SockRoot is the directory for the state service's socket file SockRoot string // HomeDir is used as the test user's home directory HomeDir string // TempDir is the directory where temporary files are stored TempDir string }
Dirs represents directories that are temporarily created for this end-to-end testing session
type Session ¶
type Session struct { Dirs *Dirs Env []string T *testing.T Exe string SvcExe string ExecutorExe string // contains filtered or unexported fields }
Session represents an end-to-end testing session during which several console process can be spawned and tested It provides a consistent environment (environment variables and temporary directories) that is shared by processes spawned during this session. The session is approximately the equivalent of a terminal session, with the main difference processes in this session are not spawned by a shell.
func NewNoPathUpdate ¶
func (*Session) ClearCache ¶
func (*Session) CommitID ¶
CommitID is used to grab the current commit ID for the project in our working directory. For integration tests you should use this function instead of localcommit.Get() and pjfile.LegacyCommitID() as it is guaranteed to give a fresh result from disk, whereas the ones above use caching which tests don't like.
func (*Session) CopyExeToDir ¶
func (*Session) DebugLogsDump ¶
func (*Session) DebugMessage ¶
func (*Session) DeleteUUIDProjects ¶
DeleteUUIDProjects indicates that all projects with UUID names (i.e. autogenerated) for the given org should be deleted when the session is closed. This should not be called from generic integration tests. Use NotifyProjectCreated() instead, because there could be race conditions if multiple platforms are creating and using UUID projects.
func (*Session) ExecutablePath ¶
ExecutablePath returns the path to the state tool that we want to test
func (*Session) IgnoreLogErrors ¶
func (s *Session) IgnoreLogErrors()
IgnoreLogErrors disables log error checking after the session closes. Normally, logged errors automatically cause test failures, so calling this is needed for tests with expected errors.
func (*Session) InstallerLog ¶
func (*Session) LoginAsPersistentUser ¶
func (s *Session) LoginAsPersistentUser()
LoginAsPersistentUser is a common test case after which an integration test user should be logged in to the platform
func (*Session) LogoutUser ¶
func (s *Session) LogoutUser()
func (*Session) NotifyProjectCreated ¶
NotifyProjectCreated indicates that the given project was created on the Platform and needs to be deleted when the session is closed.
func (*Session) PrepareActiveStateYAML ¶
PrepareActiveStateYAML creates an activestate.yaml in the session's work directory from the given YAML contents.
func (*Session) PrepareBuildScript ¶
func (*Session) PrepareCommitIdFile ¶
func (*Session) PrepareEmptyProject ¶
func (s *Session) PrepareEmptyProject()
PrepareEmptyProject creates a checkout of the empty ActiveState-CLI/Empty project without using `state checkout`.
func (*Session) PrepareFile ¶
PrepareFile writes a file to path with contents, expecting no error
func (*Session) PrepareProject ¶
PrepareProject creates a very simple activestate.yaml file for the given org/project and, if a commit ID is given, an .activestate/commit file.
func (*Session) PrepareProjectAndBuildScript ¶
func (*Session) SetupRCFile ¶
func (s *Session) SetupRCFile()
func (*Session) SetupRCFileCustom ¶
func (*Session) Spawn ¶
func (s *Session) Spawn(args ...string) *SpawnedCmd
Spawn spawns the state tool executable to be tested with arguments
func (*Session) SpawnCmd ¶
func (s *Session) SpawnCmd(cmdName string, args ...string) *SpawnedCmd
SpawnCmd executes an executable in a pseudo-terminal for integration tests
func (*Session) SpawnCmdWithOpts ¶
func (s *Session) SpawnCmdWithOpts(exe string, optSetters ...SpawnOptSetter) *SpawnedCmd
SpawnCmdWithOpts executes an executable in a pseudo-terminal for integration tests Arguments and other parameters can be specified by specifying SpawnOptSetter
func (*Session) SpawnDebuggerWithOpts ¶
func (s *Session) SpawnDebuggerWithOpts(opts ...SpawnOptSetter) *SpawnedCmd
SpawnDebuggerWithOpts will spawn a state tool command with the dlv debugger in remote debugging port. It uses the default dlv port of `2345`. It has been tested in Goland (intellij), see instructions here: https://www.jetbrains.com/help/go/attach-to-running-go-processes-with-debugger.html#step-3-create-the-remote-run-debug-configuration-on-the-client-computer Note remote debugging seems a bit unreliable. I've found it works best to start the test code first, and once it is running then start the remote debugger. When I launch the remote debugger first it often doesn't take. But even when using this trickery it may at times not work; try restarting goland, your machine, or dlv.
func (*Session) SpawnShellWithOpts ¶
func (s *Session) SpawnShellWithOpts(shell Shell, opts ...SpawnOptSetter) *SpawnedCmd
SpawnShellWithOpts spawns the given shell and options in interactive mode.
func (*Session) SpawnWithOpts ¶
func (s *Session) SpawnWithOpts(opts ...SpawnOptSetter) *SpawnedCmd
SpawnWithOpts spawns the state tool executable to be tested with arguments
type SpawnOptSetter ¶
type SpawnOptSetter func(opts *SpawnOpts)
func OptAppendEnv ¶
func OptAppendEnv(env ...string) SpawnOptSetter
func OptArgs ¶
func OptArgs(args ...string) SpawnOptSetter
func OptHideArgs ¶
func OptHideArgs() SpawnOptSetter
func OptRunInsideShell ¶
func OptRunInsideShell(v bool) SpawnOptSetter
func OptTermTest ¶
func OptTermTest(opt ...termtest.SetOpt) SpawnOptSetter
func OptWD ¶
func OptWD(wd string) SpawnOptSetter
type SpawnOpts ¶
type SpawnOpts struct { Args []string Env []string Dir string TermtestOpts []termtest.SetOpt HideCmdArgs bool RunInsideShell bool }
func NewSpawnOpts ¶
func NewSpawnOpts() SpawnOpts
type SpawnedCmd ¶
func (*SpawnedCmd) Executable ¶
func (s *SpawnedCmd) Executable() string
func (*SpawnedCmd) ExpectInput ¶
func (s *SpawnedCmd) ExpectInput(opts ...termtest.SetExpectOpt) error
func (*SpawnedCmd) ExpectRe ¶
func (s *SpawnedCmd) ExpectRe(v string, opts ...termtest.SetExpectOpt) error
ExpectRe takes a string rather than an already compiled regex, so that we can handle regex compilation failures through our error handling chain rather than have it fail on eg. a panic through regexp.MustCompile, or needing to manually error check it before sending it to ExpectRe.
func (*SpawnedCmd) Send ¶
func (s *SpawnedCmd) Send(value string) error
func (*SpawnedCmd) SendEnter ¶
func (s *SpawnedCmd) SendEnter() error
func (*SpawnedCmd) SendKeyDown ¶
func (s *SpawnedCmd) SendKeyDown() error
func (*SpawnedCmd) SendKeyLeft ¶
func (s *SpawnedCmd) SendKeyLeft() error
func (*SpawnedCmd) SendKeyRight ¶
func (s *SpawnedCmd) SendKeyRight() error
func (*SpawnedCmd) SendKeyUp ¶
func (s *SpawnedCmd) SendKeyUp() error
func (*SpawnedCmd) SendLine ¶
func (s *SpawnedCmd) SendLine(value string) error
func (*SpawnedCmd) StrippedSnapshot ¶
func (s *SpawnedCmd) StrippedSnapshot() string
StrippedSnapshot returns the snapshot with trimmed whitespace and stripped line endings Mainly intended for JSON parsing
func (*SpawnedCmd) Wait ¶
func (s *SpawnedCmd) Wait() error
func (*SpawnedCmd) WorkDirectory ¶
func (s *SpawnedCmd) WorkDirectory() string