Skip to content

Commit

Permalink
Added simple tests to build script to prevent building if tests fail
Browse files Browse the repository at this point in the history
Modified all checks for missing s3-common-functions to use more informative error function


git-svn-id: http://s3-bash.googlecode.com/svn/trunk@8 437c54f9-5d38-0410-a777-75cbac79620a
  • Loading branch information
raphael.james.cohn committed Oct 10, 2007
1 parent fa50365 commit 6411f52
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
44 changes: 39 additions & 5 deletions build
@@ -1,5 +1,4 @@
#! /bin/bash

#! /usr/bin/env bash
cat > /dev/null << EndOfLicence
s3-bash
Copyright 2007 Raphael James Cohn
Expand Down Expand Up @@ -27,8 +26,43 @@ readonly commonFunctions="$ourPath/s3-common-functions"
if [ -e "$commonFunctions" ]; then
source "$commonFunctions"
else
printf "%s: Could not locate file s3-common-functions" "$weAreKnownAs" 1>&2
exit 2
version="Unknown"
invalidEnvironmentExitCode=4
printErrorHelpAndExit "$weAreKnownAs: Could not locate file s3-common-functions" $invalidEnvironmentExitCode
fi

tar -c s3-put s3-get s3-delete s3-common-functions Licence | gzip > "/tmp/s3-bash.$version.tar.gz"
function tests
{
if [ ! -f secret-key ]; then
printErrorHelpAndExit "Internal Error: No secret key file (secret-key) exists on the path"
fi
createTemporaryFile "somefile"
somefile="$(mostRecentTemporaryFile)"
echo "Testing" > "$somefile"
url=/raphaelcohn-ami/somefile
"$ourPath/s3-delete" -k $S3_SECRET_KEY -s "$ourPath/secret-key" $url
if [ $? -ne 0 ]; then
printErrorHelpAndExit "Internal Error: s3-delete failed"
fi
"$ourPath/s3-put" -T "$somefile" -k $S3_SECRET_KEY -s "$ourPath/secret-key" $url
if [ $? -ne 0 ]; then
printErrorHelpAndExit "Internal Error: s3-put failed"
fi
"$ourPath/s3-get" -k $S3_SECRET_KEY -s "$ourPath/secret-key" $url
if [ $? -ne 0 ]; then
printErrorHelpAndExit "Internal Error: s3-get failed"
fi
"$ourPath/s3-delete" -k $S3_SECRET_KEY -s "$ourPath/secret-key" $url
if [ $? -ne 0 ]; then
printErrorHelpAndExit "Internal Error: s3-delete failed"
fi
}

function tarball
{
tar -c s3-put s3-get s3-delete s3-common-functions Licence | gzip > "$temporaryDirectory/s3-bash.$version.tar.gz"
}

initialise
tests
tarball
2 changes: 1 addition & 1 deletion s3-get
Expand Up @@ -102,7 +102,7 @@ if [ -e "$commonFunctions" ]; then
else
version="Unknown"
invalidEnvironmentExitCode=4
printHelpAndExit "$weAreKnownAs: Could not locate file s3-common-functions" $invalidEnvironmentExitCode
printErrorHelpAndExit "$weAreKnownAs: Could not locate file s3-common-functions" $invalidEnvironmentExitCode
fi

main "$@"
2 changes: 1 addition & 1 deletion s3-put
Expand Up @@ -113,7 +113,7 @@ if [ -e "$commonFunctions" ]; then
else
version="Unknown"
invalidEnvironmentExitCode=4
printHelpAndExit "$weAreKnownAs: Could not locate file s3-common-functions" $invalidEnvironmentExitCode
printErrorHelpAndExit "$weAreKnownAs: Could not locate file s3-common-functions" $invalidEnvironmentExitCode
fi

main "$@"

0 comments on commit 6411f52

Please sign in to comment.