forked from cory/tildefriends
Fixed a segfault I noticed related to require and shutdown.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3292 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
085b44752a
commit
313efbe2d6
@ -106,6 +106,7 @@ Task::Task() {
|
|||||||
Task::~Task() {
|
Task::~Task() {
|
||||||
_exportObject.Reset();
|
_exportObject.Reset();
|
||||||
_sourceObject.Reset();
|
_sourceObject.Reset();
|
||||||
|
_scriptExports.clear();
|
||||||
|
|
||||||
{
|
{
|
||||||
v8::Isolate::Scope isolateScope(_isolate);
|
v8::Isolate::Scope isolateScope(_isolate);
|
||||||
@ -286,7 +287,7 @@ bool Task::execute(const char* fileName) {
|
|||||||
if (position != std::string::npos) {
|
if (position != std::string::npos) {
|
||||||
path.resize(position + 1);
|
path.resize(position + 1);
|
||||||
} else {
|
} else {
|
||||||
path = ".";
|
path = "./";
|
||||||
}
|
}
|
||||||
_path.push_back(path);
|
_path.push_back(path);
|
||||||
}
|
}
|
||||||
@ -721,6 +722,7 @@ std::string Task::resolveRequire(const std::string& require) {
|
|||||||
if (test.size() && (require.size() < 3 || require.rfind(".js") != require.size() - 3)) {
|
if (test.size() && (require.size() < 3 || require.rfind(".js") != require.size() - 3)) {
|
||||||
test += ".js";
|
test += ".js";
|
||||||
}
|
}
|
||||||
|
std::cout << "Testing " << test << "\n";
|
||||||
uv_fs_t request;
|
uv_fs_t request;
|
||||||
if (uv_fs_access(_loop, &request, test.c_str(), R_OK, 0) == 0) {
|
if (uv_fs_access(_loop, &request, test.c_str(), R_OK, 0) == 0) {
|
||||||
result = test;
|
result = test;
|
||||||
|
28
tests/11-require
Normal file
28
tests/11-require
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cat > required.js << EOF
|
||||||
|
function foo() {
|
||||||
|
return 12345;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.foo = foo;
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > test.js << EOF
|
||||||
|
if (require("required").foo() != 12345) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
var gotError = false;
|
||||||
|
try {
|
||||||
|
require("missing");
|
||||||
|
} catch (error) {
|
||||||
|
print("nope");
|
||||||
|
gotError = true;
|
||||||
|
}
|
||||||
|
if (!gotError) {
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
exit(0);
|
||||||
|
EOF
|
||||||
|
|
||||||
|
$TILDEFRIENDS test.js
|
10
tests/12-exit
Normal file
10
tests/12-exit
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cat > blah.js << EOF
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > test.js << EOF
|
||||||
|
require("blah");
|
||||||
|
EOF
|
||||||
|
|
||||||
|
$TILDEFRIENDS test.js
|
Loading…
Reference in New Issue
Block a user