From: Richard Hartmann Date: Sat, 1 Nov 2014 06:17:33 +0000 (+0100) Subject: Merge branch 'master' into feature/tests X-Git-Url: https://git.madduck.net/code/vcsh.git/commitdiff_plain/73658dcd2c73106375cab7f649bce7be02836ca0?hp=36fc049881253a38f0b72d6d6aeb01c1295b8a2c Merge branch 'master' into feature/tests --- diff --git a/t/000-tear-env.t b/t/000-tear-env.t new file mode 100644 index 0000000..6cb384f --- /dev/null +++ b/t/000-tear-env.t @@ -0,0 +1,17 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Shell::Command; +use Test::Most; + +chdir 't' or die $!; + +if (!-d 'etc') { + plan skip_all => 'No need to tear down previous env.'; +} + +ok rm_rf 'etc'; + +done_testing; diff --git a/t/001-setup-env.t b/t/001-setup-env.t new file mode 100644 index 0000000..fb59f05 --- /dev/null +++ b/t/001-setup-env.t @@ -0,0 +1,19 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::Most; + +system ("mkdir -p t/etc"); +ok !$?; + +system ("mkdir -p t/etc/.vcsh_home"); +ok !$?; + +chdir 't/etc/' or die $!; + +system ("ln -s '../../vcsh'"); +ok !$?; + +done_testing; diff --git a/t/100-init.t b/t/100-init.t new file mode 100644 index 0000000..b726868 --- /dev/null +++ b/t/100-init.t @@ -0,0 +1,54 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Cwd 'abs_path'; +use Test::Most; + +chdir 't/etc/' or die $!; + +$ENV{'HOME'} = abs_path ('.vcsh_home'); + +my $output = `./vcsh status`; + +ok $output eq "", 'No repos set up yet.'; + +$output = `./vcsh init test1`; + +ok $output eq "Initialized empty Git repository in " . $ENV{'HOME'} . "/.config/vcsh/repo.d/test1.git/\n"; + +$output = `./vcsh status`; + +ok $output eq "test1:\n\n", 'Our new repo is there'; + +chdir $ENV{"HOME"} . '/.config/vcsh/repo.d/test1.git/' or die $!; + +ok -f 'HEAD'; +ok -d 'branches'; +ok -f 'config'; +ok -f 'description'; +ok -d 'hooks'; +ok -d 'info'; +ok -d 'objects'; +ok -d 'refs'; + +ok -f 'hooks/applypatch-msg.sample'; +ok -f 'hooks/commit-msg.sample'; +ok -f 'hooks/post-update.sample'; +ok -f 'hooks/pre-applypatch.sample'; +ok -f 'hooks/pre-commit.sample'; +ok -f 'hooks/pre-push.sample'; +ok -f 'hooks/pre-rebase.sample'; +ok -f 'hooks/prepare-commit-msg.sample'; +ok -f 'hooks/update.sample'; + +ok -f 'info/exclude'; + +ok -d 'objects/info'; +ok -d 'objects/pack'; + +ok -d 'refs/heads'; +ok -d 'refs/tags'; + +done_testing; diff --git a/t/300-add.t b/t/300-add.t new file mode 100644 index 0000000..58843c8 --- /dev/null +++ b/t/300-add.t @@ -0,0 +1,35 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Cwd 'abs_path'; + +use Shell::Command; +use Test::Most; + +chdir 't/etc/' or die $!; + +$ENV{'HOME'} = abs_path ('.vcsh_home'); + +chdir '.vcsh_home' or die $!; + +eval { + touch 'a'; +}; + +die $@ if $@; + +system (".././vcsh test1 add 'a'"); + +my $output = `.././vcsh status`; + +diag $output; + +ok $output eq "test1: +A a + +", 'Adding a file works'; + +done_testing; + diff --git a/t/950-delete.t b/t/950-delete.t new file mode 100644 index 0000000..cd07871 --- /dev/null +++ b/t/950-delete.t @@ -0,0 +1,19 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Cwd 'abs_path'; +use Test::Most; + +chdir 't/etc/' or die $!; + +$ENV{'HOME'} = abs_path ('.vcsh_home'); + +system ("echo 'Yes, do as I say' | ./vcsh delete test1"); + +my $output = `./vcsh status`; + +ok $output eq "", 'No repos set up anymore.'; + +done_testing; diff --git a/t/999-tear-env.t b/t/999-tear-env.t new file mode 100644 index 0000000..afe261a --- /dev/null +++ b/t/999-tear-env.t @@ -0,0 +1,17 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Shell::Command; +use Test::Most; + +chdir 't' or die $!; + +if (!-d 'etc') { + plan skip_all => 'No need to tear previous env.'; +} + +ok rm_rf 'etc'; + +done_testing;