Commits

Anonymous committed 909657b

Convert gen-hd-html to Perl+Test::More.

Comments (0)

Files changed (3)

installer/tests/Makefile

 all:
 
-BASH_TESTS = gen-hd-html template-toolkit bolded-nav-links update-images
+BASH_TESTS = template-toolkit bolded-nav-links update-images
 
 BASH_TESTS_TARGETS = $(addprefix test-,$(BASH_TESTS))
 

installer/tests/gen-hd-html/test1.bash

-#!/bin/bash
-
-# Verify the HTML correctness for all the themes
-
-if [ ! -e in-out ] ; then
-    mkdir in-out
-else
-    rm -fr in-out/*
-fi
-cd "in-out"
-
-# Check that the default charset and lang are OK.
-t=0
-
-error()
-{
-    echo "$1" 1>&2
-}
-
-perform_test()
-{
-let t++
-local hd
-hd="$1"
-shift
-
-echo "Test No. $t : hd=$hd"
-
-test_dir="testhtml$t"
-quadp setup $test_dir --dest-dir=`pwd`/${test_dir}-output
-
-cat > $test_dir/src/index.html.wml <<EOF
-<set-var qp_body_dir="$dir" />
-#include 'template.wml'
-
-<p>
-Hello world!
-</p>
-
-EOF
-
-if $hd ; then
-    params=" -hd "
-else
-    params=""
-fi
-
-(cd $test_dir && quadp render -a $params)
-if $hd ; then
-    if ! test -d $test_dir/hard-disk-html ; then
-        error "hard-disk-html was not created while specified to be"
-        exit 1
-    fi
-else
-    if test -d $test_dir/hard-disk-html ; then
-        error "hard-disk-html was created while note specified to be"
-        exit 1
-    fi
-fi
-}
-
-for hd in true false ; do
-    perform_test "$hd"
-done
-

installer/tests/perl/t/gen-hd-html.t

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 6;
+
+use File::Path;
+use File::Copy::Recursive qw(dircopy fcopy);
+use Cwd;
+use IO::All;
+use HTML::Lint;
+
+my $io_dir_proto = "t/data/in-out-gen-hd-html";
+my $io_dir = File::Spec->rel2abs($io_dir_proto);
+rmtree ($io_dir);
+mkpath ($io_dir);
+
+
+my $test_idx = 0;
+
+# TEST:$n=0;
+sub perform_test
+{
+    my $hd = shift;
+
+    my $orig_dir = Cwd::getcwd();
+
+    chdir($io_dir);
+
+    $test_idx++;
+
+    my $test_dir = "testhtml-$test_idx";
+    my $output_dir = "$test_dir-output";
+
+    my $pwd = Cwd::getcwd();
+
+    # TEST:$n++;
+    ok(
+        !system(
+        "quadp", "setup", $test_dir, "--dest-dir=$pwd/$output_dir"
+        ),
+        "Running quadp setup was succesful for hd '$hd'."
+    );
+
+    chdir($test_dir);
+    
+    # TEST:$n++;
+    ok (!system("quadp", "render", "-a", ($hd ? ("-hd") : ())),
+        "quadp render -a ran successfully for hd '$hd'."
+    );
+
+    # TEST:$n++;
+    if ($hd)
+    {
+        ok(
+            (-d "hard-disk-html"),
+            "hard-disk-html was created as specified",
+        );
+    }
+    else
+    {
+        ok(
+            (! -d "hard-disk-html"),
+            "hard-disk-html was not created as specified",
+        );
+    }
+
+    chdir($orig_dir);
+
+    return;
+}
+
+# TEST:$num_asserts=$n;
+
+# TEST:$num_cfgs=2;
+my @render_hd_configs = (0,1);
+
+# TEST*$num_cfgs*$num_asserts
+foreach my $hd (@render_hd_configs)
+{
+    perform_test($hd);
+}
+