From e09eb8c4e72159015374a1883473de0ba342385c Mon Sep 17 00:00:00 2001 From: Prathamesh Zarkar <159782310+prathameshzarkar9@users.noreply.github.com> Date: Wed, 11 Sep 2024 15:41:51 +0000 Subject: [PATCH] test added to validate the changes of zshrc fix --- src/common-utils/main.sh | 4 +--- test/common-utils/devcontainer-ruby-zshrc.sh | 12 ++++++++++++ .../devcontainer-ruby-zshrc/Dockerfile | 4 ++++ test/common-utils/scenarios.json | 18 ++++++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 test/common-utils/devcontainer-ruby-zshrc.sh create mode 100644 test/common-utils/devcontainer-ruby-zshrc/Dockerfile diff --git a/src/common-utils/main.sh b/src/common-utils/main.sh index 670e0c2d2..b5fe11f57 100644 --- a/src/common-utils/main.sh +++ b/src/common-utils/main.sh @@ -551,9 +551,7 @@ if [ "${INSTALL_ZSH}" = "true" ]; then # Add devcontainer .zshrc template if [ "$INSTALL_OH_MY_ZSH_CONFIG" = "true" ]; then - if [ -f "${template_path}" ] && grep -qF "$(head -n 1 "${template_path}")" "${user_rc_file}"; then - echo "No need to overwrite existing .zshrc file with the template file." - else + if ! [ -f "${template_path}" ] || ! grep -qF "$(head -n 1 "${template_path}")" "${user_rc_file}"; then echo -e "$(cat "${template_path}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${user_rc_file} fi sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="devcontainers"/g' ${user_rc_file} diff --git a/test/common-utils/devcontainer-ruby-zshrc.sh b/test/common-utils/devcontainer-ruby-zshrc.sh new file mode 100644 index 000000000..9e7b26e4c --- /dev/null +++ b/test/common-utils/devcontainer-ruby-zshrc.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +check "configure-zshrc-without-overwrite" bash -c "grep 'rbenv init -' ~/.zshrc" + +# Report result +reportResults diff --git a/test/common-utils/devcontainer-ruby-zshrc/Dockerfile b/test/common-utils/devcontainer-ruby-zshrc/Dockerfile new file mode 100644 index 000000000..67cabf907 --- /dev/null +++ b/test/common-utils/devcontainer-ruby-zshrc/Dockerfile @@ -0,0 +1,4 @@ +FROM mcr.microsoft.com/devcontainers/ruby:3.2 + +RUN echo 'eval "$(rbenv init -)"' >> /home/vscode/.zshrc + diff --git a/test/common-utils/scenarios.json b/test/common-utils/scenarios.json index e5529ea04..a929f534a 100644 --- a/test/common-utils/scenarios.json +++ b/test/common-utils/scenarios.json @@ -235,6 +235,24 @@ } } }, + "devcontainer-ruby-zshrc": { + "build": { + "dockerfile": "Dockerfile" + }, + "remoteUser": "vscode", + "features": { + "common-utils": { + "installZsh": true, + "username": "vscode", + "userUid": "1000", + "userGid": "1000", + "upgradePackages": true, + "installOhMyZsh": true, + "installOhMyZshConfig": true, + "configureZshAsDefaultShell": true + } + } + }, "alpine-base-zsh-default": { "image": "mcr.microsoft.com/devcontainers/base:alpine", "remoteUser": "vscode",