From 7f2e3695a6d1814120a6ce15c926ca902243dc38 Mon Sep 17 00:00:00 2001 From: jianglai Date: Fri, 16 Feb 2018 10:07:08 -0800 Subject: [PATCH] Respect system TMPDIR in GPG related tests With https://github.com/bazelbuild/bazel/issues/4376, bazel 0.10.0 now supports accessing system TMPDIR in its sandbox. Use this instead of hardcoding /tmp in BUILD rules to get around the gpg-agent path length restriction. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=186010932 --- javatests/google/registry/rde/BUILD | 4 ---- javatests/google/registry/testing/GpgSystemCommandRule.java | 4 +++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/javatests/google/registry/rde/BUILD b/javatests/google/registry/rde/BUILD index 6249b616b..6a5e98d6d 100644 --- a/javatests/google/registry/rde/BUILD +++ b/javatests/google/registry/rde/BUILD @@ -51,10 +51,6 @@ java_library( GenTestRules( name = "GeneratedTestRules", default_test_size = "large", - # TODO (b/63619837): stop using hardcoded /tmp once - # https://github.com/bazelbuild/bazel/issues/3215 is resolved. - # If /tmp is not accessible, try changing it to one that is. - jvm_flags = ["-Djava.io.tmpdir=/tmp"], test_files = glob( ["*Test.java"], exclude = ["RdeUploadActionTest.java"], diff --git a/javatests/google/registry/testing/GpgSystemCommandRule.java b/javatests/google/registry/testing/GpgSystemCommandRule.java index b68c03fea..b073a46b5 100644 --- a/javatests/google/registry/testing/GpgSystemCommandRule.java +++ b/javatests/google/registry/testing/GpgSystemCommandRule.java @@ -84,7 +84,9 @@ public final class GpgSystemCommandRule extends ExternalResource { @Override protected void before() throws IOException, InterruptedException { checkState(Objects.equals(cwd, DEV_NULL)); - cwd = File.createTempFile(TEMP_FILE_PREFIX, "", null); + File tmpRoot = null; + tmpRoot = new File(System.getenv("TMPDIR")); + cwd = File.createTempFile(TEMP_FILE_PREFIX, "", tmpRoot); cwd.delete(); cwd.mkdir(); conf = new File(cwd, ".gnupg");