[Ubuntu] Migrate tests for common tools to Pester (part 1) (#2288)

* add common tools tests pt1

* fix tests

* fix erlang test

* resolve comments

* minor changes

* remove extra logging
This commit is contained in:
Dibir Magomedsaygitov
2020-12-23 10:25:52 +03:00
committed by GitHub
parent 7ff71c853d
commit a9a236f7e5
13 changed files with 166 additions and 81 deletions

View File

@@ -10,5 +10,4 @@ source $HELPER_SCRIPTS/invoke-tests.sh
apt-get update -y
apt-get install -y p7zip p7zip-full p7zip-rar
# Run tests to determine that the software installed as expected
invoke_tests "Tools" "7-Zip"

View File

@@ -6,6 +6,7 @@
# Source the helpers for use with the script
source $HELPER_SCRIPTS/os.sh
source $HELPER_SCRIPTS/invoke-tests.sh
# ppa:ansible/ansible doesn't contain packages for Ubuntu20.04
if isUbuntu16 || isUbuntu18 ; then
@@ -16,9 +17,4 @@ fi
# Install latest Ansible
apt-get install -y --no-install-recommends ansible
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v ansible; then
echo "Ansible was not installed or found on PATH"
exit 1
fi
invoke_tests "Tools" "Ansible"

View File

@@ -18,5 +18,4 @@ tar zxvf /tmp/azcopy.tar.gz --strip-components=1 -C /tmp
mv /tmp/azcopy /usr/local/bin/azcopy10
chmod +x /usr/local/bin/azcopy10
# Run tests to determine that the software installed as expected
invoke_tests "Tools" "azcopy"

View File

@@ -4,6 +4,8 @@
## Desc: Installs Bazel and Bazelisk (A user-friendly launcher for Bazel)
################################################################################
source $HELPER_SCRIPTS/invoke-tests.sh
# Install bazel
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
@@ -13,14 +15,4 @@ apt-get install -y bazel
# Install bazelisk
npm install -g @bazel/bazelisk
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v bazel; then
echo "Bazel was not installed"
exit 1
fi
if ! command -v bazelisk; then
echo "Bazelisk was not installed"
exit 1
fi
invoke_tests "Tools" "Bazel"

View File

@@ -6,6 +6,7 @@
# Source the helpers for use with the script
source $HELPER_SCRIPTS/os.sh
source $HELPER_SCRIPTS/invoke-tests.sh
function InstallClang {
local version=$1
@@ -17,15 +18,6 @@ function InstallClang {
else
apt-get install -y "clang-$version" "lldb-$version" "lld-$version" "clang-format-$version"
fi
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
for cmd in clang-$version clang++-$version; do
if ! command -v $cmd; then
echo "$cmd was not installed"
exit 1
fi
done
}
function SetDefaultClang {
@@ -41,15 +33,10 @@ function SetDefaultClang {
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
if isUbuntu16 || isUbuntu18; then
versions=( "6.0" "8" "9" )
default_clang_version="9"
fi
toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json"
if isUbuntu20 ; then
versions=( "8" "9" "10" )
default_clang_version="10"
fi
versions=$(jq -r '.clang.versions[]' $toolset)
default_clang_version=$(jq -r '.clang.default_version' $toolset)
for version in ${versions[*]}; do
InstallClang $version
@@ -57,3 +44,5 @@ done
SetDefaultClang $default_clang_version
rm llvm.sh
invoke_tests "Tools" "clang"

View File

@@ -4,6 +4,8 @@
## Desc: Installs CMake
################################################################################
source $HELPER_SCRIPTS/invoke-tests.sh
# Test to see if the software in question is already installed, if not install it
echo "Checking to see if the installer script has already been run"
if command -v cmake; then
@@ -16,9 +18,4 @@ else
&& rm cmakeinstall.sh
fi
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v cmake; then
echo "cmake was not installed"
exit 1
fi
invoke_tests "Tools" "Cmake"

View File

@@ -4,6 +4,8 @@
## Desc: Installs erlang
################################################################################
source $HELPER_SCRIPTS/invoke-tests.sh
source_list=/etc/apt/sources.list.d/eslerlang.list
# Install Erlang
@@ -17,14 +19,7 @@ wget -q -O rebar3 https://s3.amazonaws.com/rebar3/rebar3
chmod +x rebar3
mv rebar3 /usr/local/bin/rebar3
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
for cmd in erl erlc rebar3; do
if ! command -v $cmd; then
echo "$cmd was not installed or not found on PATH"
exit 1
fi
done
invoke_tests "Tools" "erlang"
# Clean up source list
rm $source_list

View File

@@ -6,35 +6,25 @@
# Source the helpers for use with the script
source $HELPER_SCRIPTS/os.sh
source $HELPER_SCRIPTS/invoke-tests.sh
function InstallGcc {
version=$1
echo "Installing $version..."
apt-get install $version -y
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v $version; then
echo "$version was not installed"
exit 1
fi
}
# Install GNU C++ compiler
add-apt-repository ppa:ubuntu-toolchain-r/test -y
apt-get update -y
versions=(
"g++-7"
"g++-8"
"g++-9"
)
toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json"
if ! isUbuntu16; then
versions+=("g++-10")
fi
versions=$(jq -r '.gcc.versions[]' $toolset)
for version in ${versions[*]}; do
InstallGcc $version
done
invoke_tests "Tools" "gcc"

View File

@@ -3,36 +3,27 @@
## File: gfortran.sh
## Desc: Installs GNU Fortran
################################################################################
source $HELPER_SCRIPTS/os.sh
source $HELPER_SCRIPTS/invoke-tests.sh
function InstallFortran {
version=$1
echo "Installing $version..."
apt-get install $version -y
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v $version; then
echo "$version was not installed"
exit 1
fi
}
# Install GNU Fortran compiler
add-apt-repository ppa:ubuntu-toolchain-r/test -y
apt-get update -y
versions=(
"gfortran-8"
"gfortran-9"
)
if ! isUbuntu16; then
versions+=("gfortran-10")
fi
toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json"
versions=$(jq -r '.gfortran.versions[]' $toolset)
for version in ${versions[*]}
do
InstallFortran $version
done
invoke_tests "Tools" "gfortran"

View File

@@ -15,3 +15,73 @@ Describe "azcopy" {
"azcopy10 --version" | Should -ReturnZeroExitCode
}
}
Describe "Ansible" {
It "Ansible" {
"ansible --version" | Should -ReturnZeroExitCode
}
}
Describe "Bazel" {
It "<ToolName>" -TestCases @(
@{ ToolName = "bazel" }
@{ ToolName = "bazelisk" }
) {
"$ToolName --version"| Should -ReturnZeroExitCode
}
}
Describe "clang" {
[array]$testCases = (Get-ToolsetContent).clang.Versions | ForEach-Object { @{ClangVersion = $_} }
It "clang <ClangVersion>" -TestCases $testCases {
param (
[string] $ClangVersion
)
"clang-$ClangVersion --version" | Should -ReturnZeroExitCode
"clang++-$ClangVersion --version" | Should -ReturnZeroExitCode
}
}
Describe "Cmake" {
It "cmake" {
"cmake --version" | Should -ReturnZeroExitCode
}
}
Describe "erlang" {
$testCases = @("erl", "erlc", "rebar3") | ForEach-Object { @{ErlangCommand = $_} }
It "erlang <ErlangCommand>" -TestCases $testCases {
param (
[string] $ErlangCommand
)
"$ErlangCommand -v" | Should -ReturnZeroExitCode
}
}
Describe "gcc" {
[array]$testCases = (Get-ToolsetContent).gcc.Versions | ForEach-Object { @{GccVersion = $_} }
It "gcc <GccVersion>" -TestCases $testCases {
param (
[string] $GccVersion
)
"$GccVersion --version" | Should -ReturnZeroExitCode
}
}
Describe "gfortran" {
[array]$testCases = (Get-ToolsetContent).gfortran.Versions | ForEach-Object { @{GfortranVersion = $_} }
It "gfortran <GfortranVersion>" -TestCases $testCases {
param (
[string] $GfortranVersion
)
"$GfortranVersion --version" | Should -ReturnZeroExitCode
}
}

View File

@@ -214,5 +214,26 @@
"3.1",
"5.0"
]
},
"clang": {
"versions": [
"6.0",
"8",
"9"
],
"default_version": "9"
},
"gcc": {
"versions": [
"g++-7",
"g++-8",
"g++-9"
]
},
"gfortran": {
"versions": [
"gfortran-8",
"gfortran-9"
]
}
}

View File

@@ -218,5 +218,28 @@
"3.1",
"5.0"
]
},
"clang": {
"versions": [
"6.0",
"8",
"9"
],
"default_version": "9"
},
"gcc": {
"versions": [
"g++-7",
"g++-8",
"g++-9",
"g++-10"
]
},
"gfortran": {
"versions": [
"gfortran-8",
"gfortran-9",
"gfortran-10"
]
}
}

View File

@@ -190,5 +190,28 @@
"3.1",
"5.0"
]
},
"clang": {
"versions": [
"8",
"9",
"10"
],
"default_version": "10"
},
"gcc": {
"versions": [
"g++-7",
"g++-8",
"g++-9",
"g++-10"
]
},
"gfortran": {
"versions": [
"gfortran-8",
"gfortran-9",
"gfortran-10"
]
}
}