home · contact · privacy
Rename generated meta files, test for them.
authorChristian Heller <c.heller@plomlompom.de>
Sat, 19 Nov 2016 21:01:58 +0000 (22:01 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 19 Nov 2016 21:01:58 +0000 (22:01 +0100)
16 files changed:
processor/author.do [deleted file]
processor/author.meta.do [new file with mode: 0644]
processor/default.html.do
processor/feed.xml.do
processor/index.html.do
processor/title.do [deleted file]
processor/title.meta.do [new file with mode: 0644]
processor/url.do [deleted file]
processor/url.meta.do [new file with mode: 0644]
processor/uuid.do [deleted file]
processor/uuid.meta.do [new file with mode: 0644]
test.sh
test/test_files/author.meta [new file with mode: 0644]
test/test_files/title.meta [new file with mode: 0644]
test/test_files/url.meta [new file with mode: 0644]
test/test_files/uuid.meta [new file with mode: 0644]

diff --git a/processor/author.do b/processor/author.do
deleted file mode 100644 (file)
index ed14e3f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-if [ ! -f "$1" ]; then
-  printf "Joe Sixpack"
-fi
diff --git a/processor/author.meta.do b/processor/author.meta.do
new file mode 100644 (file)
index 0000000..ed14e3f
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+if [ ! -f "$1" ]; then
+  printf "Joe Sixpack"
+fi
index 3ff413230f8babfdd13d5ab3569f741327abd435..2a457a5ad2eda05c2f47e9953357da48af5de818 100644 (file)
@@ -3,11 +3,12 @@
 # Pull in global dependencies.
 . ./helpers.sh
 intermediate_file="${1%.html}.intermediate"
-redo-ifchange title
+title_file=title.meta
+redo-ifchange "$title_file" 
 redo-ifchange "$intermediate_file"
 
 # Build entry data.
-blog_title=`read_and_escape_file title | head -1`
+blog_title=`read_and_escape_file "$title_file" | head -1`
 title_html=`cat "$intermediate_file" | head -1`
 title_plaintext=`echo "$title_html" | html2text`
 title_plaintext_escaped=`escape_html "$title_plaintext"`
index 2cdb7b20572f8ce86ede6331e765d788ab4e5e4b..14ead597b0f7d88f25d64a02af04683493483ef8 100644 (file)
@@ -2,21 +2,25 @@
 
 # Pull in global dependencies.
 . ./helpers.sh
-redo-ifchange url
-redo-ifchange author
-redo-ifchange uuid
-redo-ifchange title 
+url_file=url.meta
+author_file=author.meta
+uuid_file=uuid.meta
+title_file=title.meta
+redo-ifchange "$url_file"
+redo-ifchange "$author_file"
+redo-ifchange "$uuid_file"
+redo-ifchange "$title_file"
 
 # Build some variables. XML-escape even file contents that should not contain
 # dangerous characters, just to avoid any XML trouble.
-base_url=`cat url | head -1`
+base_url=`cat "$url_file" | head -1`
 url_protocol=`echo $base_url | cut -d ':' -f 1`
 url_basepath=`echo $base_url | cut -d '/' -f 3-`
 url_basepath_escaped=`escape_url "$url_basepath"`
 basepath="$url_protocol""://""$url_basepath_escaped"
-title=`read_and_escape_file title | head -1`
-author=`read_and_escape_file author | head -1`
-uuid=`read_and_escape_file uuid | head -1`
+title=`read_and_escape_file "$title_file" | head -1`
+author=`read_and_escape_file "$author_file" | head -1`
+uuid=`read_and_escape_file "$uuid_file" | head -1`
 
 # Write majority of feed head.
 cat << EOF
@@ -47,13 +51,13 @@ for file in $files; do
   # Build some variables and dependencies.
   intermediate_file="${file%.*}.intermediate"
   htmlfile=`escape_url "${file%.*}.html"`
+  uuid_file="${file%.*}.uuid"
   redo-ifchange "$intermediate_file"
-  redo-ifchange "$uuidfile"
+  redo-ifchange "$uuid_file"
   title=`read_and_escape_file "$intermediate_file" | head -1`
-  uuidfile="${file%.*}.uuid"
-  uuid=`read_and_escape_file "$uuidfile" | head -1`
+  uuid=`read_and_escape_file "$uuid_file" | head -1`
   body=`read_and_escape_file "$intermediate_file" | sed 1d`
-  published=`stat -c%y "$uuidfile"`
+  published=`stat -c%y "$uuid_file"`
   published_rfc3339=`date -u "+%Y-%m-%dT%TZ" -d "$published"`
 
   # Write entry.
index 8bf675139c2bad3907e924c726b5a3084dd7ed2c..2b71ffb486cd624f39c3eb12e9dcaaeb3c93e69c 100644 (file)
@@ -2,7 +2,8 @@
 
 # Pull in global dependencies.
 . ./helpers.sh
-redo-ifchange title
+title_file=title.meta
+redo-ifchange "$title_file"
 
 # Write index head.
 cat << EOF
@@ -10,7 +11,7 @@ cat << EOF
 <html>
 <head>
 EOF
-blog_title=`read_and_escape_file title | head -1`
+blog_title=`read_and_escape_file "$title_file" | head -1`
 printf "<title>%s</title>\n</head>\n<body>\n" "$blog_title"
 printf "<h1>%s</h1>\n<ul>\n" "$blog_title"
 
diff --git a/processor/title.do b/processor/title.do
deleted file mode 100644 (file)
index 082accf..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-if [ ! -f "$1" ]; then
-  printf "Yet another blog"
-fi
diff --git a/processor/title.meta.do b/processor/title.meta.do
new file mode 100644 (file)
index 0000000..082accf
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+if [ ! -f "$1" ]; then
+  printf "Yet another blog"
+fi
diff --git a/processor/url.do b/processor/url.do
deleted file mode 100644 (file)
index 4e4079f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-if [ ! -f "$1" ]; then
-  printf "http://example.org/"
-fi
diff --git a/processor/url.meta.do b/processor/url.meta.do
new file mode 100644 (file)
index 0000000..4e4079f
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+if [ ! -f "$1" ]; then
+  printf "http://example.org/"
+fi
diff --git a/processor/uuid.do b/processor/uuid.do
deleted file mode 100644 (file)
index ba9e919..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-if [ ! -f "$1" ]; then
-  uuidgen
-fi
diff --git a/processor/uuid.meta.do b/processor/uuid.meta.do
new file mode 100644 (file)
index 0000000..ba9e919
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+if [ ! -f "$1" ]; then
+  uuidgen
+fi
diff --git a/test.sh b/test.sh
index 97d0fbf1ccd88f6bad431d69044d67b04854907e..4daff6b7956f34aca09d651b662d31a093d6417e 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -18,3 +18,18 @@ for file in test/test_files/*.html; do
     echo "== test FAILURE =="
   fi
 done
+for file in test/test_files/*meta; do
+  if [ "$file" = "test/test_files/uuid.meta" ]; then
+    true
+    # TODO: validate UUID
+  else
+    cmp_file=`echo "$file" | sed 's/test_files/test_dir/'`
+    printf "== %s diff test ==\n" "$cmp_file"
+    diff "$file" "$cmp_file"
+    if [ "$?" = "0" ]; then
+      echo "== test SUCCESS =="
+    else
+      echo "== test FAILURE =="
+    fi
+  fi
+done
diff --git a/test/test_files/author.meta b/test/test_files/author.meta
new file mode 100644 (file)
index 0000000..5f36248
--- /dev/null
@@ -0,0 +1 @@
+Joe Sixpack
\ No newline at end of file
diff --git a/test/test_files/title.meta b/test/test_files/title.meta
new file mode 100644 (file)
index 0000000..4d35b7e
--- /dev/null
@@ -0,0 +1 @@
+Yet another blog
\ No newline at end of file
diff --git a/test/test_files/url.meta b/test/test_files/url.meta
new file mode 100644 (file)
index 0000000..673d303
--- /dev/null
@@ -0,0 +1 @@
+http://example.org/
\ No newline at end of file
diff --git a/test/test_files/uuid.meta b/test/test_files/uuid.meta
new file mode 100644 (file)
index 0000000..09e4abd
--- /dev/null
@@ -0,0 +1 @@
+438b364d-e7e9-4225-952e-1e9ae312026f