#!/usr/bin/perl -w use strict; use File::Temp qw(tempdir); use File::Path; use lib 't/lib'; use VCfs::Setup; use Test::More; require_ok "VCfs"; my @types = working_vcs_types(); for my $type (@types) { note("Testing $type"); my $co_dir = setup( type => $type ); my $vc = new_ok VCfs => [$co_dir]; # detect() { my $my_type = "is_$type"; for my $method (qw(is_svn is_svk)) { my $is = $vc->$method; my $ok = $method eq $my_type ? $is : !$is; ok $ok, "$method"; } } # add and commit some files { ok open my $fh, ">", "$co_dir/foo" or diag $!; print $fh "foo and stuff\n"; close $fh; ok open $fh, ">", "$co_dir/bar" or diag $!; print $fh "bar and stuff\n"; close $fh; ok $vc->add(qw(foo bar)), "add()"; # XXX SVN specific is_deeply { $vc->status }, { foo => "A", bar => "A" }, "status"; ok $vc->commit("This is foo", "foo"), "committing just one file"; is_deeply { $vc->status }, { bar => "A" }, "status"; ok $vc->commit("This is foo", "bar"), "committing another file"; is_deeply { $vc->status }, { }, "status"; } # Change a file, do some checks on it and revert() it. { # Add a line to a committed file ok open my $fh, ">>", "$co_dir/foo" or diag $!; print $fh "here is another line\n"; close $fh; is_deeply { $vc->status }, { foo => "M" }; ok $vc->revert("foo"), "revert"; ok open $fh, "<", "$co_dir/foo" or diag $!; is join( "", <$fh> ), <<'END', " file reverted"; foo and stuff END } } done_testing();