hgcodesmell / test.sh

#!/bin/sh

# Test the hgcodesmell extension.

HG="hg --config extensions.codesmell=`pwd`/hgcodesmell.py"
msg() { echo "[ test ] $1"; }
die() { echo "[failed] $1"; exit 1; }
suc() { echo "[passed] $1"; exit 0; }

msg "Removing old test repository, if present."
rm -rf repo

msg "Making test repository in ./repo."
$HG init repo || die "repo creation failed"
cd repo

msg "Committing some files without smell."
echo "# A normal Python file." > file.py
echo "A text file." > file.txt
$HG addremove
$HG commit -vm "Initial commit." || die "initial commit failed"

msg "Trying to commit file.py with smell. codesmell should complain."
echo "1/0" >> file.py
echo | $HG commit -vm "Trying to commit file with smell."
[ $? -eq 1 ] || die "codesmell didn't exit with error"
$HG revert -a || die "revert failed"

msg "Trying to commit file.txt without smell. codesmell should not complain."
echo "1/0" >> file.txt
$HG commit -vm "Blah, blah." || die "commit failed"

msg "Trying to commit file.txt with smelling change message. codesmell should complain."
echo "1/0" >> file.txt
echo | $HG commit -vm "imported patch blah-blah"
[ $? -eq 1 ] || die "codesmell didn't exit with error"
$HG revert -a || die "revert failed"

msg "Removing test repository."
cd ..
rm -r repo

suc "all tests successful"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.