Anonymous avatar Anonymous committed 2a8e116

Convert bolded-nav-links to Perl+Test::More.

Comments (0)

Files changed (15)

installer/tests/Makefile

 all:
 
-BASH_TESTS = bolded-nav-links update-images
+BASH_TESTS = update-images
 
 BASH_TESTS_TARGETS = $(addprefix test-,$(BASH_TESTS))
 

installer/tests/bolded-nav-links/template/Contents.pm

-package Contents;
-
-use strict;
-
-my $contents =
-{
-    'title' => "My Lecture Title",
-    'subs' =>
-    [
-        {
-            'url' => "two.html",
-            'title' => "Child Node",
-        },
-        {
-            'url' => "finale",
-            'title' => "Finale",
-            'subs' =>
-            [
-                {
-                    'url' => "links.html",
-                    'title' => "Links",
-                },
-                {
-                    'url' => "books.html",
-                    'title' => "Books",
-                },
-            ],
-        },
-
-    ],
-    'images' =>
-    [
-        'style.css',
-    ],
-};
-
-sub get_contents
-{
-    return $contents;
-}
-
-1;

installer/tests/bolded-nav-links/template/src/finale/books.html.wml

-#include 'template.wml'
-
-<ol>
-<li>
-Hi there!
-</li>
-</ol>

installer/tests/bolded-nav-links/template/src/finale/links.html.wml

-#include 'template.wml'
-
-<ol>
-<li>
-Hi there!
-</li>
-</ol>

installer/tests/bolded-nav-links/template/src/index.html.wml

-#include 'template.wml'
-
-<h1><font color="red">FILL IN</font></h1>

installer/tests/bolded-nav-links/template/src/style.css

