Skip to content

Commit

Permalink
Document globalFlags and globalState
Browse files Browse the repository at this point in the history
  • Loading branch information
na-- committed Mar 7, 2022
1 parent 5e14510 commit 55cd43d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const (
waitRemoteLoggerTimeout = time.Second * 5
)

// globalFlags contains global config values that apply for all k6 sub-commands.
type globalFlags struct {
configFilePath string
runType string
Expand All @@ -64,6 +65,19 @@ type globalFlags struct {
verbose bool
}

// globalState contains the globalFlags and accessors for most of the global
// process-external like CLI arguments, env vars, standard input, output and
// error, etc. In practice, most of it is normally accessed through the `os`
// package from the Go stdlib.
//
// We group them here so we can prevent direct access to them from the rest of
// the k6 codebase. This gives us the ability to mock them and have robust and
// easy-to-write integration-like tests to check the k6 end-to-end behavior in
// any simulated conditions.
//
// `newGlobalState()` returns a globalState object with the real `os`
// parameters, while `newGlobalTestState()` can be used in tests to create
// simulated environments.
type globalState struct {
ctx context.Context

Expand Down

0 comments on commit 55cd43d

Please sign in to comment.