2023-07-04 20:07:28 +08:00
|
|
|
From 364aed58e083e305f3f9ffc5bcacf9536f2472ab Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: cpovirk <cpovirk@google.com>
|
|
|
|
|
Date: Tue, 25 Apr 2023 10:00:41 -0700
|
|
|
|
|
Subject: [PATCH] Split the tests for `Files.createTempDir` into a separate
|
|
|
|
|
file.
|
|
|
|
|
|
|
|
|
|
This makes it easier to run them a second time under a newer Android emulator in our internal tests.
|
|
|
|
|
|
|
|
|
|
RELNOTES=n/a
|
|
|
|
|
PiperOrigin-RevId: 526998248
|
|
|
|
|
|
|
|
|
|
Origin: https://github.com/google/guava/commit/364aed58e083e305f3f9ffc5bcacf9536f2472ab
|
|
|
|
|
---
|
2023-09-27 16:59:01 +08:00
|
|
|
.../common/io/FilesCreateTempDirTest.java | 38 +++++++++++++++++++
|
|
|
|
|
.../test/com/google/common/io/FilesTest.java | 15 +++-----
|
|
|
|
|
.../common/io/FilesCreateTempDirTest.java | 37 ++++++++++++++++++
|
|
|
|
|
.../test/com/google/common/io/FilesTest.java | 15 +++-----
|
|
|
|
|
4 files changed, 87 insertions(+), 18 deletions(-)
|
|
|
|
|
create mode 100644 android/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java
|
2023-07-04 20:07:28 +08:00
|
|
|
create mode 100644 guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java
|
|
|
|
|
|
2023-09-27 16:59:01 +08:00
|
|
|
diff --git a/android/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java b/android/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java
|
2023-07-04 20:07:28 +08:00
|
|
|
new file mode 100644
|
2023-09-27 16:59:01 +08:00
|
|
|
index 0000000..109342a
|
2023-07-04 20:07:28 +08:00
|
|
|
--- /dev/null
|
2023-09-27 16:59:01 +08:00
|
|
|
+++ b/android/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java
|
|
|
|
|
@@ -0,0 +1,38 @@
|
2023-07-04 20:07:28 +08:00
|
|
|
+/*
|
|
|
|
|
+ * Copyright (C) 2007 The Guava Authors
|
|
|
|
|
+ *
|
|
|
|
|
+ * Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
+ * you may not use this file except in compliance with the License.
|
|
|
|
|
+ * You may obtain a copy of the License at
|
|
|
|
|
+ *
|
|
|
|
|
+ * http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
+ *
|
|
|
|
|
+ * Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
+ * distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
+ * See the License for the specific language governing permissions and
|
|
|
|
|
+ * limitations under the License.
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+package com.google.common.io;
|
|
|
|
|
+
|
|
|
|
|
+import static com.google.common.truth.Truth.assertThat;
|
|
|
|
|
+
|
|
|
|
|
+import java.io.File;
|
2023-09-27 16:59:01 +08:00
|
|
|
+import junit.framework.TestCase;
|
2023-07-04 20:07:28 +08:00
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Unit test for {@link Files#createTempDir}.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author Chris Nokleberg
|
|
|
|
|
+ */
|
|
|
|
|
+
|
2023-09-27 16:59:01 +08:00
|
|
|
+public class FilesCreateTempDirTest extends TestCase {
|
2023-07-04 20:07:28 +08:00
|
|
|
+ public void testCreateTempDir() {
|
|
|
|
|
+ File temp = Files.createTempDir();
|
|
|
|
|
+ assertTrue(temp.exists());
|
|
|
|
|
+ assertTrue(temp.isDirectory());
|
|
|
|
|
+ assertThat(temp.listFiles()).isEmpty();
|
|
|
|
|
+ assertTrue(temp.delete());
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
2023-09-27 16:59:01 +08:00
|
|
|
diff --git a/android/guava-tests/test/com/google/common/io/FilesTest.java b/android/guava-tests/test/com/google/common/io/FilesTest.java
|
|
|
|
|
index 8446da1..338059e 100644
|
|
|
|
|
--- a/android/guava-tests/test/com/google/common/io/FilesTest.java
|
|
|
|
|
+++ b/android/guava-tests/test/com/google/common/io/FilesTest.java
|
|
|
|
|
@@ -42,7 +42,12 @@ import junit.framework.TestSuite;
|
2023-07-04 20:07:28 +08:00
|
|
|
/**
|
|
|
|
|
* Unit test for {@link Files}.
|
|
|
|
|
*
|
|
|
|
|
- * <p>Note: {@link Files#fileTraverser()} is tested in {@link FilesFileTraverserTest}.
|
|
|
|
|
+ * <p>Some methods are tested in separate files:
|
|
|
|
|
+ *
|
|
|
|
|
+ * <ul>
|
|
|
|
|
+ * <li>{@link Files#fileTraverser()} is tested in {@link FilesFileTraverserTest}.
|
|
|
|
|
+ * <li>{@link Files#createTempDir()} is tested in {@link FilesCreateTempDirTest}.
|
|
|
|
|
+ * </ul>
|
|
|
|
|
*
|
|
|
|
|
* @author Chris Nokleberg
|
|
|
|
|
*/
|
2023-09-27 16:59:01 +08:00
|
|
|
@@ -357,14 +362,6 @@ public class FilesTest extends IoTestCase {
|
2023-07-04 20:07:28 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- public void testCreateTempDir() {
|
|
|
|
|
- File temp = Files.createTempDir();
|
|
|
|
|
- assertTrue(temp.exists());
|
|
|
|
|
- assertTrue(temp.isDirectory());
|
|
|
|
|
- assertThat(temp.listFiles()).isEmpty();
|
|
|
|
|
- assertTrue(temp.delete());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
public void testMove() throws IOException {
|
|
|
|
|
File i18nFile = getTestFile("i18n.txt");
|
|
|
|
|
File temp1 = createTempFile();
|
2023-09-27 16:59:01 +08:00
|
|
|
diff --git a/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java b/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java
|
2023-07-04 20:07:28 +08:00
|
|
|
new file mode 100644
|
2023-09-27 16:59:01 +08:00
|
|
|
index 0000000..557689e
|
2023-07-04 20:07:28 +08:00
|
|
|
--- /dev/null
|
2023-09-27 16:59:01 +08:00
|
|
|
+++ b/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java
|
|
|
|
|
@@ -0,0 +1,37 @@
|
2023-07-04 20:07:28 +08:00
|
|
|
+/*
|
2023-09-27 16:59:01 +08:00
|
|
|
+ * Copyright (C) 2007 The Guava Authors
|
2023-07-04 20:07:28 +08:00
|
|
|
+ *
|
|
|
|
|
+ * Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
+ * you may not use this file except in compliance with the License.
|
|
|
|
|
+ * You may obtain a copy of the License at
|
|
|
|
|
+ *
|
|
|
|
|
+ * http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
+ *
|
|
|
|
|
+ * Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
+ * distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
+ * See the License for the specific language governing permissions and
|
|
|
|
|
+ * limitations under the License.
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+package com.google.common.io;
|
|
|
|
|
+
|
2023-09-27 16:59:01 +08:00
|
|
|
+import static com.google.common.truth.Truth.assertThat;
|
2023-07-04 20:07:28 +08:00
|
|
|
+
|
2023-09-27 16:59:01 +08:00
|
|
|
+import java.io.File;
|
2023-07-04 20:07:28 +08:00
|
|
|
+
|
|
|
|
|
+/**
|
2023-09-27 16:59:01 +08:00
|
|
|
+ * Unit test for {@link Files#createTempDir}.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author Chris Nokleberg
|
2023-07-04 20:07:28 +08:00
|
|
|
+ */
|
2023-09-27 16:59:01 +08:00
|
|
|
+
|
|
|
|
|
+public class FilesCreateTempDirTest extends IoTestCase {
|
|
|
|
|
+ public void testCreateTempDir() {
|
|
|
|
|
+ File temp = Files.createTempDir();
|
|
|
|
|
+ assertTrue(temp.exists());
|
|
|
|
|
+ assertTrue(temp.isDirectory());
|
|
|
|
|
+ assertThat(temp.listFiles()).isEmpty();
|
|
|
|
|
+ assertTrue(temp.delete());
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
diff --git a/guava-tests/test/com/google/common/io/FilesTest.java b/guava-tests/test/com/google/common/io/FilesTest.java
|
|
|
|
|
index 8446da1..338059e 100644
|
|
|
|
|
--- a/guava-tests/test/com/google/common/io/FilesTest.java
|
|
|
|
|
+++ b/guava-tests/test/com/google/common/io/FilesTest.java
|
|
|
|
|
@@ -42,7 +42,12 @@ import junit.framework.TestSuite;
|
|
|
|
|
/**
|
|
|
|
|
* Unit test for {@link Files}.
|
|
|
|
|
*
|
|
|
|
|
- * <p>Note: {@link Files#fileTraverser()} is tested in {@link FilesFileTraverserTest}.
|
|
|
|
|
+ * <p>Some methods are tested in separate files:
|
|
|
|
|
+ *
|
|
|
|
|
+ * <ul>
|
|
|
|
|
+ * <li>{@link Files#fileTraverser()} is tested in {@link FilesFileTraverserTest}.
|
|
|
|
|
+ * <li>{@link Files#createTempDir()} is tested in {@link FilesCreateTempDirTest}.
|
|
|
|
|
+ * </ul>
|
|
|
|
|
*
|
|
|
|
|
* @author Chris Nokleberg
|
|
|
|
|
*/
|
|
|
|
|
@@ -357,14 +362,6 @@ public class FilesTest extends IoTestCase {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- public void testCreateTempDir() {
|
|
|
|
|
- File temp = Files.createTempDir();
|
|
|
|
|
- assertTrue(temp.exists());
|
|
|
|
|
- assertTrue(temp.isDirectory());
|
|
|
|
|
- assertThat(temp.listFiles()).isEmpty();
|
|
|
|
|
- assertTrue(temp.delete());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
public void testMove() throws IOException {
|
|
|
|
|
File i18nFile = getTestFile("i18n.txt");
|
|
|
|
|
File temp1 = createTempFile();
|
2023-07-04 20:07:28 +08:00
|
|
|
--
|
2023-09-27 16:59:01 +08:00
|
|
|
2.41.0
|
2023-07-04 20:07:28 +08:00
|
|
|
|