Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ doc/_build
doc/jsdoc
patches/doc/jsdoc
core-packages/*/doc/jsdoc
site-packages
*.pyc
*.old
*.orig
*(Autosaved)*
*.sublime-*
Empty file modified context.jsx
100644 → 100755
Empty file.
Empty file modified core-packages/__future__/lib/exceptions/index.jsx
100644 → 100755
Empty file.
Empty file modified core-packages/__future__/lib/ideas.txt
100644 → 100755
Empty file.
Empty file modified core-packages/__future__/lib/persistence/engines.jsx
100644 → 100755
Empty file.
Empty file modified core-packages/__future__/lib/persistence/index.jsx
100644 → 100755
Empty file.
Empty file modified core-packages/__future__/lib/preview/idea.txt
100644 → 100755
Empty file.
Empty file modified core-packages/http/doc/readme.rst
100644 → 100755
Empty file.
Empty file modified core-packages/http/lib/auth.jsx
100644 → 100755
Empty file.
Empty file modified core-packages/http/lib/browser.jsx
100644 → 100755
Empty file.
Empty file modified core-packages/http/lib/index.jsx
100644 → 100755
Empty file.
Empty file modified core-packages/http/lib/url.jsx
100644 → 100755
Empty file.
Empty file modified core-packages/http/test/http.specs
100644 → 100755
Empty file.
Empty file modified core-packages/io/lib/index.jsx
100644 → 100755
Empty file.
Empty file modified core-packages/io/lib/octals.jsx
100644 → 100755
Empty file.
Empty file modified core-packages/io/test/io.specs
100644 → 100755
Empty file.
Empty file modified core-packages/logging/doc/readme.rst
100644 → 100755
Empty file.
Empty file modified core-packages/logging/lib/index.jsx
100644 → 100755
Empty file.
Empty file modified core-packages/logging/test/logging.specs
100644 → 100755
Empty file.
Empty file modified core-packages/persistence/lib/index.jsx
100644 → 100755
Empty file.
Empty file modified core-packages/templating/doc/readme.rst
100644 → 100755
Empty file.
Empty file modified core-packages/templating/lib/index.jsx
100644 → 100755
Empty file.
Empty file modified core-packages/templating/test/templating.specs
100644 → 100755
Empty file.
Empty file modified core-packages/testing/doc/readme.rst
100644 → 100755
Empty file.
Empty file modified core-packages/testing/doc/unit-testing.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 88 additions & 25 deletions core-packages/testing/lib/index.jsx
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,64 @@ var Template = require("templating").Template;

var TestRunner = function () {
this._clean_results = function (suites, results) {
var self = this
var cleaned_results = suites.map(function(suite) {
var total = suite.children.length;
var passed = suite.children.filter(function(spec) {
return (results[spec.id].result == "passed");
}).length;


var specs = suite.children.map(function (spec) {
return {'name': spec.name,
'result': results[spec.id].result,
'messages': results[spec.id].messages
if(spec.type === 'suite'){
return self._clean_results([spec], results)[0]
}
else {

return {
'name': spec.name,
'result': results[spec.id].result,
'messages': results[spec.id].messages,
'type': 'spec'
}
}
});

var total = specs.reduce(function(a,b){
if(b.type === 'suite'){
return a + b.total
} else {
return a + 1
}
}, 0);
var passed = specs.reduce(function(a,b){
if(b.type === 'suite'){
return a + b.total
} else {
if(b.result == "passed"){
return a + 1
} else {
return a;
}
}
}, 0);

return {
'name': suite.name,
'passed': passed,
'failed': new Number(total - passed),
'total': total,
'specs': specs
'specs': specs,
'type': 'suite'
};
});
return cleaned_results;
}

this.run = function () {
if(this.results) return this.results;

var reporter = new jasmine.JsApiReporter();
jasmine.getEnv().addReporter(reporter);
jasmine.getEnv().execute();
return this._clean_results(reporter.suites_, reporter.results());
this.results = this._clean_results(reporter.suites_, reporter.results());
return this.results
}

this.get_environment = function () {
Expand All @@ -62,39 +92,72 @@ var TestRunner = function () {
});
}

// we'll add this into the html representation,
// we'll add this into the html representation,
// so people can upload structured test reports to our central server.
this.as_json = function () {


}

this.print_suite = function(suite){
var self = this;
suite.specs.forEach(function(spec) {
if(spec.type == 'suite'){
self.print_suite(spec)
}
else {
$.writeln("\t" + spec.result.toUpperCase() + "\t" + spec.name);
if(spec.result != 'passed'){
$.writeln('\t\t'+spec.messages.join('\n\t\t'))
}
}
});
}

this.to_console = function () {
var results = this.run();

var self = this
results.forEach(function(suite) {
$.writeln("\nSuite: {} \tran {} tests, {} failure(s)".format(suite.name, suite.total, suite.failed));
suite.specs.forEach(function(spec) {
$.writeln("\t" + spec.result.toUpperCase() + "\t" + spec.name);
});
var passed = suite.specs.filter(function(s){ return s.result == 'passed' }).length || '0';
var failed = suite.specs.filter(function(s){ return s.result != 'passed' }).length || '0';
$.writeln("\nSuite: {} \tran {} tests, {} success, {} failure(s)".format(suite.name, suite.total, passed, failed));
self.print_suite(suite)
});
}

this.to_log = function () {
// todo
}

this.flatten = function(specs, res) {
res = res || [];
var self = this
specs.forEach(function(el){
if(el.type === 'suite'){
self.flatten(el.specs, res)
} else {
res.push(el)
}
})

return res;
}

this.to_html = function (filename) {
// some background info
var datetime = new Date();
var date = datetime.toDateString();
var time = "{}:{}".format(datetime.getHours(), datetime.getMinutes());
var environment = this.get_environment();
var environment = this.get_environment();

// run tests
var results = this.run();

var self = this

// tidy up results
results.forEach(function(suite) {
var prevSpecs = self.flatten(suite.specs);

suite.specs = prevSpecs;
suite.specs.forEach(function(spec) {
if (spec.result == 'failed') {
var messages = spec.messages.reject(function (message) {
Expand All @@ -106,15 +169,15 @@ var TestRunner = function () {
}
});
});

var duration = ((new Date().getTime() - datetime.getTime())/1000).toFixed(2);

var template = new Template("report.html", module);
var template = new Template("report.html", module);
template.render({
'date': date,
'time': time,
'duration': duration,
'suites': results,
'date': date,
'time': time,
'duration': duration,
'suites': results,
'total': results.sum('total'),
'fails': results.sum('failed'),
'passes': results.sum('passed'),
Expand All @@ -130,4 +193,4 @@ var TestRunner = function () {
}
}

exports.tests = new TestRunner();
exports.tests = new TestRunner();
Empty file modified core-packages/testing/templates/partial.environment.html
100644 → 100755
Empty file.
Empty file modified core-packages/testing/templates/partial.suite.html
100644 → 100755
Empty file.
Empty file modified core-packages/testing/templates/partial.test.html
100644 → 100755
Empty file.
Empty file modified core-packages/testing/templates/report.html
100644 → 100755
Empty file.
Empty file modified core-packages/ui/doc/layout.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified core-packages/ui/doc/readme.rst
100644 → 100755
Empty file.
Empty file modified core-packages/ui/doc/reference.rst
100644 → 100755
Empty file.
Empty file modified core-packages/ui/lib/_ideas_.jsx
100644 → 100755
Empty file.
Loading