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

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