Skip to content

Commit

Permalink
Several fixes so we can run a toy example again
Browse files Browse the repository at this point in the history
  • Loading branch information
Whiteknight committed Sep 7, 2011
1 parent a4e0ae3 commit 7231fab
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
33 changes: 26 additions & 7 deletions src/harness/FileResult.winxed
Expand Up @@ -4,20 +4,21 @@ namespace Rosella { namespace Harness
{
var file;
var errdetails;
var status;
var failures;
var todo_passed;
var num_tests;
var passed_tests;
var status;

function FileResult(var file)
{
self.file = file;
self.failures = [];
self.todo_passed = [];
self.errdetails = null;
self.status = "PASSED";
file.set_result(self);
self.failures = [];
self.todo_passed = [];
self.passed_tests = [];
self.errdetails = null;
self.status = null;
}

/* Public Accessors
Expand All @@ -31,7 +32,14 @@ namespace Rosella { namespace Harness

function list_of_todo_passed() { return self.todo_passed; }

function status() { return self.status; }
function status()
{
if (self.status != null)
return self.status;
if (elements(self.failures) > 0)
return "FAILED";
return "PASSED";
}

function error_details() { return self.errdetails; }

Expand All @@ -53,15 +61,26 @@ namespace Rosella { namespace Harness

function add_pass(int num, int todo)
{
string msg = Rosella.String.sprintf("%s test %d", string(self.file), num);
if (todo == 1)
push(self.todo_passed, msg);
else
push(self.passed_tests, msg);
}

function add_fail(int num, int todo)
{
self.status = "FAILED";
string msg = Rosella.String.sprintf("%s test %d", string(self.file), num);
if (todo == 1)
push(self.passed_tests, msg);
else
push(self.failures, msg);
}

function set_plan(int num)
{
// TODO: Check bounds. Make sure we run this many tests
self.num_tests = num;
}
}
}}
6 changes: 2 additions & 4 deletions src/harness/TapParser.winxed
Expand Up @@ -53,7 +53,7 @@ namespace Rosella { namespace Harness
else if (r == "not" && l[i++] == "ok")
result = 0;
else
Rosella.IO.sayf("Unknown TAP sequence: '%s'", join(" ", r));
Rosella.Error.invalid(__FUNCTION__, "Unknown TAP sequence: '%s' ('%s', '%s')", join(" ", l), r, l[1]);
int num = int(l[i++]);
while(i < elements(l) && l[i] != "#")
i++;
Expand All @@ -66,19 +66,17 @@ namespace Rosella { namespace Harness

function get_lines()
{
int cclass_whitespace = Rosella.String.get_character_class("whitespace");
var lines = [[]];
int i = 0;
while(self.tokenizer.has_tokens()) {
var t = self.tokenizer.get_token();
string d = t.data();
Rosella.IO.sayf("'%s' : %d", d, int(t.metadata()));
if (indexof("\n", d) != -1) {
i++;
lines[i] = [];
continue;
}
if (int(t.metadata()) != cclass_whitespace)
if (int(t.metadata()) != 0)
push(lines[i], d);
}
return lines;
Expand Down
6 changes: 6 additions & 0 deletions src/harness/TestFile.winxed
Expand Up @@ -3,6 +3,7 @@ namespace Rosella { namespace Harness
class TestFile
{
var filename;
var result;

function TestFile(string filename)
{
Expand All @@ -17,6 +18,11 @@ namespace Rosella { namespace Harness
/* Compile and execute routines
*/

function set_result(var result)
{
self.result = result;
}

function compile_test(string filename)
{
Rosella.Error.must_subclass(__CLASS__);
Expand Down
2 changes: 1 addition & 1 deletion src/harness/TestRun.winxed
Expand Up @@ -75,7 +75,7 @@ namespace Rosella { namespace Harness
function files_by_status(string status)
{
return Rosella.Query.as_queryable(self.tests).filter(function(test) {
return test.status() == status;
return test.result.status() == status;
}).data();
}

Expand Down

0 comments on commit 7231fab

Please sign in to comment.