Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuxel committed Aug 20, 2019
2 parents 7de41e5 + 930deac commit 85dbfc4
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
3 changes: 2 additions & 1 deletion containers/cpp/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"files.associations": {
"iostream": "cpp"
}
},
"cmake.sourceDirectory": "${workspaceRoot}/test-project"
}
11 changes: 11 additions & 0 deletions containers/cpp/test-project/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.0.0)
project(test-project VERSION 0.1.0)

include(CTest)
enable_testing()

add_executable(test-project main.cpp)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
61 changes: 61 additions & 0 deletions containers/cpp/test-project/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env bash
cd $(dirname "$0")

if [ -z $HOME ]; then
HOME="/root"
fi

FAILED=()

check() {
LABEL=$1
shift
echo -e "\n🧪 Testing $LABEL: $@"
if $@; then
echo "🏆 Passed!"
else
echo "💥 $LABEL check failed."
FAILED+=("$LABEL")
fi
}

checkMultiple() {
PASSED=0
LABEL="$1"
shift; MINIMUMPASSED=$1
shift; EXPRESSION="$1"
while [ "$EXPRESSION" != "" ]; do
if $EXPRESSION; then ((PASSED++)); fi
shift; EXPRESSION=$1
done
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
}

checkExtension() {
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]"
}

# Actual tests
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]"
checkExtension "ms-vscode.cpptools"
check "non-root-user" "id vscode"
check "/home/vscode" [ -d "/home/vscode" ]
check "sudo" sudo -u vscode echo "sudo works."
check "git" git --version
check "command-line-tools" which top ip lsb_release g++ gcc cmake cppcheck valgrind
check "g++" g++ -g main.cpp -o main.out
rm main.out
mkdir -p build
cd build
check "cmake" cmake ..
cd ..
rm -rf build

# Report result
if [ ${#FAILED[@]} -ne 0 ]; then
echo -e "\n💥 Failed tests: ${FAILED[@]}"
exit 1
else
echo -e "\n💯 All passed!"
exit 0
fi

0 comments on commit 85dbfc4

Please sign in to comment.