I think this fixes tests, and makes them runnable from continuous integration.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3161 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2016-03-13 13:37:58 +00:00
parent ebe54b6117
commit 7a16a1d65c
15 changed files with 97 additions and 124 deletions

View File

@ -257,7 +257,8 @@ void Task::kill() {
}
}
void Task::execute(const char* fileName) {
bool Task::execute(const char* fileName) {
bool executed = false;
v8::Isolate::Scope isolateScope(_isolate);
v8::HandleScope handleScope(_isolate);
v8::Context::Scope contextScope(v8::Local<v8::Context>::New(_isolate, _context));
@ -274,6 +275,7 @@ void Task::execute(const char* fileName) {
if (!script.IsEmpty()) {
script->Run();
std::cout << "Script " << fileName << " completed\n";
executed = true;
} else {
std::cerr << "Failed to compile: " << fileName << ".\n";
}
@ -283,6 +285,7 @@ void Task::execute(const char* fileName) {
message += fileName;
_isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(_isolate, message.c_str())));
}
return executed;
}
void Task::invokeExport(const v8::FunctionCallbackInfo<v8::Value>& args) {

View File

@ -74,7 +74,7 @@ public:
void configureFromStdin();
void setTrusted(bool trusted) { _trusted = trusted; }
void execute(const char* fileName);
bool execute(const char* fileName);
void activate();
void run();

View File

@ -55,3 +55,8 @@ TaskTryCatch::~TaskTryCatch() {
}
}
}
bool TaskTryCatch::hasCaught()
{
return _tryCatch.HasCaught();
}

View File

@ -9,6 +9,7 @@ class TaskTryCatch {
public:
TaskTryCatch(Task* task);
~TaskTryCatch();
bool hasCaught();
private:
v8::TryCatch _tryCatch;

View File

@ -18,6 +18,7 @@ v8::Platform* gPlatform = 0;
int main(int argc, char* argv[]) {
int result = 0;
uv_setup_args(argc, argv);
TaskStub::initialize();
v8::V8::InitializeICU();
@ -64,12 +65,23 @@ int main(int argc, char* argv[]) {
v8::HandleScope handleScope(task.getIsolate());
v8::Context::Scope contextScope(task.getContext());
TaskTryCatch tryCatch(&task);
task.execute(coreTask);
if (!task.execute(coreTask))
{
result = -1;
}
if (tryCatch.hasCaught())
{
result = -2;
}
}
if (result == 0)
{
task.run();
}
task.run();
}
v8::V8::Dispose();
return 0;
return result;
}