Permalink
Browse files

core, refactor: do not generate coverage report of non-absolute path …

…files.
  • Loading branch information...
xicilion committed May 27, 2018
1 parent 55f207e commit 47a5f79c6e13117b8f4a47ebf68999705ef96155
View
@@ -212,7 +212,6 @@ class SandBox : public SandBox_base {
public:
std::vector<obj_ptr<ExtLoader>> m_loaders;
bool m_global;
bool m_init;
};
} /* namespace fibjs */
@@ -23,6 +23,8 @@
namespace fibjs {
bool path_isAbsolute(exlib::string path);
void InvokeApiInterruptCallbacks(v8::Isolate* isolate)
{
v8::internal::Isolate* v8_isolate = (v8::internal::Isolate*)isolate;
@@ -169,6 +171,9 @@ void WriteLcovData(v8::Isolate* isolate, FILE* file)
if (!script->Name().ToLocal(&name))
continue;
std::string file_name = ToSTLString(isolate, name);
if (!path_isAbsolute(file_name))
continue;
fprintf(file, "SF:%s\n", file_name.c_str());
std::vector<uint32_t> lines;
for (size_t j = 0; j < script_data.FunctionCount(); j++) {
@@ -12,6 +12,13 @@ namespace fibjs {
#ifndef _WIN32
DECLARE_MODULE_EX(path, path_posix);
bool path_isAbsolute(exlib::string path)
{
bool retVal;
path_posix_base::isAbsolute(path, retVal);
return retVal;
}
#endif
result_t path_posix_base::normalize(exlib::string path, exlib::string& retVal)
@@ -12,6 +12,13 @@ namespace fibjs {
#ifdef _WIN32
DECLARE_MODULE_EX(path, path_win32);
bool path_isAbsolute(exlib::string path)
{
bool retVal;
path_win32_base::isAbsolute(path, retVal);
return retVal;
}
#endif
result_t path_win32_base::normalize(exlib::string path, exlib::string& retVal)
@@ -73,7 +73,6 @@ SandBox::SandBox()
m_loaders.push_back(loader);
m_global = false;
m_init = false;
}
void SandBox::initGlobal(v8::Local<v8::Object> global)
@@ -111,13 +110,8 @@ RootModule* RootModule::g_root = NULL;
void SandBox::initRoot()
{
m_init = true;
Isolate* isolate = holder();
if (g_cov && isolate->m_id == 1)
pauseCoverage(isolate->m_isolate);
RootModule* pModule = RootModule::g_root;
while (pModule) {
@@ -130,14 +124,6 @@ void SandBox::initRoot()
v8::Local<v8::Object> _buffer = Buffer_base::class_info().getModule(isolate);
_buffer->Set(isolate->NewString("Buffer"), _buffer);
v8::Local<v8::Value> m;
run_module("stream.js", "/", m);
m_init = false;
if (g_cov && isolate->m_id == 1)
beginCoverage(isolate->m_isolate);
}
result_t SandBox::add(exlib::string id, v8::Local<v8::Value> mod)
@@ -230,30 +230,28 @@ result_t SandBox::resolveModule(exlib::string base, exlib::string& id, obj_ptr<B
int32_t i;
if (!base.empty()) {
if (m_init) {
fname = id;
fname = id;
if (fname.substr(fname.length() - 3) == ".js")
fname.resize(fname.length() - 3);
if (fname.substr(fname.length() - 3) == ".js")
fname.resize(fname.length() - 3);
#ifdef _WIN32
{
exlib::string fname1 = fname;
int32_t sz = (int32_t)fname1.length();
const char* buf = fname1.c_str();
for (int32_t i = 0; i < sz; i++)
if (buf[i] == PATH_SLASH)
fname[i] = '/';
}
{
exlib::string fname1 = fname;
int32_t sz = (int32_t)fname1.length();
const char* buf = fname1.c_str();
for (int32_t i = 0; i < sz; i++)
if (buf[i] == PATH_SLASH)
fname[i] = '/';
}
#endif
for (i = 0; opt_tools[i] && qstrcmp(opt_tools[i], fname.c_str()); i += 2)
;
for (i = 0; opt_tools[i] && qstrcmp(opt_tools[i], fname.c_str()); i += 2)
;
if (opt_tools[i]) {
data = new Buffer(opt_tools[i + 1]);
return 0;
}
if (opt_tools[i]) {
data = new Buffer(opt_tools[i + 1]);
return 0;
}
if (isPathSlash(base[base.length() - 1]))

0 comments on commit 47a5f79

Please sign in to comment.