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

# Create a new attribute type, and attach one string attribute of this type
# to the current directory.
# Check that it succeeded, and cleanup.
# This requires that the string value is properly quoted.
# This case tests a regression which was introduced at some point.
#
# This test case does not test the presence of triggers.

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

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;

my @attype = sort $ct->argv(qw(lstype -kind attype -s -obs))->qx;
my $attype = @attype? $attype[$#attype] . 'Z' : 'FOO';
$silent->argv(qw(mkattype -nc), $attype)->system and die "Aborted: $!\n";
my $value = q("foo");
ok(!$silent->argv('mkattr', $attype, $value, '.')->system,
   "String attribute set to $value\n");
$silent->argv(qw(rmtype -f -rmall), "attype:$attype")->system;

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