Blame gnulib-tests/test-vc-list-files-cvs.sh

Packit 33f14e
#!/bin/sh
Packit 33f14e
# Unit tests for vc-list-files
Packit 33f14e
# Copyright (C) 2008-2017 Free Software Foundation, Inc.
Packit 33f14e
# This file is part of the GNUlib Library.
Packit 33f14e
#
Packit 33f14e
# This program is free software: you can redistribute it and/or modify
Packit 33f14e
# it under the terms of the GNU General Public License as published by
Packit 33f14e
# the Free Software Foundation; either version 3 of the License, or
Packit 33f14e
# (at your option) any later version.
Packit 33f14e
#
Packit 33f14e
# This program is distributed in the hope that it will be useful,
Packit 33f14e
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 33f14e
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 33f14e
# GNU General Public License for more details.
Packit 33f14e
#
Packit 33f14e
# You should have received a copy of the GNU General Public License
Packit 33f14e
# along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit 33f14e
Packit 33f14e
: ${srcdir=.}
Packit 33f14e
. "$srcdir/init.sh"; path_prepend_ "$abs_aux_dir" .
Packit 33f14e
Packit 33f14e
tmpdir=vc-cvs
Packit 33f14e
repo=`pwd`/$tmpdir/repo
Packit 33f14e
Packit 33f14e
fail=0
Packit 33f14e
for i in with-cvsu without; do
Packit 33f14e
  # On the first iteration, test using cvsu, if it's in your path.
Packit 33f14e
  # On the second iteration, ensure that cvsu fails, so we'll
Packit 33f14e
  # exercise the awk-using code.
Packit 33f14e
  if test $i = without; then
Packit 33f14e
    printf '%s\n' '#!/bin/sh' 'exit 1' > cvsu
Packit 33f14e
    chmod a+x cvsu
Packit 33f14e
    PATH=`pwd`:$PATH
Packit 33f14e
    export PATH
Packit 33f14e
  fi
Packit 33f14e
  ok=0
Packit 33f14e
  mkdir $tmpdir && cd $tmpdir &&
Packit 33f14e
    # without cvs, skip the test
Packit 33f14e
    { ( cvs -Q -d "$repo" init ) > /dev/null 2>&1 \
Packit 33f14e
      || skip_ "cvs not found in PATH"; } &&
Packit 33f14e
    mkdir w && cd w &&
Packit 33f14e
    mkdir d &&
Packit 33f14e
    touch d/a b c &&
Packit 33f14e
    cvs -Q -d "$repo" import -m imp m M M0 &&
Packit 33f14e
    cvs -Q -d "$repo" co m && cd m &&
Packit 33f14e
    printf '%s\n' b c d/a > expected &&
Packit 33f14e
    vc-list-files | sort > actual &&
Packit 33f14e
    compare expected actual &&
Packit 33f14e
    ok=1
Packit 33f14e
  test $ok = 0 && fail=1
Packit 33f14e
done
Packit 33f14e
Packit 33f14e
Exit $fail