Subject: | user-customized syntax files can break tests |
Some of the test files compare output to standard vim syntax definitions.
However if a user has customized the syntax files this can alter the
output and cause the tests to fail.
At least t/01array.t, t/10cmp.t, and t/20override.t are vulnerable.
While the tests could also break if the standard vim syntax files ever
change that is probably less likely than user files.
Setting $ENV{HOME} to another directory ('t', for instance)
(something under the dist's control) keeps vim from reading any
user-defined syntax files.
I have attached a patch.
I don't have much experience with building dists with EUMM
but I added an explicit no_index for "t" to try to avoid causing any
problems with the addition of the pm file.
Subject: | text-vimcolor-test-env.patch |
diff --git a/META.yml b/META.yml
index afdc40e..eb91362 100644
--- a/META.yml
+++ b/META.yml
@@ -5,5 +5,9 @@ version: 0.11
license: perl
distribution_type: module
+no_index:
+ directory:
+ - t
+
requires:
Path::Class: 0.02
diff --git a/t/01array.t b/t/01array.t
index e7f5ac1..2264df2 100644
--- a/t/01array.t
+++ b/t/01array.t
@@ -8,6 +8,7 @@ use strict;
use warnings;
use Test::More;
use Text::VimColor;
+require "t/test_env.pm";
plan tests => 7 + 2 * 3;
diff --git a/t/02file.t b/t/02file.t
index 8c0f7b8..9dfecce 100644
--- a/t/02file.t
+++ b/t/02file.t
@@ -4,6 +4,7 @@ use strict;
use warnings;
use Test::More;
use Text::VimColor;
+require "t/test_env.pm";
plan tests => 1;
diff --git a/t/05xml.t b/t/05xml.t
index 49de5aa..54b2ddf 100644
--- a/t/05xml.t
+++ b/t/05xml.t
@@ -5,6 +5,7 @@ use strict;
use warnings;
use Test::More;
use Text::VimColor;
+require "t/test_env.pm";
use IO::File;
my $NS = 'http://ns.laxan.com/text-vimcolor/1';
diff --git a/t/10cmp.t b/t/10cmp.t
index 5efe721..1bace43 100644
--- a/t/10cmp.t
+++ b/t/10cmp.t
@@ -4,6 +4,7 @@ use strict;
use warnings;
use Test::More;
use Text::VimColor;
+require "t/test_env.pm";
use Path::Class qw( file );
plan tests => 2;
diff --git a/t/15let.t b/t/15let.t
index 9092a84..a8a6c37 100644
--- a/t/15let.t
+++ b/t/15let.t
@@ -4,6 +4,7 @@ use strict;
use warnings;
use Test::More;
use Text::VimColor;
+require "t/test_env.pm";
use Path::Class qw( file );
# If the version of Vim is too old to do the right shell-script highlighting,
diff --git a/t/20override.t b/t/20override.t
index fd1bc73..266af30 100644
--- a/t/20override.t
+++ b/t/20override.t
@@ -5,6 +5,7 @@ use strict;
use warnings;
use Test::More;
use Text::VimColor;
+require "t/test_env.pm";
use Path::Class qw( file );
plan tests => 4;
diff --git a/t/test_env.pm b/t/test_env.pm
new file mode 100644
index 0000000..a26e3c9
--- /dev/null
+++ b/t/test_env.pm
@@ -0,0 +1,4 @@
+# don't allow user-customized syntax files to throw off test results
+$ENV{HOME} = 't';
+
+return 1;