Commits

Greg Ward committed 9a2d948

tests: go ahead and run test-git, but exit if git not found.

Comments (0)

Files changed (4)

 # Maximally pessimistic view of header dependencies.
 $(objects): $(headers)
 
-.PHONY: check
-check: vcprompt
-	cd tests && ./test-simple
+.PHONY: check check-simple check-git
+check: check-simple check-git
 
 gitrepo = tests/git-repo.tar
 
+check-simple: vcprompt
+	cd tests && ./test-simple
+
 check-git: vcprompt $(gitrepo)
 	cd tests && ./test-git
 
 $(gitrepo): tests/setup-git
 	cd tests && ./setup-git
 
-# target check-all requires that all supported VC tools be
-# installed
-check-all: check check-git
-
 clean:
 	rm -f $(objects) vcprompt
 
 vcprompt=""
 tmpdir=""
 
+# Check if some external command is available by running it
+# and ensuring that it prints an expected string.  If not,
+# exit with optional message.
+check_available()
+{
+    cmd=$1
+    expect=$2
+    msg=$3
+
+    if ! $cmd 2>/dev/null | grep -q "$expect"; then
+        [ "$msg" ] && echo $msg
+        exit 0
+    fi
+}
+
 find_vcprompt()
 {
     vcprompt=$testdir/../vcprompt
 # way tests can modify the repo and/or working dir without harming
 # other tests.
 
+. ./common.sh
+
+check_available "git --version " "git version"
 set -ex
 cd `dirname $0`
 rm -rf git-repo
 
 . ./common.sh
 
+# check if git is available; exit if not
+check_git()
+{
+    check_available \
+      "git --version" \
+      "git version" \
+      "git not found: skipping this test script"
+}
+
 find_gitrepo()
 {
     gitrepo="$testdir/git-repo.tar"
     posttest
 }
 
+check_git
 find_vcprompt
 find_gitrepo
 setup
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.