func TestCommand_exec_helper(*testing.T) {
	if os.Getenv("TUSK_WANT_TEST_COMMAND") != "1" {
		return
	}
	defer os.Exit(0)

	fail := func(msg interface{}) {
		fmt.Fprintln(os.Stderr, msg)
		os.Exit(1)
	}

	wantArgs := strings.Split(os.Getenv("TUSK_TEST_COMMAND_ARGS"), ",")
	args := os.Args
	for len(args) > 0 {
		if args[0] == "--" {
			args = args[1:]
			break
		}
		args = args[1:]
	}

	if diff := cmp.Diff(wantArgs, args); diff != "" {
		fail("arguments differ:\n" + diff)
	}

	dir, err := os.Getwd()
	if err != nil {
		fail("failed to get working dir: " + err.Error())
	}

	wantDir := os.Getenv("TUSK_TEST_COMMAND_DIR")
	if wantDir != "" && dir != wantDir {
		fail(fmt.Sprintf("want working dir %s, got %s", wantDir, dir))
	}
}
// TestCommand_exec_helper is a helper test that is called when mocking exec.
//
// The following environment variables can configure this function:
//
// - TUSK_WANT_TEST_COMMAND: Set to "1" to run this function.
// - TUSK_TEST_COMMAND_ARGS: Set to a comma-separated list of expected command
//   arguments.
// - TUSK_TEST_COMMAND_DIR: Set to the expected directory
TestCommand_exec_helper is a helper test that is called when mocking exec.

The following environment variables can configure this function.

- TUSK_WANT_TEST_COMMAND: Set to "1" to run this function.
- TUSK_TEST_COMMAND_ARGS: Set to a comma-separated list of expected command
arguments.
- TUSK_TEST_COMMAND_DIR: Set to the expected directory
// TestCommand_exec_helper is a helper test that is called when mocking exec . // // The following environment variables can configure this function : // // - TUSK_WANT_TEST_COMMAND : Set to " 1 " to run this function . // - TUSK_TEST_COMMAND_ARGS : Set to a comma - separated list of expected command // arguments . // - TUSK_TEST_COMMAND_DIR : Set to the expected directory
func TestCommand_exec_helper(*testing.T) {
	if os.Getenv("TUSK_WANT_TEST_COMMAND") != "1" {
		return
	}
	defer os.Exit(0)
	fail := func(msg interface{}) {
		fmt.Fprintln(os.Stderr, msg)
		os.Exit(1)
	}
	wantArgs := strings.Split(os.Getenv("TUSK_TEST_COMMAND_ARGS"), ",")
	args := os.Args
	for len(args) > 0 {
		if args[0] == "--" {
			args = args[1:]
			break
		}
		args = args[1:]
	}
	if diff := cmp.Diff(wantArgs, args); diff != "" {
		fail("arguments differ:\n" + diff)
	}
	dir, err := os.Getwd()
	if err != nil {
		fail("failed to get working dir: " + err.Error())
	}
	wantDir := os.Getenv("TUSK_TEST_COMMAND_DIR")
	if wantDir != "" && dir != wantDir {
		fail(fmt.Sprintf("want working dir %s, got %s", wantDir, dir))
	}
}
func TestCommand_exec_helper ( * testing . T ) { if os . Getenv ( " " ) != " " { return } defer os . Exit ( 0 ) fail := func ( msg interface { } ) { fmt . Fprintln ( os . Stderr , msg ) os . Exit ( 1 ) } wantArgs := strings . Split ( os . Getenv ( " " ) , " " ) args := os . Args for len ( args ) > 0 { if args [ 0 ] == " " { args = args [ 1 : ] break } args = args [ 1 : ] } if diff := cmp . Diff ( wantArgs , args ) ; diff != " " { fail ( " \n " + diff ) } dir , err := os . Getwd ( ) if err != nil { fail ( " " + err . Error ( ) ) } wantDir := os . Getenv ( " " ) if wantDir != " " && dir != wantDir { fail ( fmt . Sprintf ( " " , wantDir , dir ) ) } }
TestCommand_exec_helper is a helper test that is called when mocking exec.
TestCommand_exec_helper is a helper test that is called when mocking exec .