132 lines
5.4 KiB
Bash
Executable file
132 lines
5.4 KiB
Bash
Executable file
#!/bin/bash
|
|
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
#
|
|
# Author: Tomáš Juhász <tjuhasz@redhat.com>
|
|
# Inspired by internal test by: Honza Horak <hhorak@redhat.com>
|
|
#
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
#
|
|
# Copyright (c) 2013 Red Hat, Inc. All rights reserved.
|
|
#
|
|
# This copyrighted material is made available to anyone wishing
|
|
# to use, modify, copy, or redistribute it subject to the terms
|
|
# and conditions of the GNU General Public License version 2.
|
|
#
|
|
# This program is distributed in the hope that it will be
|
|
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
# PURPOSE. See the GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public
|
|
# License along with this program; if not, write to the Free
|
|
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
# Boston, MA 02110-1301, USA.
|
|
#
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
# Include Beaker environment
|
|
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
|
|
|
function check_and_cleanup()
|
|
{
|
|
rlAssertExists "./node_modules/optimist/package.json"
|
|
rlRun "[[ -e './node_modules/optimist/node_modules/wordwrap/package.json' ]] || [[ -e './node_modules/wordwrap/package.json' ]]" 0 "File wordwrap/package.json should exist."
|
|
# Skip directory cleanup if the first parameter is empty
|
|
[[ -z "$1" ]] && rlRun "rm -rf ./node_modules && ! ls ./node_modules" 0 "Cleaning up local modules"
|
|
rlRun "$NPMJS cache clean --force" 0 "Cleaning up npm cache"
|
|
}
|
|
|
|
|
|
# Packages to be tested
|
|
PACKAGES=${PACKAGES:-nodejs}
|
|
# Other required packages
|
|
REQUIRES=${REQUIRES:-}
|
|
# Node binary name parametrized
|
|
NODEJS=${NODEJS:-node}
|
|
# NPM binary name parametrized
|
|
NPMJS=${NPMJS:-npm}
|
|
|
|
# Parameters to check using "npm parameter" and what to look for in their output
|
|
|
|
rlJournalStart
|
|
rlPhaseStartSetup
|
|
rlAssertRpm --all
|
|
rlAssertBinaryOrigin $NODEJS
|
|
|
|
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
|
|
rlRun "cp *.js* $TmpDir/." 0 "Copying additional test files"
|
|
rlRun "pushd $TmpDir"
|
|
rlPhaseEnd
|
|
|
|
rlPhaseStartTest "Install"
|
|
echo "---ls--" && ls -lah && echo "--- " # info
|
|
|
|
# Tests
|
|
rlLog "Installing from web repository:"
|
|
rlRun "$NPMJS install optimist " 0 "Installing \"optimist\" from repository"
|
|
check_and_cleanup
|
|
|
|
rlLog "Installing using \"package.json\" and web repository:"
|
|
rlRun "mv _package.json package.json" 0 "Enabling \"package.json\""
|
|
rlRun "$NPMJS install" 0 "Installing \"optimist\" using \"package.json\""
|
|
check_and_cleanup
|
|
rlRun "mv package.json _package.json" 0 "Disabling \"package.json\""
|
|
|
|
rlLog "Installing particular version from web repository:"
|
|
rlRun "$NPMJS install optimist@0.4.0" 0 "Installing version 0.4.0 of \"optimist\""
|
|
check_and_cleanup
|
|
|
|
rlLog "Installing globally from web repository:"
|
|
rlRun "$NPMJS install coffee-script --global " 0 "Installing \"coffee-script\" globally"
|
|
rlRun "which coffee" 0 "Executable \"coffee\" should be in binary path"
|
|
rlRun "$NPMJS cache clean --force" 0 "Cleaning up npm cache"
|
|
|
|
rlPhaseEnd
|
|
|
|
rlPhaseStartTest "Remove"
|
|
rlLog "Removing local package:"
|
|
rlRun "$NPMJS remove optimist wordwrap" 0 "Removing \"optimist\" and \"wordwrap\""
|
|
rlAssertNotExists "./node_modules/optimist/package.json"
|
|
rlAssertNotExists "./node_modules/optimist/node_modules/wordwrap/package.json"
|
|
rlAssertNotExists "./node_modules/wordwrap/package.json"
|
|
|
|
echo "---ls-node-modules--" && ls -lah ./node_modules # info
|
|
echo "---" # info
|
|
|
|
rlLog "Removing global package:"
|
|
rlRun "$NPMJS remove coffee-script --global" 0 "Removing global \"coffee-script\""
|
|
rlAssertNotExists "${npm_global_path}/coffee-script/package.json"
|
|
rlPhaseEnd
|
|
|
|
rlPhaseStartTest "Help"
|
|
rlLog "Checking quickhelp messages:"
|
|
# special treatment for npm test -h (displays man)
|
|
rlRun "${NPMJS} test -h | col -bx | grep -E '${CHECK_APIHELP_FOR}|${NPMJS} test'"\
|
|
0 "Calling \"${NPMJS} test -h\" should display quick help or man"
|
|
run_by_format "${NPMJS} %kword% -h | col -bx | grep -E '${NPMJS} %kword%'"\
|
|
"$CHECK_QUICKHELP_PAGES" \
|
|
"Calling \"${NPMJS} %kword% -h\" should display quick help"
|
|
|
|
rlLog "Checking help pages (man redirects):"
|
|
run_by_format "${NPMJS} help %kword% | col -bx | grep -E '${CHECK_HELP_FOR}'" \
|
|
"$CHECK_HELP_PAGES" \
|
|
"Calling \"${NPMJS} help %kword%\" should display manpage"
|
|
|
|
if ${NPMJS} -h | grep 'apihelp'; then
|
|
run_by_format "${NPMJS} apihelp %kword% | col -bx | grep -E '${CHECK_APIHELP_FOR}'" \
|
|
"$CHECK_APIHELP_PAGES" \
|
|
"Calling \"${NPMJS} apihelp %kword%\" should display manpage"
|
|
fi
|
|
|
|
rlPhaseEnd
|
|
|
|
rlPhaseStartCleanup
|
|
rlRun "rm /root/.npmrc" 0,1
|
|
rlRun "rm /root/.npm" 0,1
|
|
rlRun "popd"
|
|
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
|
rlPhaseEnd
|
|
rlJournalPrintText
|
|
rlJournalEnd
|
|
|