Subject: | [PATCH] Test failures on Cygwin |
The test failures on Cygwin are caused by the repeated use of the "test.config" file in the tests. For some reason, Cygwin and/or XP seem unable to open a file to write when it was recently deleted. Anyways, I replaced the current handling with File::Temp. After testing, all seemed to work just fine.
Oh, and I switched it over the Test::More while I was at it.
--- t/01_Config-Auto.t.old 2005-07-07 09:35:50.310734400 -0500
+++ t/01_Config-Auto.t 2005-07-07 09:37:43.743843200 -0500
@@ -4,11 +4,11 @@
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
-
-use Test;
-BEGIN { plan tests => 18 };
-use Config::Auto;
-ok(1); # If we made it this far, we're ok.
+$|++;
+use Test::More qw(no_plan);
+use File::Temp qw(tempfile);
+use Cwd qw(cwd);
+BEGIN { use_ok('Config::Auto'); }
#########################
@@ -16,11 +16,11 @@
# its man page ( perldoc Test ) for help writing this test script.
sub t {
- open OUT, ">test.config" or die $!;
- print OUT @_;
- close OUT;
- my $c = Config::Auto::parse("test.config");
- unlink "test.config";
+ my ($fh, $filename) = tempfile(undef, DIR => cwd);
+ print $fh @_;
+ close $fh;
+ my $c = Config::Auto::parse($filename);
+ unlink $filename;
return $c;
}
@@ -32,9 +32,9 @@
nameserver 129.67.1.180
EOF
-ok(ref ($c->{nameserver}) eq "ARRAY");
-ok($c->{nameserver}[0] eq "163.1.2.1");
-ok(ref ($c->{search}) eq "ARRAY");
+is(ref ($c->{nameserver}), "ARRAY", 'list of nameservers is an ARRAY');
+is($c->{nameserver}[0], "163.1.2.1", 'first is 163.1.2.1');
+is(ref ($c->{search}), "ARRAY", 'list of search is an ARRAY');
$c = t(<<EOF);
root:x:0:0:root:/root:/bin/bash
@@ -42,8 +42,8 @@
bin:x:2:2:bin:/bin:/bin/sh
EOF
-ok(ref($c->{root}) eq "ARRAY");
-ok($c->{root}[0] eq "x");
+is(ref($c->{root}), "ARRAY");
+is($c->{root}[0], "x");
$c = t(<<EOF);
# This file was generated by debconf automaticaly.
@@ -53,7 +53,7 @@
USE_GDKXFT=false
EOF
-ok($c->{MOZILLA_DSP} eq "auto");
+is($c->{MOZILLA_DSP}, "auto");
$c = t(<<EOF);
# /etc/nsswitch.conf
@@ -69,8 +69,8 @@
hosts: files dns
EOF
-ok($c->{passwd} eq "compat");
-ok(ref $c->{hosts} eq "ARRAY");
+is($c->{passwd}, "compat");
+is(ref $c->{hosts}, "ARRAY");
$c = t(<<EOF);
test: foo=bar
@@ -79,10 +79,10 @@
EOF
-ok($c->{quux} eq "zoop");
-ok(ref $c->{test} eq "HASH");
-ok($c->{test}{foo} eq "bar");
-ok($c->{test}{baz} == 1);
+is($c->{quux}, "zoop");
+is(ref $c->{test}, "HASH");
+is($c->{test}{foo}, "bar");
+is($c->{test}{baz}, 1);
$c = t(<<EOF);
[group1]
@@ -92,8 +92,9 @@
password = doubleblah
EOF
-ok(ref $c->{"group1"} eq "HASH");
-ok($c->{"group1"}{"host"} eq "proxy.some-domain-name.com");
-ok($c->{"group1"}{"port"} eq "80");
-ok($c->{"group1"}{"username"} eq "blah");
-ok($c->{"group1"}{"password"} eq "doubleblah");
+is(ref $c->{"group1"}, "HASH");
+is($c->{"group1"}{"host"}, "proxy.some-domain-name.com");
+is($c->{"group1"}{"port"}, "80");
+is($c->{"group1"}{"username"}, "blah");
+is($c->{"group1"}{"password"}, "doubleblah");