v8/test/test262-es6/harness-adapt.js
rossberg@chromium.org cc07503bd9 test/test262: update testcfg.py for new test262
testcfg.py:

- update revision and MD5
- remove non-mandatory harness files
- use test parser distributed with test262
- new attribute `suite.harnesspath`
- new method GetIncludesForTest
- GetSourceForTest: cache source on testcase
- IsNegativeTest: use parseTestRecord
- use 7-char sha hash [1]
- DRY setting up paths to test262 suite, harness, etc
- clean up helper fns

harness-adapter.js:

- add $DONE function to adapter [2]

1: github tar file has 7-char sha embedded in dir name
script cannot find directory to rename if they don't match exactly

2: test262 uses a `$DONE` function for async tests with
semantics like those of mocha's `done`.

Briefly: done(arg) => if (arg) { /* failure */ }

Implemented a version of this for v8, using v8-specific
api (`print`, `quit`)

BUG=v8:3513
LOG=N
R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/478163002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23313 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-08-22 13:00:10 +00:00

92 lines
3.0 KiB
JavaScript

// Copyright 2011 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
function fnGlobalObject() { return (function() { return this; })(); }
var ES5Harness = (function() {
var currentTest = {};
var $this = this;
function Test262Error(id, path, description, codeString,
preconditionString, result, error) {
this.id = id;
this.path = path;
this.description = description;
this.result = result;
this.error = error;
this.code = codeString;
this.pre = preconditionString;
}
Test262Error.prototype.toString = function() {
return this.result + " " + this.error;
}
function registerTest(test) {
if (!(test.precondition && !test.precondition())) {
var error;
try {
var res = test.test.call($this);
} catch(e) {
res = 'fail';
error = e;
}
var retVal = /^s/i.test(test.id)
? (res === true || typeof res == 'undefined' ? 'pass' : 'fail')
: (res === true ? 'pass' : 'fail');
if (retVal != 'pass') {
var precondition = (test.precondition !== undefined)
? test.precondition.toString()
: '';
throw new Test262Error(
test.id,
test.path,
test.description,
test.test.toString(),
precondition,
retVal,
error);
}
}
}
return {
registerTest: registerTest
}
})();
function $DONE(arg){
if (arg) {
print('FAILED! Error: ' + arg);
quit(1);
}
quit(0);
};