]> git.madduck.net Git - code/vcsh.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge branch 'feature/tests'
authorRichard Hartmann <richih@debian.org>
Wed, 11 Feb 2015 18:53:25 +0000 (19:53 +0100)
committerRichard Hartmann <richih@debian.org>
Wed, 11 Feb 2015 18:53:25 +0000 (19:53 +0100)
Makefile
t/000-tear-env.t [new file with mode: 0644]
t/001-setup-env.t [new file with mode: 0644]
t/100-init.t [new file with mode: 0644]
t/300-add.t [new file with mode: 0644]
t/950-delete.t [new file with mode: 0644]
t/999-tear-env.t [new file with mode: 0644]
tools/hooks/pre-commit [new file with mode: 0755]

index ca6ebe681a99ac4f85d78d4ccd0974d4b4d7d413..d939624851d745aa0874c5a795cb49d47a529f92 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -44,7 +44,8 @@ purge: uninstall
        rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(ZSHDIR)
 
 test:
-       @if which git > /dev/null ; then :; else echo "'git' not found, exiting..."; exit 1; fi
+       @if which git   > /dev/null; then :    ; else echo "'git' not found, exiting..."; exit 1;  fi
+       @if which prove > /dev/null; then prove; else echo "'prove' not found; not running tests"; fi
 
 moo:
        @ which cowsay >/dev/null 2>&1 && cowsay "I hope you're happy now..."
diff --git a/t/000-tear-env.t b/t/000-tear-env.t
new file mode 100644 (file)
index 0000000..6cb384f
--- /dev/null
@@ -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 (file)
index 0000000..fb59f05
--- /dev/null
@@ -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 (file)
index 0000000..f2b3a05
--- /dev/null
@@ -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 shared 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 (file)
index 0000000..24d9a8a
--- /dev/null
@@ -0,0 +1,33 @@
+#!/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`;
+
+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 (file)
index 0000000..cd07871
--- /dev/null
@@ -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 (file)
index 0000000..afe261a
--- /dev/null
@@ -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;
diff --git a/tools/hooks/pre-commit b/tools/hooks/pre-commit
new file mode 100755 (executable)
index 0000000..ddb0550
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# Unfortunately, Git decided to set those two during pre-commit
+unset GIT_DIR
+unset GIT_INDEX_FILE
+
+prove