Skip to content

Commit

Permalink
Make it possible to run JSBigString tests
Browse files Browse the repository at this point in the history
Summary: Add a target for JSBigString tests that can be run with a normal `buck test` invocation. Also fix an issue in the test when `getenv` returns null by defaulting to `/tmp`.

Reviewed By: ridiculousfish

Differential Revision: D14716270

fbshipit-source-id: f2eb6d3aab93c32a4b41f5786aedd04a70468d75
  • Loading branch information
kodafb authored and facebook-github-bot committed Apr 2, 2019
1 parent 17dbf98 commit 2387d7d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 14 additions & 0 deletions ReactCommon/cxxreact/tests/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,17 @@ fb_xplat_cxx_test(
react_native_xplat_target("cxxreact:jsbigstring"),
],
)

fb_xplat_cxx_test(
name = "jsbigstring_test",
srcs = ["jsbigstring.cpp"],
compiler_flags = [
"-fexceptions",
"-frtti",
],
deps = [
"fbsource//xplat/folly:molly",
"fbsource//xplat/third-party/gmock:gtest",
react_native_xplat_target("cxxreact:jsbigstring"),
],
)
5 changes: 4 additions & 1 deletion ReactCommon/cxxreact/tests/jsbigstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ using namespace facebook::react;
namespace {
int tempFileFromString(std::string contents)
{
std::string tmp {getenv("TMPDIR")};
const char *tmpDir = getenv("TMPDIR");
if (tmpDir == nullptr)
tmpDir = "/tmp";
std::string tmp {tmpDir};
tmp += "/temp.XXXXXX";

std::vector<char> tmpBuf {tmp.begin(), tmp.end()};
Expand Down

0 comments on commit 2387d7d

Please sign in to comment.