Skip to content

Commit

Permalink
Rolled wikitest.js functionality into tiddlywiki.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Ruston committed Jan 3, 2012
1 parent 8dd7315 commit ffbed4e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 61 deletions.
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ node tiddlywiki.js --recipe $PWD/test/tiddlywiki.2.6.5/source/tiddlywiki.com/ind
diff tmp/newcooked/index.html test/tiddlywiki.2.6.5/target/index.2.6.5.html

# Run the wikification tests
node wikitest.js test/wikitests/
node tiddlywiki.js --wikitest test/wikitests/

jshint *.js
jshint js
33 changes: 33 additions & 0 deletions tiddlywiki.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,39 @@ var commandLineSwitches = {
handler: function(args,callback) {
process.nextTick(function() {callback(null);});
}
},
wikitest: {
args: {min: 1, max: 1},
handler: function(args,callback) {
var testdirectory = args[0],
files = fs.readdirSync(testdirectory),
titles = [],
f,t,extname,basename;
for(f=0; f<files.length; f++) {
extname = path.extname(files[f]);
if(extname === ".tid") {
var tiddlers = app.store.deserializeTiddlers(extname,fs.readFileSync(path.resolve(testdirectory,files[f]),"utf8"));
if(tiddlers.length > 1) {
throw "Cannot use .JSON files";
}
app.store.addTiddler(new Tiddler(tiddlers[0]));
titles.push(tiddlers[0].title);
}
}
for(t=0; t<titles.length; t++) {
var htmlTarget = fs.readFileSync(path.resolve(testdirectory,titles[t] + ".html"),"utf8"),
plainTarget = fs.readFileSync(path.resolve(testdirectory,titles[t] + ".txt"),"utf8"),
tiddler = app.store.getTiddler(titles[t]),
htmlRender = app.store.renderTiddler("text/html",titles[t]),
plainRender = app.store.renderTiddler("text/plain",titles[t]);
if(htmlTarget !== htmlRender) {
console.error("Tiddler %s html error\nTarget: %s\nFound: %s\n",titles[t],htmlTarget,htmlRender);
}
if(plainTarget !== plainRender) {
console.error("Tiddler %s plain text error\nTarget: %s\nFound: %s\n",titles[t],plainTarget,plainRender);
}
}
}
}
};

Expand Down
60 changes: 0 additions & 60 deletions wikitest.js

This file was deleted.

0 comments on commit ffbed4e

Please sign in to comment.