Files
git-upstream/functional-tests/030-test_no_local_changes.sh
Davide Guerri 8e066904b5 Add functional test framework and some basic tests
hpgit lacks of functional tests that ensure it works as expected and
that can be used to automate code verifications.
Functional tests will help to improve hpgit software quality.

JIRA: CICD-1089
Change-Id: Id9764b93c504da3fcc8d8c56415120536388a432
2014-02-03 17:14:46 +00:00

56 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
BASE_DIR=$(cd $(dirname $0); pwd -P)
# Include and run common test functions and initializations
source $BASE_DIR/libs/logging.lib
source $BASE_DIR/libs/utils.lib
REPO_NAME="empty-repo"
UPSTREAM_REPO=$(git rev-parse --show-toplevel)
TEST_BASE_REF="2c4bf67b5c416adfb162d9ca1fb4b0bf353fbb2a"
CHERRY_PICKS="19b89746d08fa224bb8aba12106dbc330cb5d019 \
5d4fbe79037c3b2516216258a907d3a02f0b205c"
TEST_REBASE_REF="fd3524e1b7353cda228b6fb73c3a2d34a4fee4de"
function test_no_local_changes() {
log DEBUG "Starting $TEST_NAME::$FUNCNAME"
prepare_for_hpgit $TEST_DIR $REPO_NAME $UPSTREAM_REPO $TEST_BASE_REF \
$TEST_NAME
pushd $TEST_DIR/$REPO_NAME >/dev/null
log DEBUG "Cherry picking upstream commits"
for cp in $CHERRY_PICKS; do
log DEBUG "Cherry picking commit $cp"
git cherry-pick $cp >/dev/null || return 1
done
git push -u origin master --quiet >/dev/null || return 1
git checkout master --quiet || return 1
log DEBUG "Rebasing local patches onto upstream version $TEST_REBASE_REF"
git branch import/$TEST_NAME-new $TEST_REBASE_REF --quiet || return 1
local result="$(git-hp import-upstream import/$TEST_NAME-new)"
echo "$result" | grep "There are no local changes to be applied!" >/dev/null
if [ "$?" -ne 0 ]; then
popd >/dev/null
return 1
fi
popd >/dev/null
}
TESTS="test_no_local_changes"
for test in $TESTS; do
$test && log INFO "$TEST_NAME::$test() passed." || \
log ERROR "$TEST_NAME::$test() failed!"
done