0

motivation:

I have a test that needs to write a short temp file (must be < 107 characters). Currently the test is using

Files.createTempFile(null,".sock");

issue

which when running I'm trying to figure out the java.io.tmp value when running java test using bazel. The different options I have is:

  • Setting $TEST_TMPDIR (or without)
  • Using "local"=True (or without)

Here is the result:

# local=True + TEST_TMPDIR=/btmp:
/btmp/_bazel_ors/719f891d5db9fd5e73ade25b0c847fd1/execroot/__main__/_tmp/8be6e61521c57d3cfc8585efa880e1ac/1638063256753562848.sock

# local=False + TEST_TMPDIR=/btmp:
/btmp/_bazel_ors/719f891d5db9fd5e73ade25b0c847fd1/bazel-sandbox/5561433121200492142/execroot/__main__/_tmp/8be6e61521c57d3cfc8585efa880e1ac/4867903879018296623.sock

# local=True , no TEST_TMPDIR:
/private/var/tmp/_bazel_ors/719f891d5db9fd5e73ade25b0c847fd1/execroot/__main__/_tmp/8be6e61521c57d3cfc8585efa880e1ac/984443110479498941.sock

# local=False , no TEST_TMPDIR:
/private/var/tmp/_bazel_ors/719f891d5db9fd5e73ade25b0c847fd1/bazel-sandbox/6199384508952843116/execroot/__main__/_tmp/8be6e61521c57d3cfc8585efa880e1ac/4588114364301475150.sock

Seems like the shortest temp prefix I can get is:

/private/var/tmp/_bazel_ors/719f891d5db9fd5e73ade25b0c847fd1/execroot/__main__/_tmp/

which is 85 char long (way too long for my needs).

How can I safely play with this configuration and make it a lot shorter?


note:

My env is mac osx sierra and I'm running bazel 0.5.1

0

2 Answers 2

2

Solvable by adding this to the jvm_flags of the test target:

"jvm_flags" = ["-Djava.io.tmpdir=/tmp"],

But note that it would make the test less hermetic

Sign up to request clarification or add additional context in comments.

Comments

1

You can also tell bazel where it should store its outputs --output_base=/tmp/foo.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.