From a67ad20f388cd35487a7a9d46a003e39e1f402aa Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 2 Jul 2013 10:17:29 +0200 Subject: [PATCH] Tests: Tests skippen, wenn Template-Cache-Verzeichnis nicht schreibbar ist --- t/Support/TestSetup.pm | 16 ++++++++++++++++ t/controllers/base/render.t | 6 ++++++ t/presenter/base/render.t | 6 ++++++ 3 files changed, 28 insertions(+) diff --git a/t/Support/TestSetup.pm b/t/Support/TestSetup.pm index 2fbbd2d5f..081e7b106 100644 --- a/t/Support/TestSetup.pm +++ b/t/Support/TestSetup.pm @@ -4,6 +4,7 @@ use strict; use Data::Dumper; use CGI qw( -no_xhtml); +use IO::File; use SL::Auth; use SL::Form; use SL::Locale; @@ -56,4 +57,19 @@ sub login { _login($client, $login); } +sub templates_cache_writable { + my $dir = $::lx_office_conf{paths}->{userspath} . '/templates-cache'; + return 1 if -w $dir; + + # Try actually creating a file. Due to ACLs this might be possible + # even if the basic Unix permissions and Perl's -w test say + # otherwise. + my $file = "${dir}/.writetest"; + my $out = IO::File->new($file, "w") || return 0; + $out->close; + unlink $file; + + return 1; +} + 1; diff --git a/t/controllers/base/render.t b/t/controllers/base/render.t index 0a15078e0..3d5bad0e5 100644 --- a/t/controllers/base/render.t +++ b/t/controllers/base/render.t @@ -14,6 +14,12 @@ no warnings 'uninitialized'; Support::TestSetup::login(); +if (!Support::TestSetup::templates_cache_writable()) { + plan skip_all => 'Cache dir not writable for this test'; +} else { + plan tests => 19; +} + sub reset_test_env { $ENV{HTTP_USER_AGENT} = 'Perl Tests'; diff --git a/t/presenter/base/render.t b/t/presenter/base/render.t index 5d7c96ea3..4e389f9b0 100644 --- a/t/presenter/base/render.t +++ b/t/presenter/base/render.t @@ -9,6 +9,12 @@ use SL::Presenter; Support::TestSetup::login(); +if (!Support::TestSetup::templates_cache_writable()) { + plan skip_all => 'Cache dir not writable for this test'; +} else { + plan tests => 11; +} + my $pr = SL::Presenter->get; # Passing invalid parameters: -- 2.20.1