[Ubuntu] Migrate Browsers and Rust tests to Pester (#2323)

* add tests for browsers and rust

* small fix

* fix tests invoking

* small fixes

* resolve conflicts

* fix firefox test
This commit is contained in:
Dibir Magomedsaygitov
2020-12-28 11:34:32 +03:00
committed by GitHub
parent ba0809214b
commit 7c15befd02
5 changed files with 71 additions and 34 deletions

View File

@@ -4,15 +4,11 @@
## Desc: Installs Firefox
################################################################################
source $HELPER_SCRIPTS/invoke-tests.sh
# Install Firefox
apt-get install -y firefox
# 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 firefox; then
exit 1
fi
# add to gloabl system preferences for firefox locale en_US, because other browsers have en_US local.
# Default firefox local is en_GB
echo 'pref("intl.locale.requested","en_US");' >> "/usr/lib/firefox/browser/defaults/preferences/syspref.js"
@@ -34,9 +30,4 @@ chmod +x $GECKODRIVER_BIN
ln -s "$GECKODRIVER_BIN" /usr/bin/
echo "GECKOWEBDRIVER=$GECKODRIVER_DIR" | tee -a /etc/environment
# Run tests to determine that the geckodriver installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v geckodriver; then
echo "geckodriver was not installed"
exit 1
fi
invoke_tests "Browsers" "Firefox"

View File

@@ -4,6 +4,8 @@
## Desc: Installs google-chrome and chromedriver
################################################################################
source $HELPER_SCRIPTS/invoke-tests.sh
LSB_RELEASE=$(lsb_release -rs)
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
@@ -12,13 +14,6 @@ apt-get update
apt-get install -y google-chrome-stable
echo "CHROME_BIN=/usr/bin/google-chrome" | tee -a /etc/environment
# 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 google-chrome; then
echo "google-chrome was not installed"
exit 1
fi
CHROME_VERSION=$(google-chrome --product-version)
CHROME_VERSION=${CHROME_VERSION%.*}
@@ -41,9 +36,4 @@ chmod +x $CHROMEDRIVER_BIN
ln -s "$CHROMEDRIVER_BIN" /usr/bin/
echo "CHROMEWEBDRIVER=$CHROMEDRIVER_DIR" | tee -a /etc/environment
# Run tests to determine that the chromedriver installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v chromedriver; then
echo "chromedriver was not installed"
exit 1
fi
invoke_tests "Browsers" "Chrome"

View File

@@ -6,6 +6,7 @@
# Source the helpers for use with the script
source $HELPER_SCRIPTS/etc-environment.sh
source $HELPER_SCRIPTS/invoke-tests.sh
export RUSTUP_HOME=/usr/share/rust/.rustup
export CARGO_HOME=/usr/share/rust/.cargo
@@ -21,18 +22,9 @@ cargo install bindgen cbindgen
cargo install cargo-audit
cargo install cargo-outdated
echo "Test installation of the Rust toochain"
# Permissions
chmod -R 777 $(dirname $RUSTUP_HOME)
for cmd in rustup rustc rustdoc cargo rustfmt cargo-clippy bindgen cbindgen 'cargo audit' 'cargo outdated'; do
if ! command -v $cmd --version; then
echo "$cmd was not installed or is not found on the path"
exit 1
fi
done
# Cleanup Cargo cache
rm -rf ${CARGO_HOME}/registry/*
@@ -44,3 +36,5 @@ pushd /etc/skel
ln -sf $RUSTUP_HOME .rustup
ln -sf $CARGO_HOME .cargo
popd
invoke_tests "Tools" "Rust"

View File

@@ -0,0 +1,19 @@
Describe "Firefox" {
It "Firefox" {
"sudo -i firefox --version" | Should -ReturnZeroExitCode
}
It "Geckodriver" {
"geckodriver --version" | Should -ReturnZeroExitCode
}
}
Describe "Chrome" {
It "Chrome" {
"google-chrome --version" | Should -ReturnZeroExitCode
}
It "Chrome Driver" {
"chromedriver --version" | Should -ReturnZeroExitCode
}
}

View File

@@ -16,6 +16,49 @@ Describe "azcopy" {
}
}
Describe "Rust" {
It "Rustup is installed" {
"rustup --version" | Should -ReturnZeroExitCode
}
It "Rustc is installed" {
"rustc --version" | Should -ReturnZeroExitCode
}
It "Rustdoc is installed" {
"rustdoc --version" | Should -ReturnZeroExitCode
}
It "Rustfmt is installed" {
"rustfmt --version" | Should -ReturnZeroExitCode
}
Context "Cargo dependencies" {
It "bindgen" {
"bindgen --version" | Should -ReturnZeroExitCode
}
It "cbindgen" {
"cbindgen --version" | Should -ReturnZeroExitCode
}
It "cargo" {
"cargo --version" | Should -ReturnZeroExitCode
}
It "cargo-clippy" {
"cargo-clippy --version" | Should -ReturnZeroExitCode
}
It "Cargo audit" {
"cargo audit --version" | Should -ReturnZeroExitCode
}
It "Cargo outdated" {
"cargo outdated --version" | Should -ReturnZeroExitCode
}
}
}
Describe "Docker" {
It "docker" {
"docker --version" | Should -ReturnZeroExitCode