1. Greg Ward
  2. vcprompt

Commits

Jordi Fita  committed 45a2521

Added tests for fossil support.

  • Participants
  • Parent commits ded02b6
  • Branches default

Comments (0)

Files changed (3)

File tests/setup-fossil

View file
+#!/bin/sh
+
+# Setup the test fossil repository that will be used by test-fossil.
+#
+# Output is fossil-repo, which will be unpacked for each test run.
+
+. ./common.sh
+
+check_available "fossil version" "This is fossil"
+set -ex
+cd `dirname $0`
+rm -rf fossil-repo
+fossil init -A alice fossil-repo
+fossil user default alice -R fossil-repo
+rm -fr fossil-work
+mkdir fossil-work
+cd fossil-work
+fossil open ../fossil-repo
+
+echo a > a
+echo b > b
+fossil add a b
+fossil commit -m "add a, b"
+
+mkdir .fossil-settings
+cat > .fossil-settings/ignore-glob <<EOF
+~$
+\.o$
+EOF
+fossil add .fossil-settings/ignore-glob
+fossil commit -m "add ignore-glob"
+
+echo fix >> b
+fossil commit --branch stable -m "fix a bug"
+
+fossil checkout trunk
+
+cd ..
+rm -rf fossil-work

File tests/test-fossil

View file
+#!/bin/sh
+
+# Tests that require a real fossil repository and executable.
+
+. ./common.sh
+
+check_fossil()
+{
+    check_available \
+    "fossil version" \
+    "This is fossil" \
+    "fossil not found: skipping this test script"
+}
+
+find_fossilrepo()
+{
+    fossilrepo="$testdir/fossil-repo"
+    if [ ! -f $fossilrepo ]; then
+    echo "$fossilrepo not found" >&2
+    exit 1
+    fi
+}
+
+pretest()
+{
+    [ -d "$tmpdir" ] || die "tmpdir ($tmpdir) does not exist"
+    cd $tmpdir
+    rm -rf fossil-work
+    mkdir fossil-work
+    cd fossil-work
+    fossil open $fossilrepo > /dev/null
+}
+
+posttest()
+{
+    :
+}
+
+# default prompt format in test repo
+test_basics()
+{
+    pretest
+    assert_vcprompt "show branch 1" "trunk" "%b"
+    fossil checkout stable > /dev/null
+    assert_vcprompt "show branch 2" "stable" "%b"
+
+    # not implemented yet
+    echo foo >> b
+    echo junk > junk
+    assert_vcprompt "show modified" "+" "%m"
+    assert_vcprompt "show unknown" "?" "%u"
+
+    posttest
+}
+
+check_fossil
+find_vcprompt
+find_fossilrepo
+setup
+
+test_basics
+
+report

File tests/test-simple

View file
     assert_vcprompt "git subdir" "foo"
 }
 
+test_simple_fossil()
+{
+    cd $tmpdir
+    mkdir fossil && cd fossil
+
+    touch _FOSSIL_
+    assert_vcprompt "fossil broken" "fossil:(unknown)" "%n:%b"
+
+    rm _FOSSIL_
+    assert_vcprompt "fossil norepo" "" "%n:%b"
+    assert_vcprompt "fossil norepo" "" "%n:%b"
+
+    touch .fslckout
+    assert_vcprompt "fossil broken" "fossil:(unknown)" "%n:%b"
+}
+
 test_simple_hg()
 {
     cd $tmpdir
 test_no_vc
 test_root
 test_simple_cvs
+test_simple_fossil
 test_simple_git
 test_simple_hg
 test_simple_hg_bookmarks