summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-05-28 11:01:05 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2010-05-28 11:01:05 +0200
commite2a868a8437ea9ef2cf88a5b934b28da2b8f425d (patch)
treebc6c0dd2f3f7ee0f49aa31c046865d48446eae3b
parent1215c13c45be9ab1d9fcfec45b63475449d48487 (diff)
Fix comirror-setup unicode handling & add test for it
-rwxr-xr-xbin/comirror-setup3
-rwxr-xr-xtest/60-comirror-setup.t58
-rw-r--r--test/next-unicroak/1.jpg0
-rw-r--r--test/next-unicroak/1.xhtml14
-rw-r--r--test/next-unicroak/2.jpg0
-rw-r--r--test/next-unicroak/2.xhtml14
-rw-r--r--test/next-unicroak/3.jpg0
-rw-r--r--test/next-unicroak/3.xhtml14
-rw-r--r--test/next-unicroak/4.jpg0
-rw-r--r--test/next-unicroak/4.xhtml14
-rw-r--r--test/next-unicroak/5.jpg0
-rw-r--r--test/next-unicroak/5.xhtml13
12 files changed, 104 insertions, 26 deletions
diff --git a/bin/comirror-setup b/bin/comirror-setup
index 03bf0a5..879c32c 100755
--- a/bin/comirror-setup
+++ b/bin/comirror-setup
@@ -29,9 +29,12 @@ my @opts = (
local $| = 1;
+binmode(STDOUT, ':utf8');
+
sub hash_to_file {
my ($hash, $file) = @_;
open(my $fh, '>', $file) or die("Can't open $file for writing: $!\n");
+ binmode($fh, ':utf8');
while (my ($key, $value) = each(%{$hash})) {
$key =~ tr/-/_/;
print {$fh} "$key\t$value\n";
diff --git a/test/60-comirror-setup.t b/test/60-comirror-setup.t
index 469b290..a3ac27c 100755
--- a/test/60-comirror-setup.t
+++ b/test/60-comirror-setup.t
@@ -3,15 +3,10 @@ use strict;
use warnings;
use 5.010;
use Cwd;
-use Test::More tests => 9;
+use Test::More tests => 18;
use Test::Cmd;
-my $test = Test::Cmd->new( prog => 'bin/comirror-setup', workdir => q{} );
-my $cwd = $test->workdir();
-
-my $next_base = 'file://' . getcwd() . '/test/next-loop';
-my ($str, $exit);
-my @links;
+my $test;
sub check_key {
my ($filetype, $key, $value) = @_;
@@ -26,31 +21,42 @@ sub check_key {
}
}
-ok($test, 'Create Test::Cmd object');
+for my $test_type (qw/loop unicroak/) {
-$exit = $test->run(
- chdir => $cwd
-);
+ $test = Test::Cmd->new( prog => 'bin/comirror-setup', workdir => q{} );
+ my $cwd = $test->workdir();
-ok($exit != 0, 'Not enough arguments: non-zero return');
+ my $next_base = 'file://' . getcwd() . "/test/next-${test_type}";
+ my ($str, $exit);
+ my @links;
-is ($test->stdout, q{}, 'Not enough arguments: Nothing to stdout');
-isnt($test->stderr, q{}, 'Not enough arguments: Something to stderr');
+ ok($test, 'Create Test::Cmd object');
-for my $i (1 .. 5) {
- push(@links, "${next_base}/${i}.xhtml");
-}
+ $exit = $test->run(
+ chdir => $cwd
+ );
+
+ ok($exit != 0, 'Not enough arguments: non-zero return');
+
+ is ($test->stdout, q{}, 'Not enough arguments: Nothing to stdout');
+ isnt($test->stderr, q{}, 'Not enough arguments: Something to stderr');
-$exit = $test->run(
- chdir => $cwd,
- args => '--batch ' . join(q{ }, @links[0, 1, 3]),
-);
+ for my $i (1 .. 5) {
+ push(@links, "${next_base}/${i}.xhtml");
+ }
+
+ $exit = $test->run(
+ chdir => $cwd,
+ args => '--batch ' . join(q{ }, @links[0, 1, 3]),
+ );
-ok($exit == 0, 'Correct usage: return zero');
+ ok($exit == 0, 'Correct usage: return zero');
-isnt($test->stdout, q{}, 'Correct usage: Something to stdout');
-is ($test->stderr, q{}, 'Correct usage: Nothing to stderr');
+ isnt($test->stdout, q{}, 'Correct usage: Something to stdout');
+ is ($test->stderr, q{}, 'Correct usage: Nothing to stderr');
-check_key('state', 'uri', $links[0]);
+ check_key('state', 'uri', $links[0]);
-check_key('conf', 'image_re', "${next_base}/.+");
+ check_key('conf', 'image_re', "${next_base}/.+");
+
+}
diff --git a/test/next-unicroak/1.jpg b/test/next-unicroak/1.jpg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/next-unicroak/1.jpg
diff --git a/test/next-unicroak/1.xhtml b/test/next-unicroak/1.xhtml
new file mode 100644
index 0000000..9753197
--- /dev/null
+++ b/test/next-unicroak/1.xhtml
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+<div>
+ <img src="1.jpg"/>
+ <a href="2.xhtml">Next →</a>
+</div>
+</body>
+</html>
diff --git a/test/next-unicroak/2.jpg b/test/next-unicroak/2.jpg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/next-unicroak/2.jpg
diff --git a/test/next-unicroak/2.xhtml b/test/next-unicroak/2.xhtml
new file mode 100644
index 0000000..b3c3969
--- /dev/null
+++ b/test/next-unicroak/2.xhtml
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+<div>
+ <img src="2.jpg"/>
+ <a href="3.xhtml">Next →</a>
+</div>
+</body>
+</html>
diff --git a/test/next-unicroak/3.jpg b/test/next-unicroak/3.jpg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/next-unicroak/3.jpg
diff --git a/test/next-unicroak/3.xhtml b/test/next-unicroak/3.xhtml
new file mode 100644
index 0000000..b0488cf
--- /dev/null
+++ b/test/next-unicroak/3.xhtml
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+<div>
+ <img src="3.jpg"/>
+ <a href="4.xhtml">Next →</a>
+</div>
+</body>
+</html>
diff --git a/test/next-unicroak/4.jpg b/test/next-unicroak/4.jpg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/next-unicroak/4.jpg
diff --git a/test/next-unicroak/4.xhtml b/test/next-unicroak/4.xhtml
new file mode 100644
index 0000000..844854e
--- /dev/null
+++ b/test/next-unicroak/4.xhtml
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+<div>
+ <img src="4.jpg"/>
+ <a href="5.xhtml">Next →</a>
+</div>
+</body>
+</html>
diff --git a/test/next-unicroak/5.jpg b/test/next-unicroak/5.jpg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/next-unicroak/5.jpg
diff --git a/test/next-unicroak/5.xhtml b/test/next-unicroak/5.xhtml
new file mode 100644
index 0000000..41012d9
--- /dev/null
+++ b/test/next-unicroak/5.xhtml
@@ -0,0 +1,13 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+<div>
+ <img src="5.jpg"/>
+</div>
+</body>
+</html>