-
Notifications
You must be signed in to change notification settings - Fork 265
Add shellrc tests for unified env #660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,11 +15,24 @@ import ( | |
var update = flag.Bool("update", false, "update the golden files with the test results") | ||
|
||
func TestWriteDevboxShellrc(t *testing.T) { | ||
os.Setenv("DEVBOX_FEATURE_UNIFIED_ENV", "0") | ||
testdirs, err := filepath.Glob("testdata/shellrc/*") | ||
if err != nil { | ||
t.Fatal("Error globbing testdata:", err) | ||
} | ||
testWriteDevboxShellrc(t, testdirs) | ||
} | ||
|
||
func TestWriteDevboxShellrcWithUnifiedEnv(t *testing.T) { | ||
os.Setenv("DEVBOX_FEATURE_UNIFIED_ENV", "1") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here as well |
||
testdirs, err := filepath.Glob("testdata/shellrc_unifiedenv/*") | ||
if err != nil { | ||
t.Fatal("Error globbing testdata:", err) | ||
} | ||
testWriteDevboxShellrc(t, testdirs) | ||
} | ||
|
||
func testWriteDevboxShellrc(t *testing.T, testdirs []string) { | ||
// Load up all the necessary data from each testdata/shellrc directory | ||
// into a slice of tests cases. | ||
tests := make([]struct { | ||
|
@@ -29,6 +42,7 @@ func TestWriteDevboxShellrc(t *testing.T) { | |
goldShellrcPath string | ||
goldShellrc []byte | ||
}, len(testdirs)) | ||
var err error | ||
for i, path := range testdirs { | ||
test := &tests[i] | ||
test.name = filepath.Base(path) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
echo "Hello from a devbox shell hook!" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Set up the prompt | ||
|
||
autoload -Uz promptinit | ||
promptinit | ||
#prompt adam1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove? |
||
|
||
setopt histignorealldups sharehistory | ||
|
||
# Use emacs keybindings even if our EDITOR is set to vi | ||
bindkey -e | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this means war |
||
|
||
# Keep 1000 lines of history within the shell and save it to ~/.zsh_history: | ||
HISTSIZE=1000 | ||
SAVEHIST=1000 | ||
HISTFILE=~/.zsh_history | ||
|
||
# Use modern completion system | ||
autoload -Uz compinit | ||
compinit | ||
|
||
zstyle ':completion:*' auto-description 'specify: %d' | ||
zstyle ':completion:*' completer _expand _complete _correct _approximate | ||
zstyle ':completion:*' format 'Completing %d' | ||
zstyle ':completion:*' group-name '' | ||
zstyle ':completion:*' menu select=2 | ||
eval "$(dircolors -b)" | ||
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} | ||
zstyle ':completion:*' list-colors '' | ||
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s | ||
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*' | ||
zstyle ':completion:*' menu select=long | ||
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s | ||
zstyle ':completion:*' use-compctl false | ||
zstyle ':completion:*' verbose true | ||
|
||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' | ||
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Run the shell hook defined in shell.nix or flake.nix | ||
eval $shellHook | ||
|
||
# Begin testdata/shellrc_unifiedenv/basic/shellrc | ||
|
||
# Set up the prompt | ||
|
||
autoload -Uz promptinit | ||
promptinit | ||
#prompt adam1 | ||
|
||
setopt histignorealldups sharehistory | ||
|
||
# Use emacs keybindings even if our EDITOR is set to vi | ||
bindkey -e | ||
|
||
# Keep 1000 lines of history within the shell and save it to ~/.zsh_history: | ||
HISTSIZE=1000 | ||
SAVEHIST=1000 | ||
HISTFILE=~/.zsh_history | ||
|
||
# Use modern completion system | ||
autoload -Uz compinit | ||
compinit | ||
|
||
zstyle ':completion:*' auto-description 'specify: %d' | ||
zstyle ':completion:*' completer _expand _complete _correct _approximate | ||
zstyle ':completion:*' format 'Completing %d' | ||
zstyle ':completion:*' group-name '' | ||
zstyle ':completion:*' menu select=2 | ||
eval "$(dircolors -b)" | ||
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} | ||
zstyle ':completion:*' list-colors '' | ||
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s | ||
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*' | ||
zstyle ':completion:*' menu select=long | ||
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s | ||
zstyle ':completion:*' use-compctl false | ||
zstyle ':completion:*' verbose true | ||
|
||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' | ||
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' | ||
|
||
# End testdata/shellrc_unifiedenv/basic/shellrc | ||
|
||
# Begin Devbox Post-init Hook | ||
|
||
PATH="$DEVBOX_PATH_PREPEND:$PATH" | ||
|
||
# Prepend to the prompt to make it clear we're in a devbox shell. | ||
export PS1="(devbox) $PS1" | ||
|
||
# End Devbox Post-init Hook | ||
|
||
# Switch to the directory where devbox.json config is | ||
workingDir=$(pwd) | ||
cd path/to/projectDir | ||
|
||
# Begin Plugin Init Hook | ||
|
||
echo "Welcome to the devbox!" | ||
|
||
# End Plugin Init Hook | ||
|
||
# Begin Devbox User Hook | ||
|
||
echo "Hello from a devbox shell hook!" | ||
|
||
# End Devbox User Hook | ||
|
||
cd $workingDir | ||
|
||
# Begin Script command | ||
|
||
# End Script command |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PATH=/a/test/path | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is this value used? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Set up the prompt | ||
|
||
autoload -Uz promptinit | ||
promptinit | ||
#prompt adam1 | ||
|
||
setopt histignorealldups sharehistory | ||
|
||
# Use emacs keybindings even if our EDITOR is set to vi | ||
bindkey -e | ||
|
||
# Keep 1000 lines of history within the shell and save it to ~/.zsh_history: | ||
HISTSIZE=1000 | ||
SAVEHIST=1000 | ||
HISTFILE=~/.zsh_history | ||
|
||
# Use modern completion system | ||
autoload -Uz compinit | ||
compinit | ||
|
||
zstyle ':completion:*' auto-description 'specify: %d' | ||
zstyle ':completion:*' completer _expand _complete _correct _approximate | ||
zstyle ':completion:*' format 'Completing %d' | ||
zstyle ':completion:*' group-name '' | ||
zstyle ':completion:*' menu select=2 | ||
eval "$(dircolors -b)" | ||
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} | ||
zstyle ':completion:*' list-colors '' | ||
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s | ||
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*' | ||
zstyle ':completion:*' menu select=long | ||
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s | ||
zstyle ':completion:*' use-compctl false | ||
zstyle ':completion:*' verbose true | ||
|
||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' | ||
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Run the shell hook defined in shell.nix or flake.nix | ||
eval $shellHook | ||
|
||
# Begin testdata/shellrc_unifiedenv/nohook/shellrc | ||
|
||
# Set up the prompt | ||
|
||
autoload -Uz promptinit | ||
promptinit | ||
#prompt adam1 | ||
|
||
setopt histignorealldups sharehistory | ||
|
||
# Use emacs keybindings even if our EDITOR is set to vi | ||
bindkey -e | ||
|
||
# Keep 1000 lines of history within the shell and save it to ~/.zsh_history: | ||
HISTSIZE=1000 | ||
SAVEHIST=1000 | ||
HISTFILE=~/.zsh_history | ||
|
||
# Use modern completion system | ||
autoload -Uz compinit | ||
compinit | ||
|
||
zstyle ':completion:*' auto-description 'specify: %d' | ||
zstyle ':completion:*' completer _expand _complete _correct _approximate | ||
zstyle ':completion:*' format 'Completing %d' | ||
zstyle ':completion:*' group-name '' | ||
zstyle ':completion:*' menu select=2 | ||
eval "$(dircolors -b)" | ||
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} | ||
zstyle ':completion:*' list-colors '' | ||
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s | ||
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*' | ||
zstyle ':completion:*' menu select=long | ||
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s | ||
zstyle ':completion:*' use-compctl false | ||
zstyle ':completion:*' verbose true | ||
|
||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' | ||
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' | ||
|
||
# End testdata/shellrc_unifiedenv/nohook/shellrc | ||
|
||
# Begin Devbox Post-init Hook | ||
|
||
PATH="$DEVBOX_PATH_PREPEND:$PATH" | ||
|
||
# Prepend to the prompt to make it clear we're in a devbox shell. | ||
export PS1="(devbox) $PS1" | ||
|
||
# End Devbox Post-init Hook | ||
|
||
# Switch to the directory where devbox.json config is | ||
workingDir=$(pwd) | ||
cd path/to/projectDir | ||
|
||
# Begin Plugin Init Hook | ||
|
||
echo "Welcome to the devbox!" | ||
|
||
# End Plugin Init Hook | ||
|
||
cd $workingDir | ||
|
||
# Begin Script command | ||
|
||
# End Script command |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PATH=/a/test/path |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
echo "Hello from a devbox shell hook!" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Run the shell hook defined in shell.nix or flake.nix | ||
eval $shellHook | ||
|
||
# Begin Devbox Post-init Hook | ||
|
||
PATH="$DEVBOX_PATH_PREPEND:$PATH" | ||
|
||
# Prepend to the prompt to make it clear we're in a devbox shell. | ||
export PS1="(devbox) $PS1" | ||
|
||
# End Devbox Post-init Hook | ||
|
||
# Switch to the directory where devbox.json config is | ||
workingDir=$(pwd) | ||
cd path/to/projectDir | ||
|
||
# Begin Plugin Init Hook | ||
|
||
echo "Welcome to the devbox!" | ||
|
||
# End Plugin Init Hook | ||
|
||
# Begin Devbox User Hook | ||
|
||
echo "Hello from a devbox shell hook!" | ||
|
||
# End Devbox User Hook | ||
|
||
cd $workingDir | ||
|
||
# Begin Script command | ||
|
||
# End Script command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want
t.Setenv
https://pkg.go.dev/testing#T.Setenv