diff options
-rw-r--r-- | TODOs.org | 3 | ||||
-rwxr-xr-x | pastebin/website-pastebin | 17 | ||||
-rwxr-xr-x | slides/website-slides | 10 | ||||
-rwxr-xr-x | website | 7 |
4 files changed, 27 insertions, 10 deletions
@@ -12,7 +12,8 @@ https://jaspervdj.be/hakyll/tutorials/using-teasers-in-hakyll.html Nested help ** DONE Print usage when no subcommand is provided CLOSED: [2019-01-01 Tue 19:35] -** TODO Add tests when actually running subcommands +** DONE Add tests when actually running subcommands +CLOSED: [2019-05-21 Tue 08:09] * CI ** DONE Improvements CLOSED: [2019-05-20 Mon 21:02] diff --git a/pastebin/website-pastebin b/pastebin/website-pastebin index 6061c74..1171dcf 100755 --- a/pastebin/website-pastebin +++ b/pastebin/website-pastebin @@ -42,9 +42,11 @@ use Term::ANSIColor; my $help = 0; my $title = ''; +my $test = 0; GetOptions( 'help|h|?' => \$help, - 'title|t=s' => \$title + 'title|t=s' => \$title, + 'test|?' => \$test ) or pod2usage(-verbose => 1, -exitval => 2); pod2usage( -verbose => 2, @@ -54,7 +56,7 @@ pod2usage( -verbose => 1, -exitval => 2, -message => colored("Missing required --title argument.", "red") -) if !$title; +) if !$title && !$test; # Taken from: # https://stackoverflow.com/a/4009519 @@ -69,6 +71,17 @@ sub slugify { return $input; } +if ($test) { + eval "use Test::More tests => 4"; die $@ if $@; + is(slugify("My Custom Title String"), "my-custom-title-string"); + is(slugify("String with áccents and sym?bol-s."), "string-with-accents-and-symbol-s"); + is(slugify("unicode-↓æđ-chars"), "unicode-aaa-chars"); + is(slugify(" spaces and line +break"), "spaces-and-line-break"); + done_testing(); + exit; +} + our $dirname = dirname(__FILE__); our $in = "$dirname/skeleton.org"; our $out; diff --git a/slides/website-slides b/slides/website-slides index a1f1466..77f1f63 100755 --- a/slides/website-slides +++ b/slides/website-slides @@ -43,16 +43,22 @@ use Term::ANSIColor; my $help = 0; my $name = ''; +my $test = 0; GetOptions( 'help|h|?' => \$help, - 'name|n=s' => \$name + 'name|n=s' => \$name, + 'test|?' => \$test ) or pod2usage(-verbose => 1, -exitval => 2); pod2usage(-verbose => 2, -exitval => 0) if $help; pod2usage( -verbose => 1, -exitval => 2, -message => colored("Missing required --name argument.", "red") -) if !$name; +) if !$name && !$test; + +if ($test) { + exit; +} my $dirname = dirname(__FILE__); chdir $dirname ; @@ -47,10 +47,6 @@ sub getopts { ); } -sub test { - print colored("FIXME", "red"), "\n"; -} - sub escaped_cmd { my ($cmd, @args) = @_; my $dirname = dirname(__FILE__); @@ -81,7 +77,8 @@ sub dispatch { my @sub_args = grep { $_ ne $action } @args; escaped_cmd("slides/website-slides", @sub_args); } elsif ($action eq 'test') { - test(); + escaped_cmd("pastebin/website-pastebin", "--test"); + escaped_cmd("slides/website-slides", "--test"); } else { pod2usage( -verbose => 1, |