22# set -e
33# set -o pipefail
44
5- # Workaround to create license.agreement file and simulate a proper installation.
6- mkdir -p " ${HOME} " /.ide
7- touch " ${HOME} " /.ide/.license.agreement
8-
9- source " $( dirname " ${0} " ) " /all-tests-functions.sh
10-
11- # Remove side-effects
12- BAK_IDE_ROOT=" ${IDE_ROOT} "
13- BAK_PATH=" ${PATH} "
14- DEBUG_INTEGRATION_TEST_PREFIX=" ${HOME} /tmp/ideasy-integration-test-debug"
15-
16- # Create backups of shell RC files to prevent destroying user's existing configuration
17- BAK_BASHRC=" "
18- BAK_ZSHRC=" "
19- if [ -f " $HOME /.bashrc" ]; then
20- BAK_BASHRC=" $HOME /.bashrc.ideasy-test-backup"
21- cp " $HOME /.bashrc" " $BAK_BASHRC "
22- fi
23- if [ -f " $HOME /.zshrc" ]; then
24- BAK_ZSHRC=" $HOME /.zshrc.ideasy-test-backup"
25- cp " $HOME /.zshrc" " $BAK_ZSHRC "
26- fi
27-
28- trap " export PATH=\" ${BAK_PATH} \" && export IDE_ROOT=\" ${BAK_IDE_ROOT} \" && rm -rf \" ${DEBUG_INTEGRATION_TEST_PREFIX} \" && doRestoreRcFiles && echo \" PATH, IDE_ROOT, and shell RC files restored\" " EXIT
29-
305function doRestoreRcFiles() {
316 # Restore shell RC files from backups to preserve user's existing configuration
327 if [ -n " $BAK_BASHRC " ] && [ -f " $BAK_BASHRC " ]; then
@@ -40,30 +15,17 @@ function doRestoreRcFiles() {
4015}
4116
4217function doResetVariables() {
43- IDE_HOME=" ${DEBUG_INTEGRATION_TEST} /home-dir "
18+ IDE_HOME=" ${DEBUG_INTEGRATION_TEST} "
4419 export IDE_ROOT=" ${IDE_HOME} /projects"
4520 IDEASY_DIR=" ${IDE_ROOT} /_ide"
46- FUNCTIONS=" ${IDEASY_DIR} /installation/functions"
47- IDE=" ${DEBUG_INTEGRATION_TEST} /home-dir/projects/_ide/bin/${BINARY_FILE_NAME} "
21+ IDEASY_INSTALLATION_DIR=" ${IDEASY_DIR} /installation"
22+ FUNCTIONS=" ${IDEASY_INSTALLATION_DIR} /functions"
23+ IDEASY_RELEASE_DIR_RELATIVE=" software/maven/ideasy/ideasy/test"
24+ IDEASY_RELEASE_DIR=" ${IDEASY_DIR} /${IDEASY_RELEASE_DIR_RELATIVE} "
25+ IDE=" ${IDEASY_INSTALLATION_DIR} /bin/${BINARY_FILE_NAME} "
4826 TEST_RESULTS_FILE=" ${IDE_ROOT} /testResults"
4927}
5028
51- # Switch IDEasy binary file name based on github workflow matrix.os name (first argument of all-tests.sh)
52- BINARY_FILE_NAME=" ideasy"
53- if doIsWindows; then
54- BINARY_FILE_NAME=" ideasy.exe"
55- fi
56-
57- START_TIME=$( date ' +%Y-%m-%d_%H-%M-%S' )
58- DEBUG_INTEGRATION_TEST=" ${DEBUG_INTEGRATION_TEST_PREFIX} -${START_TIME} "
59- doResetVariables
60-
61- test_files_directory=$( realpath " $0 " | xargs dirname)
62-
63- success=0
64- failure=0
65- total=0
66-
6729function doTestsInner() {
6830 # Note: requires var test_files_directory to be set.
6931 for testpath in " ${test_files_directory:? } /integration-tests" /* ; do
@@ -118,60 +80,105 @@ function doTests () {
11880 exit 0
11981}
12082
121- function main () {
122- echo " Running integration tests from directory: ${test_files_directory} "
83+ # Workaround to create license.agreement file and simulate a proper installation.
84+ mkdir -p " ${HOME} " /.ide
85+ touch " ${HOME} " /.ide/.license.agreement
86+
87+ source " $( dirname " ${0} " ) " /all-tests-functions.sh
88+
89+ # Remove side-effects
90+ BAK_IDE_ROOT=" ${IDE_ROOT} "
91+ BAK_PATH=" ${PATH} "
92+ DEBUG_INTEGRATION_TEST=" ${HOME} /tmp/ideasy-integration-test-debug"
93+ if [ -e " ${DEBUG_INTEGRATION_TEST} " ]; then
94+ echo " Deleting previous test folder ${DEBUG_INTEGRATION_TEST} "
95+ rm -rf " ${DEBUG_INTEGRATION_TEST} "
96+ fi
97+ # Create backups of shell RC files to prevent destroying user's existing configuration
98+ BAK_BASHRC=" "
99+ BAK_ZSHRC=" "
100+ if [ -f " $HOME /.bashrc" ]; then
101+ BAK_BASHRC=" $HOME /.bashrc.ideasy-test-backup"
102+ cp " $HOME /.bashrc" " $BAK_BASHRC "
103+ fi
104+ if [ -f " $HOME /.zshrc" ]; then
105+ BAK_ZSHRC=" $HOME /.zshrc.ideasy-test-backup"
106+ cp " $HOME /.zshrc" " $BAK_ZSHRC "
107+ fi
108+
109+ trap " export PATH=\" ${BAK_PATH} \" && export IDE_ROOT=\" ${BAK_IDE_ROOT} \" && doRestoreRcFiles && echo \" PATH, IDE_ROOT, and shell RC files restored\" " EXIT
110+
111+ # Switch IDEasy binary file name based on github workflow matrix.os name (first argument of all-tests.sh)
112+ BINARY_FILE_NAME=" ideasy"
113+ if doIsWindows; then
114+ BINARY_FILE_NAME=" ideasy.exe"
115+ fi
116+
117+ doResetVariables
118+ test_files_directory=$( realpath " $0 " | xargs dirname)
119+
120+ success=0
121+ failure=0
122+ total=0
123+
124+ echo " Running integration tests from directory: ${test_files_directory} "
123125
124- # rm -rf "${DEBUG_INTEGRATION_TEST_PREFIX}"
125126 # Only need to mkdir once:
126127 echo " Creating IDEasy directory at: ${IDEASY_DIR} "
127128 mkdir -p " ${IDEASY_DIR} "
128129
129130 echo " Switching directory to: ${IDEASY_DIR} "
130131 cd " ${IDEASY_DIR} " || exit
131132
132- # Determine IDEasy release to use for testing (default: downloads latest release)
133- # NOTE: For debugging purposes, if you want to avoid download time, you can
134- # uncomment var snapshot, set it to a local compressed IDEasy release and
135- # give it to 'doDownloadSnapshot' as first argument..
136- local snapshot=" "
137- # snapshot="$HOME/tmp/downloads/ide-cli-2025.04.001-20250404.093145-4-linux-x64.tar.gz"
138- doDownloadSnapshot " ${snapshot} "
139- # Extract IDEasy and setup
140- doExtract
141-
142- # source ./bin/ide
143- echo " Switching directory to: ${IDE_ROOT} "
144- cd " ${IDE_ROOT} " || exit
145-
146- # upgrade to latest snapshot
147- echo " Upgrading IDEasy to latest SNAPSHOT"
148- $IDE -d --batch upgrade --mode=snapshot || echo " Upgrade failed, continuing with downloaded version"
149-
150- # source functions (resets IDEasy)
151- echo " Sourcing functions to: ${FUNCTIONS} "
152- # Add IDE bin to PATH so ideasy command can be found
153- export PATH=" ${IDEASY_DIR} /bin:$PATH "
154- # Try installation path first, then fall back to root
155- if [ -f " ${FUNCTIONS:? } " ]; then
156- source " ${FUNCTIONS:? } "
157- elif [ -f " ${IDEASY_DIR} /functions" ]; then
158- echo " Using functions from root: ${IDEASY_DIR} /functions"
159- source " ${IDEASY_DIR} /functions"
160- else
161- echo " ERROR: Could not find functions file"
162- exit 1
163- fi
133+ # Determine IDEasy release to use for testing (default: downloads latest release)
134+ # NOTE: For debugging purposes, if you want to avoid download time, you can
135+ # uncomment var snapshot, set it to a local compressed IDEasy release
136+ local_release=" "
137+ # snapshot="$HOME/tmp/downloads/ide-cli-2025.04.001-20250404.093145-4-linux-x64.tar.gz"
138+ doDownloadRelease " ${local_release} "
139+ # Extract IDEasy and setup
140+ mkdir -p " ${IDEASY_RELEASE_DIR} "
141+ echo " Extracting IDEasy archive ${IDEASY_COMPRESSED_FILE} to ${IDEASY_RELEASE_DIR} "
142+ tar xfz " ${IDEASY_COMPRESSED_FILE:? } " --directory " ${IDEASY_RELEASE_DIR} " || exit 1
143+ cd ${IDEASY_DIR}
144+ doCreateLink ${IDEASY_RELEASE_DIR_RELATIVE} installation
145+ # avoid cloning urls on every run in local execution
146+ IDE_URLS=" ${BAK_IDE_ROOT} /_ide/urls"
147+ if [ -d " ${IDE_URLS} " ]; then
148+ doCreateLink " $IDE_URLS " urls
149+ fi
164150
165- echo " Checking version after upgrade"
166- ide -v
151+ echo " Switching directory to: ${IDE_ROOT} "
152+ cd " ${IDE_ROOT} " || exit 1
153+
154+
155+ # upgrade to latest snapshot
156+ echo " Upgrading IDEasy to latest SNAPSHOT"
157+ $IDE -d --batch upgrade --mode=snapshot || exit 1 # echo "Upgrade failed, continuing with downloaded version"
158+
159+ # source functions (resets IDEasy)
160+ echo " Sourcing functions from: ${FUNCTIONS} "
161+ # Add IDE bin to PATH so ideasy command can be found
162+ export PATH=" ${IDEASY_DIR} /installation/bin:$PATH "
163+ # Try installation path first, then fall back to root
164+ if [ -f " ${FUNCTIONS:? } " ]; then
165+ source " ${FUNCTIONS:? } "
166+ elif [ -f " ${IDEASY_DIR} /functions" ]; then
167+ echo " Using functions from root: ${IDEASY_DIR} /functions"
168+ source " ${IDEASY_DIR} /functions"
169+ else
170+ echo " ERROR: Could not find functions file"
171+ exit 1
172+ fi
167173
168- doIdeCreate
174+ echo " Checking version after upgrade"
175+ which ideasy
176+ ide -v
169177
170- doTests
178+ doIdeCreate
171179
172- echo " DONE"
173- exit 0
174- }
180+ doTests
175181
176- main
182+ echo " DONE"
183+ exit 0
177184
0 commit comments