-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#583: First prototype of integration tests in bash.
- Loading branch information
Showing
5 changed files
with
233 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
#!/bin/bash | ||
|
||
source "$(dirname "${0}")"/functions-test.sh | ||
|
||
success=0 | ||
failure=0 | ||
total=0 | ||
|
||
function doTestsInner() { | ||
# Note: requires var test_files_directory to be set. | ||
echo "Enter doTestsInner..." | ||
echo $PWD | ||
echo "test_files_directory ---> ${test_files_directory}"/"${1}"-* | ||
for testpath in "${test_files_directory}"/"${1}"-* | ||
do | ||
testcase="${testpath/*\//}" | ||
echo "Running test #${total}: ${testcase}" | ||
result=1 | ||
if [[ $testcase == integration* ]] | ||
then | ||
echo "Will run test script: $testcase" | ||
"${testpath}" | ||
result=${?} | ||
# cd test-setup | ||
# rm -fR "${PWD}/software" | ||
# rm -f "${PWD}/conf/devon.properties" | ||
# rm -f "${PWD}/settings/devon.properties" | ||
# echo "JAVA_VERSION=17*" >> "${PWD}/settings/devon.properties" | ||
else | ||
echo "TODO -- for now ignore non-integration tests: $testcase". | ||
echo "is this code reachable in the first place?" | ||
# mkdir -p "${testcase}/conf" | ||
# cd "${testcase}" | ||
# echo "export M2_REPO=~/.m2/repository" > "conf/devon.properties" | ||
fi | ||
if [ "${result}" == 0 ] | ||
then | ||
doSuccess "[SUCCESS] Succeeded running test #${total}: ${testcase}" | ||
let "success++" | ||
echo "\033[92m[SUCCESS] Succeeded running test #${total}: ${testcase}\033[39m" >> ../testResults | ||
else | ||
doError "[ERROR] Failed running test #${total}: ${testcase} - exit code ${result}" | ||
let "failure++" | ||
echo "\033[91m[ERROR] Failed running test #${total}: ${testcase} - exit code ${result}\033[39m" >> ../testResults | ||
fi | ||
let "total++" | ||
cd .. | ||
done | ||
} | ||
|
||
function doDisplayResults() { | ||
cat testResults | while read -r line; do echo -e "${line}"; done | ||
} | ||
|
||
|
||
|
||
function doTests () { | ||
# mkdir -p ~/.devon | ||
# touch ~/.devon/.license.agreement | ||
# rm -rf integration-test | ||
# mkdir -p integration-test | ||
# cd integration-test | ||
#export DEVON_SKIP_PROJECT_SETUP=true | ||
#doTestsInner "test" | ||
doTestsInner "integration-test" | ||
#[[ "${INTEGRATION_TEST}" == true ]] && doTestsInner "integration-test" | ||
echo -e "\n*****************************************************" | ||
echo "Executed #${total} test(s), #${success} succeeded and #${failure} failed" | ||
echo -e "*****************************************************\n" | ||
if [ "${failure}" == 0 ] | ||
then | ||
doSuccess "All test succeeded. Fine!" | ||
doDisplayResults | ||
else | ||
doWarning "There are test failures! Please check the logs and fix errors.\n" | ||
doDisplayResults | ||
exit 1 | ||
fi | ||
exit 0 | ||
} | ||
|
||
function main () { | ||
local DEBUG_INTEGRATION_TEST="/c/Users/nmollers/tmp/ideasy-integration-test-debug" | ||
local HOME="${DEBUG_INTEGRATION_TEST}/home-dir" | ||
local IDE_ROOT="${HOME}/projects" | ||
local IDE_BIN="${IDE_ROOT}/_ide/bin" | ||
local IDE="${DEBUG_INTEGRATION_TEST}/home-dir/projects/_ide/bin/ide" | ||
|
||
# test_files_directory=$(cd `dirname $0` && pwd) | ||
local test_files_directory=$(realpath $0 | xargs dirname) | ||
echo "Will run integration tests from dir: ${test_files_directory}" | ||
|
||
rm -rf "${DEBUG_INTEGRATION_TEST}" | ||
# Only need to mkdir once: | ||
mkdir -p "${IDE_BIN}" | ||
|
||
|
||
# TODO remove logs | ||
echo "IDE_ROOT is: $IDE_ROOT" | ||
echo "My PWD is: $PWD" | ||
echo "My ~/ is:" ~/ | ||
|
||
# TODO Download latest IDEasy (or build local IDEasy ?) | ||
# curl ??? | ||
local SNAPSHOT="/c/Users/nmollers/Downloads/ide-cli-2024.10.001-beta-20241029.023922-8-windows-x64.tar.gz" | ||
cd "${IDE_ROOT}/_ide" | ||
tar xfz "${SNAPSHOT}" || (echo "Not able to extract." && exit 1) | ||
|
||
#no need to: cd "${HOME}" | ||
echo -e "echo \"Tmp home dir's bashrc loading...\"" >> ~/.bashrc | ||
echo -e "alias ide=\"source ${PWD}/bin/ide\"" >> ~/.bashrc | ||
# echo -e 'export IDE_ROOT="$(pwd)"' >> ~/.bashrc | ||
|
||
|
||
# source ./bin/ide | ||
cd "${IDE_ROOT}" | ||
doTests | ||
|
||
echo "DONE" | ||
exit 0 | ||
} | ||
|
||
main | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
## source "$(dirname "${0}")"/functions-test | ||
|
||
echo my PWD is: $PWD | ||
echo "My ~ (home dir) is " ~/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/bash | ||
|
||
test_project_name="tmp-integ-test" | ||
|
||
function doIdeCreate () { | ||
#TODO: determine the name of the currently executed script | ||
# local project-name="$(dirname "${BASH_SOURCE:-$0}")" | ||
# local project_name="$(basename "${BASH_SOURCE:-$0}")" | ||
# local test_project_name="tmp-integ-test" | ||
local settings_url=${1:--} | ||
echo ide create ${test_project_name} ${settings_url} | ||
|
||
#TODO: IDE_ROOT ? | ||
mkdir ${IDE_ROOT}/${test_project_name} | ||
cd ${IDE_ROOT}/${test_project_name} | ||
|
||
# TODO: Remove logs | ||
echo "END OF doIdeCreate" | ||
echo "My IDE_ROOT is: ${IDE_ROOT}" | ||
echo "My PWD is: $PWD" | ||
echo "settings-url : ${settings_url}" | ||
echo "project-name : ${project_name}" | ||
} | ||
|
||
function doIdeCreateCleanup () { | ||
rm -rf ${IDE_ROOT}/${test_project_name} | ||
} | ||
|
||
|
||
function doCommandTest() { | ||
# CLI="${PWD}/scripts/devon" | ||
# "${CLI}" "${1}" --batch setup | ||
#TODO | ||
log_setup=">>LOG_COMMAND_TEST.log" | ||
ide "${@}" "${log_setup}" | ||
result="${?}" | ||
exit $result | ||
} | ||
|
||
function doExtract() { | ||
if [ -f "${1}" ] | ||
then | ||
tar xfz "${1}" || exit 1 | ||
else | ||
echo "Could not find and extract release ${1}" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# $@: success message | ||
function doSuccess() { | ||
echo -e "\033[92m${*}\033[39m" | ||
} | ||
|
||
# $@: warning message | ||
function doWarning() { | ||
echo -e "\033[93m${*}\033[39m" | ||
} | ||
|
||
# $@: messages to output | ||
function doError() { | ||
echo -e "\033[91m${1}\033[39m" | ||
} | ||
|
||
function doIsMacOs() { | ||
if [ "${OSTYPE:0:6}" = "darwin" ] | ||
then | ||
return | ||
fi | ||
return 255 | ||
} | ||
|
||
function doIsWindows() { | ||
if [ "${OSTYPE}" = "cygwin" ] || [ "${OSTYPE}" = "msys" ] | ||
then | ||
return | ||
fi | ||
return 255 | ||
} |
12 changes: 12 additions & 0 deletions
12
cli/src/test/integration-tests-bash/integration-test-intellij.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
source "$(dirname "${0}")"/functions-test.sh | ||
doIdeCreate | ||
doCommandTest gibberish whatever intellij | ||
retCode=$? | ||
if [ $retCode == 0 ] | ||
then | ||
# TODO: else rename folder? | ||
doIdeCreateCleanup | ||
fi | ||
exit $retCode |
12 changes: 12 additions & 0 deletions
12
cli/src/test/integration-tests-bash/integration-test-npm.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
source "$(dirname "${0}")"/functions-test.sh | ||
|
||
doIdeCreate | ||
doCommandTest install npm | ||
retCode=$? | ||
if [ $retCode == 0 ] | ||
then | ||
doIdeCreateCleanup | ||
fi | ||
exit $retCode |