-a.nav:link { color: green }
-a.nav:visited { color: #FF1493 /* The DeepPink Colour */  }
-a.nav:active { color: blue }
-b.nav { color : Black}
-b.plain {color : Black}
-a:hover { background-color: yellow }
-body { background-color : #FFFFFF }
-a.contents:active { color: red }
-table.mycode { border-style : solid ; border-width : thin }
-td.mycode { width : 60em }
-table.mydemo { border-style : solid ; border-width : thin }
-td.mydemo { width : 60em }
-table.note { border-style : double ; border-width : 3em}
-h3.notbold { font-weight: normal }
-font.menupath { font-family: monospace }
-b.menupathcomponent { color: red }
-font.menupathseparator { color: green }
-tt.mycode { color : #8A2BE2 /* The BlueViolet Colour */ }
-tt { color : #8A2BE2 /* The BlueViolet Colour */ }
-li.notbold { padding-bottom : 15em }
-ul.contents { list-style-type : none ; padding-left : 2em }
-ul.contentsmain { list-style-type : none ; padding-left : 0em }
-ul.point { font-size : large }
-ol.point { font-size : large }
-table.frame { border-style : solid ; border-width : thin }
-table.bordered { border-style : solid ; border-width : thin }
-table.bordered td { border-style : solid ; border-width : thin }
-/* Styles for gvim output */
-.c29 { color: #ff00ff; }
-.c28 { color: #0000ff; }
-.c31 { color: #008b8b; }
-.c30 { color: #6a5acd; }
-.c32 { color: #a52a2a; font-weight: bold; }
-.c34 { color: #2e8b57; font-weight: bold; }

installer/tests/bolded-nav-links/template/src/two.html.wml

-#include 'template.wml'
-
-<ol>
-<li>
-Hi there!
-</li>
-</ol>

installer/tests/bolded-nav-links/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
-
-perform_test()
-{
-let t++
-
-test_dir=testhtml$t
-quadp setup $test_dir --dest-dir=./rendered
-
-cp -R ../template/Contents.pm $test_dir
-rm -fr "$test_dir/src"
-cp -R ../template/src $test_dir/src
-
-(cd $test_dir && quadp render -a)
-output_file="$test_dir"/rendered/finale/books.html
-
-if ! grep -F "<b>Next</b>" "$output_file" > /dev/null ; then
-    echo "Next Link was not bolded" 1>&2
-    exit 1
-fi
-}
-
-perform_test
-

installer/tests/perl/t/bolded-nav-links.t

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 3;
+
+use File::Path;
+use File::Copy::Recursive qw(dircopy fcopy);
+use Cwd;
+use IO::All;
+
+my $io_dir = "t/data/in-out-bolded-nav-links";
+rmtree ($io_dir);
+mkpath ($io_dir);
+
+my $test_idx = 0;
+
+sub perform_test
+{
+    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
+    ok(
+        !system(
+        "quadp", "setup", $test_dir, "--dest-dir=./rendered"
+        ),
+        "Running quadp setup was succesful."
+    );
+
+    my $tmpl_dir = "$orig_dir/t/lib/bolded-nav-links/template";
+
+    fcopy("$tmpl_dir/Contents.pm", "$test_dir/Contents.pm",);
+    rmtree("$test_dir/src");
+    dircopy("$tmpl_dir/src", "$test_dir/src");
+
+    # TEST
+    ok(
+        !system("cd $test_dir && quadp render -a"),
+        "quadp render -a",
+    );
+
+    # TEST
+    like(
+        scalar(io->file("$test_dir/rendered/finale/books.html")->slurp),
+        qr{<b>Next</b>},
+        "Next link was bolded",
+    );
+
+    chdir($orig_dir);
+}
+
+perform_test();
+

installer/tests/perl/t/lib/bolded-nav-links/template/Contents.pm

+package Contents;
+
+use strict;
+
+my $contents =
+{
+    'title' => "My Lecture Title",
+    'subs' =>
+    [
+        {
+            'url' => "two.html",
+            'title' => "Child Node",
+        },
+        {
+            'url' => "finale",
+            'title' => "Finale",
+            'subs' =>
+            [
+                {
+                    'url' => "links.html",
+                    'title' => "Links",
+                },
+                {
+                    'url' => "books.html",
+                    'title' => "Books",
+                },
+            ],
+        },
+
+    ],
+    'images' =>
+    [
+        'style.css',
+    ],
+};
+
+sub get_contents
+{
+    return $contents;
+}
+
+1;

installer/tests/perl/t/lib/bolded-nav-links/template/src/finale/books.html.wml

+#include 'template.wml'
+
+<ol>
+<li>
+Hi there!
+</li>
+</ol>

installer/tests/perl/t/lib/bolded-nav-links/template/src/finale/links.html.wml

+#include 'template.wml'
+
+<ol>
+<li>
+Hi there!
+</li>
+</ol>

installer/tests/perl/t/lib/bolded-nav-links/template/src/index.html.wml

+#include 'template.wml'
+
+<h1><font color="red">FILL IN</font></h1>

installer/tests/perl/t/lib/bolded-nav-links/template/src/style.css

+a.nav:link { color: green }
+a.nav:visited { color: #FF1493 /* The DeepPink Colour */  }
+a.nav:active { color: blue }
+b.nav { color : Black}
+b.plain {color : Black}
+a:hover { background-color: yellow }
+body { background-color : #FFFFFF }
+a.contents:active { color: red }
+table.mycode { border-style : solid ; border-width : thin }
+td.mycode { width : 60em }
+table.mydemo { border-style : solid ; border-width : thin }
+td.mydemo { width : 60em }
+table.note { border-style : double ; border-width : 3em}
+h3.notbold { font-weight: normal }
+font.menupath { font-family: monospace }
+b.menupathcomponent { color: red }
+font.menupathseparator { color: green }
+tt.mycode { color : #8A2BE2 /* The BlueViolet Colour */ }
+tt { color : #8A2BE2 /* The BlueViolet Colour */ }
+li.notbold { padding-bottom : 15em }
+ul.contents { list-style-type : none ; padding-left : 2em }
+ul.contentsmain { list-style-type : none ; padding-left : 0em }
+ul.point { font-size : large }
+ol.point { font-size : large }
+table.frame { border-style : solid ; border-width : thin }
+table.bordered { border-style : solid ; border-width : thin }
+table.bordered td { border-style : solid ; border-width : thin }
+/* Styles for gvim output */
+.c29 { color: #ff00ff; }
+.c28 { color: #0000ff; }
+.c31 { color: #008b8b; }
+.c30 { color: #6a5acd; }
+.c32 { color: #a52a2a; font-weight: bold; }
+.c34 { color: #2e8b57; font-weight: bold; }

installer/tests/perl/t/lib/bolded-nav-links/template/src/two.html.wml

+#include 'template.wml'
+
+<ol>
+<li>
+Hi there!
+</li>
+</ol>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.