Skip to content

Commit 7f75fdb

Browse files
committed
Try to fix windows
Junit (or something, maybe not junit directly) seems to be failing to delete a temp dir I was creating with the TempDir annotation. Maybe just manually creating/deleting it will work.
1 parent 6d55c77 commit 7f75fdb

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

smithy-build/src/test/java/software/amazon/smithy/build/plugins/SourcesPluginTest.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@
1010
import static org.hamcrest.Matchers.is;
1111
import static org.hamcrest.Matchers.not;
1212

13+
import java.io.File;
1314
import java.io.IOException;
1415
import java.net.URISyntaxException;
1516
import java.nio.file.Files;
1617
import java.nio.file.Path;
1718
import java.nio.file.Paths;
19+
import java.util.Comparator;
20+
import org.junit.jupiter.api.AfterEach;
1821
import org.junit.jupiter.api.Assertions;
22+
import org.junit.jupiter.api.BeforeEach;
1923
import org.junit.jupiter.api.Test;
20-
import org.junit.jupiter.api.io.TempDir;
2124
import software.amazon.smithy.build.MockManifest;
2225
import software.amazon.smithy.build.PluginContext;
2326
import software.amazon.smithy.build.SmithyBuild;
@@ -30,6 +33,19 @@
3033
import software.amazon.smithy.utils.ListUtils;
3134

3235
public class SourcesPluginTest {
36+
37+
private Path tempDirectory;
38+
39+
@BeforeEach
40+
public void before() throws IOException {
41+
tempDirectory = Files.createTempDirectory(getClass().getSimpleName());
42+
}
43+
44+
@AfterEach
45+
public void after() throws IOException {
46+
Files.walk(tempDirectory).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
47+
}
48+
3349
@Test
3450
public void copiesFilesForSourceProjection() throws URISyntaxException {
3551
Model model = Model.assembler()
@@ -242,10 +258,10 @@ public void omitsUnsupportedFilesFromManifest() throws URISyntaxException {
242258
}
243259

244260
@Test
245-
public void copiesModelFromJarWithEncodedPathWithSourceProjection(@TempDir Path tempDir)
261+
public void copiesModelFromJarWithEncodedPathWithSourceProjection()
246262
throws IOException, URISyntaxException {
247263
Path source = Paths.get(getClass().getResource("sources/jar-import.jar").toURI());
248-
Path jarPath = tempDir.resolve(Paths.get("special%45path", "special.jar"));
264+
Path jarPath = tempDirectory.resolve(Paths.get("special%45path", "special.jar"));
249265

250266
Files.createDirectories(jarPath.getParent());
251267
Files.copy(source, jarPath);
@@ -275,10 +291,10 @@ public void copiesModelFromJarWithEncodedPathWithSourceProjection(@TempDir Path
275291
}
276292

277293
@Test
278-
public void copiesModelFromJarWithEncodedPathWithNonSourceProjection(@TempDir Path tempDir)
294+
public void copiesModelFromJarWithEncodedPathWithNonSourceProjection()
279295
throws IOException, URISyntaxException {
280296
Path source = Paths.get(getClass().getResource("sources/jar-import.jar").toURI());
281-
Path jarPath = tempDir.resolve(Paths.get("special%45path", "special.jar"));
297+
Path jarPath = tempDirectory.resolve(Paths.get("special%45path", "special.jar"));
282298

283299
Files.createDirectories(jarPath.getParent());
284300
Files.copy(source, jarPath);

0 commit comments

Comments
 (0)