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

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