Compare commits

...

7 Commits

Author SHA1 Message Date
Alex Schroeder
c7db436f00 umlaut.t: environment variable must be encoded
The environment variable must be in "bytes", ie. we need to call
utf8::encode.
2016-06-17 16:50:47 +02:00
Alex Schroeder
14c33c5a9a Remove extra test for $DataDir
We already call CreateDir($DataDir) in this sub.
2016-06-17 16:49:46 +02:00
Alex Schroeder
0bd2afe4e1 Added basic tests to check for UTF-8 in $DataDir
basic.t tests normal operations; umlaut-t tests normal operations when
$DataDir contains an (UTF8 encoded) character.
2016-06-17 14:37:01 +02:00
Alex Schroeder
0a9ff1b723 Skip pygmentize if the binary is not found 2016-06-17 10:52:35 +02:00
Alex Schroeder
2dab06f905 Tests rely on English output
Set environment variable to en_US.UTF-8.
2016-06-17 10:52:35 +02:00
Alex Schroeder
8c143393e3 test.pl: no warning about killing the server 2016-06-17 10:52:35 +02:00
Alex Schroeder
8255303d95 Make server.pl compatible with Alexine 2016-06-17 10:52:34 +02:00
7 changed files with 87 additions and 16 deletions

View File

@@ -14,22 +14,31 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
package OddMuse;
our $RunCGI = 0;
do 'wiki.pl';
my $dir = $DataDir; # used for Mojolicious::Plugin::CGI setup
use Mojolicious::Lite;
# This needs to be in a different section, sometimes?
plugin CGI => {
support_semicolon_in_query_string => 1,
};
plugin CGI => {
route => '/wiki',
# We need this for older versions of Mojolicious::Plugin::CGI
script => 'wiki.pl',
run => \&OddMuse::DoWikiRequest,
before => sub {
no warnings;
$OddMuse::RunCGI = 0;
# The default data directory is determined by the environment variable
# WikiDataDir and falls back to the following
# $OddMuse::DataDir = '/tmp/oddmuse';
use warnings;
require 'wiki.pl' unless defined &OddMuse::DoWikiRequest;
},
env => {},
# path to where STDERR from cgi script goes
errlog => "$dir/wiki.log",
errlog => ($ENV{WikiDataDir} || '/tmp/oddmuse')
. "/wiki.log",
};
get '/' => sub {

25
t/basic.t Normal file
View File

@@ -0,0 +1,25 @@
# Copyright (C) 2016 Alex Schroeder <alex@gnu.org>
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
require 't/test.pl';
package OddMuse;
use Test::More tests => 3;
# editing pages
test_page(get_page('Test'),
'<title>Wiki: Test</title>',
'Status: 404 NOT FOUND');
test_page(update_page('Test', 'Muuu!', 'first edit', undef, undef,
'username=Alex'),
'<p>Muuu!</p>');

View File

@@ -23,6 +23,8 @@ SKIP: {
add_module('git.pl');
$ENV{LANG} = "en_US.UTF-8"; # test relies on English output
if (qx($GitBinary --version) !~ /git version/) {
skip "$GitBinary not found", 16;
}

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2015 Alex Schroeder <alex@gnu.org>
# Copyright (C) 2015-2016 Alex Schroeder <alex@gnu.org>
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
@@ -18,8 +18,14 @@ use Test::More tests => 2;
add_module('pygmentize.pl');
$ENV{PATH} = '.'; # pygmentize is not installed in the current directory
$page = apply_rules(newlines('{{{\ntest\n}}}\n'));
test_page($page,
'\bsh\b.*\bpygmentize\b.*\bnot found\b',
'<pre>test</pre>');
SKIP: {
if (qx(pygmentize -V) !~ /Pygments version/) {
skip "pygmentize not found", 2;
}
$ENV{PATH} = '.'; # pygmentize is not installed in the current directory
$page = apply_rules(newlines('{{{\ntest\n}}}\n'));
test_page($page,
'\bsh\b.*\bpygmentize\b.*\bnot found\b',
'<pre>test</pre>');
}

View File

@@ -416,7 +416,6 @@ sub start_mojolicious_server {
END {
# kill server
if ($pid) {
warn "Killing server $pid\n";
kill 'KILL', $pid or warn "Could not kill server $pid";
}
}

31
t/umlaut.t Normal file
View File

@@ -0,0 +1,31 @@
# Copyright (C) 2016 Alex Schroeder <alex@gnu.org>
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
require 't/test.pl';
package OddMuse;
use Test::More tests => 3;
use utf8;
my $dir = $ENV{WikiDataDir};
$dir .= "-ä";
utf8::encode($dir); # bytes
$ENV{WikiDataDir} = $dir;
# editing pages
test_page(get_page('Test'),
'<title>Wiki: Test</title>',
'Status: 404 NOT FOUND');
test_page(update_page('Test', 'Muuu!', 'first edit', undef, undef,
'username=Alex'),
'<p>Muuu!</p>');

View File

@@ -305,7 +305,6 @@ sub InitVariables { # Init global session variables for mod_perl!
$LastUpdate = $ts;
unshift(@MyRules, \&MyRules) if defined(&MyRules) && (not @MyRules or $MyRules[0] != \&MyRules);
@MyRules = sort {$RuleOrder{$a} <=> $RuleOrder{$b}} @MyRules; # default is 0
ReportError(Ts('Cannot create %s', $DataDir) . ": $!", '500 INTERNAL SERVER ERROR') unless -d $DataDir;
@IndexOptions = (['pages', T('Include normal pages'), 1, \&AllPagesList]);
foreach my $sub (@MyInitVariables) {
my $result = $sub->();