1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-30 11:16:38 -05:00
denoland-deno/libdeno/test.cc

32 lines
913 B
C++
Raw Normal View History

2019-01-21 14:03:30 -05:00
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
#include "test.h"
2019-01-29 21:31:59 -05:00
#include <string>
#include "file_util.h"
deno_buf snapshot = {nullptr, 0, nullptr, 0, 0};
int main(int argc, char** argv) {
2018-11-01 08:05:21 -04:00
// Locate the snapshot.
std::string exe_path;
if (!deno::ExePath(&exe_path)) {
std::cerr << "deno::ExePath() failed" << std::endl;
return 1;
}
std::string snapshot_path = deno::Dirname(exe_path) + SNAPSHOT_PATH;
// Load the snapshot.
std::string contents;
2018-11-01 08:05:21 -04:00
if (!deno::ReadFileToString(snapshot_path.c_str(), &contents)) {
std::cerr << "Failed to read snapshot from " << snapshot_path << std::endl;
return 1;
}
snapshot.data_ptr =
reinterpret_cast<uint8_t*>(const_cast<char*>(contents.c_str()));
snapshot.data_len = contents.size();
testing::InitGoogleTest(&argc, argv);
deno_init();
deno_set_v8_flags(&argc, argv);
return RUN_ALL_TESTS();
}