# -*- cperl -*-
use strict;
use Benchmark;

# Set one string comment to the current directory.
# Check that it succeeded.
# This requires that the string value is properly quoted.
# This case mirrors a similar suite for mkattr.
#
# This suite does not test the presence of triggers.

use Test::More tests => 8;
select(STDERR); $| = 1; select(STDOUT); $| = 1;
use ClearCase::Argv qw(chdir);
use Argv 1.25;

ClearCase::Argv->summary;      # start keeping stats
ClearCase::Argv->ipc(1);
my $ct = ClearCase::Argv->new({autochomp=>1});
my $silent = $ct->clone;
$silent->stdout(0);
$silent->stderr(0);
die "This test needs to be run in a view, in a vob\n"
  unless $ct->argv(qw(ls -s -d .))->stderr(0)->qx;

sub one_pass {
  my $ipc = shift;
  my $mode = $ipc? 'ipc' : 'fork';
  $silent->ipc($ipc);
  my $value = q(foo);
  ok(!$silent->argv(qw(chevent -rep -c), $value, '.')->system,
     "String comment set to $value ($mode mode)");
  $value = q(O'Toole);
  ok(!$silent->argv(qw(chevent -rep -c), $value, '.')->system,
     "String comment set to $value ($mode mode)");
  $value = q(*test*);
  ok(!$silent->argv(qw(chevent -rep -c), $value, '.')->system,
     "String comment set to $value ($mode mode)");
  $value = qq(Line one\nLine two);
  ok(!$silent->argv(qw(chevent -rep -c), $value, '.')->system,
     "String comment set to $value ($mode mode)");
}
one_pass(0);
one_pass(1);

print STDERR "\n", ClearCase::Argv->summary;   # print out the stats we kept
