Skip to content

Commit e021a0b

Browse files
test added to validate the changes of zshrc fix
1 parent 1d3efab commit e021a0b

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

src/common-utils/main.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,7 @@ if [ "${INSTALL_ZSH}" = "true" ]; then
551551

552552
# Add devcontainer .zshrc template
553553
if [ "$INSTALL_OH_MY_ZSH_CONFIG" = "true" ]; then
554-
if [ -f "${template_path}" ] && grep -qF "$(head -n 1 "${template_path}")" "${user_rc_file}"; then
555-
echo "No need to overwrite existing .zshrc file with the template file."
556-
else
554+
if ! [ -f "${template_path}" ] || ! grep -qF "$(head -n 1 "${template_path}")" "${user_rc_file}"; then
557555
echo -e "$(cat "${template_path}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${user_rc_file}
558556
fi
559557
sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="devcontainers"/g' ${user_rc_file}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library
6+
source dev-container-features-test-lib
7+
8+
# Definition specific tests
9+
check "configure-zshrc-without-overwrite" bash -c "grep 'rbenv init -' ~/.zshrc"
10+
11+
# Report result
12+
reportResults
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM mcr.microsoft.com/devcontainers/ruby:3.2
2+
3+
RUN echo 'eval "$(rbenv init -)"' >> /home/vscode/.zshrc
4+

test/common-utils/scenarios.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,24 @@
235235
}
236236
}
237237
},
238+
"devcontainer-ruby-zshrc": {
239+
"build": {
240+
"dockerfile": "Dockerfile"
241+
},
242+
"remoteUser": "vscode",
243+
"features": {
244+
"common-utils": {
245+
"installZsh": true,
246+
"username": "vscode",
247+
"userUid": "1000",
248+
"userGid": "1000",
249+
"upgradePackages": true,
250+
"installOhMyZsh": true,
251+
"installOhMyZshConfig": true,
252+
"configureZshAsDefaultShell": true
253+
}
254+
}
255+
},
238256
"alpine-base-zsh-default": {
239257
"image": "mcr.microsoft.com/devcontainers/base:alpine",
240258
"remoteUser": "vscode",

0 commit comments

Comments
 (0)