From 4b36d82c173ce6cb24f52a9e30dc08354c0af2e3 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 22 May 2011 22:17:29 -0700 Subject: Add a test file for git cloning --- t/008_git_clone.t | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 t/008_git_clone.t (limited to 't/008_git_clone.t') diff --git a/t/008_git_clone.t b/t/008_git_clone.t new file mode 100644 index 0000000..c4935ce --- /dev/null +++ b/t/008_git_clone.t @@ -0,0 +1,55 @@ +use Test::More tests => 3; +use Test::Exception; +use strict; +use warnings; +use autodie qw/:all/; +use IPC::Cmd qw/can_run/; + +use jitterbug; +use jitterbug::Schema; +use lib 't/lib'; +use jitterbug::Test; + +use JSON; +use YAML qw/LoadFile Dump/; + +use File::Spec; +use File::Temp qw/tempdir/; + +use Dancer::Test; +use Dancer::Config qw/setting/; +use File::Spec::Functions; +use File::Copy::Recursive qw/dircopy/; +my $hook_data = catfile(qw/t data hook_data.yml/); + +my $content = LoadFile($hook_data); + +my $db_dir = tempdir( CLEANUP => 1 ); +my $db_file = File::Spec->catfile( $db_dir, 'jitterbug.db' ); +my $dsn = 'dbi:SQLite:dbname=' . $db_file; +my $schema = jitterbug::Schema->connect($dsn); +$schema->deploy; + +setting plugins => { + DBIC => { + schema => { + skip_automake => 1, + pckg => "jitterbug::Schema", + connect_info => [$dsn] + } + } +}; + +if (can_run('git')){ + + my $gitrepo = "t/data/testing"; + dircopy "$gitrepo/._git_", "$gitrepo/.git" unless -e "$gitrepo/.git"; + + lives_ok sub { system("$^X scripts/post_to_hook.pl") }, 'post_to_hook.pl lives'; + + lives_ok sub { system("$^X scripts/builder.pl -c t/data/test.yml -C") }, 'builder.pl lives'; + + ok(-e "t/tmp/build/testing/.git", 'found a testing git repo'); +} else { + skip "Git not available, skipping tests", 3; +} -- cgit v1.2.3 From 068fe469d432c5e4a0f36d7e2ac72e3bb7c6131b Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 22 May 2011 22:21:56 -0700 Subject: remove a cached build dir before the test --- t/008_git_clone.t | 4 ++++ 1 file changed, 4 insertions(+) (limited to 't/008_git_clone.t') diff --git a/t/008_git_clone.t b/t/008_git_clone.t index c4935ce..6e33018 100644 --- a/t/008_git_clone.t +++ b/t/008_git_clone.t @@ -20,6 +20,8 @@ use Dancer::Test; use Dancer::Config qw/setting/; use File::Spec::Functions; use File::Copy::Recursive qw/dircopy/; +use File::Path qw/rmtree/; + my $hook_data = catfile(qw/t data hook_data.yml/); my $content = LoadFile($hook_data); @@ -40,6 +42,8 @@ setting plugins => { } }; +rmtree(catfile(qw/t tmp build testing/)); + if (can_run('git')){ my $gitrepo = "t/data/testing"; -- cgit v1.2.3 From f4127b1235b585b5d82082fcfd820b68479ceba4 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 22 May 2011 23:01:33 -0700 Subject: Add a test to verify we get the expected sha1 --- t/008_git_clone.t | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 't/008_git_clone.t') diff --git a/t/008_git_clone.t b/t/008_git_clone.t index 6e33018..5a7f915 100644 --- a/t/008_git_clone.t +++ b/t/008_git_clone.t @@ -1,4 +1,4 @@ -use Test::More tests => 3; +use Test::More tests => 4; use Test::Exception; use strict; use warnings; @@ -49,11 +49,17 @@ if (can_run('git')){ my $gitrepo = "t/data/testing"; dircopy "$gitrepo/._git_", "$gitrepo/.git" unless -e "$gitrepo/.git"; - lives_ok sub { system("$^X scripts/post_to_hook.pl") }, 'post_to_hook.pl lives'; + lives_ok sub { system("$^X -Ilib scripts/post_to_hook.pl") }, 'post_to_hook.pl lives'; - lives_ok sub { system("$^X scripts/builder.pl -c t/data/test.yml -C") }, 'builder.pl lives'; + + lives_ok sub { # $ENV{DEBUG} = 1; + system("$^X -Ilib scripts/builder.pl -c t/data/test.yml -C") + }, 'builder.pl lives'; ok(-e "t/tmp/build/testing/.git", 'found a testing git repo'); + chdir "t/tmp/build/testing"; + chomp( my $sha1 = qx{git rev-parse HEAD} ); + is($sha1,"3ab75b9a29e09bf027f64250b44cab19b316c128", "got expected sha1 in repo"); } else { skip "Git not available, skipping tests", 3; } -- cgit v1.2.3 From 2e70da0107303e88428d7ac58773cb0a06b5d5c3 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Mon, 23 May 2011 17:45:35 -0700 Subject: Refactor _parse_results and enable debugging in the git tests --- t/008_git_clone.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/008_git_clone.t') diff --git a/t/008_git_clone.t b/t/008_git_clone.t index 5a7f915..6733a14 100644 --- a/t/008_git_clone.t +++ b/t/008_git_clone.t @@ -52,7 +52,7 @@ if (can_run('git')){ lives_ok sub { system("$^X -Ilib scripts/post_to_hook.pl") }, 'post_to_hook.pl lives'; - lives_ok sub { # $ENV{DEBUG} = 1; + lives_ok sub { $ENV{DEBUG} = 1; system("$^X -Ilib scripts/builder.pl -c t/data/test.yml -C") }, 'builder.pl lives'; -- cgit v1.2.3