Clover icon

sunshower-base

  1. Project Clover database Fri Apr 6 2018 03:41:27 UTC
  2. Package io.sunshower.test.common

File TestClasspath.java

 

Coverage histogram

../../../../img/srcFileCovDistChart8.png
19% of files have more coverage

Code metrics

10
17
3
1
41
36
10
0.59
5.67
3
3.33

Classes

Class Line # Actions
TestClasspath 7 17 10
0.7333333573.3%
 

Contributing tests

This file is covered by 3 tests. .

Source view

1    package io.sunshower.test.common;
2   
3    import java.io.File;
4    import java.io.IOException;
5    import java.util.NoSuchElementException;
6   
 
7    public class TestClasspath {
8   
 
9  3 toggle public static File buildDir() {
10  3 final File file = new File(ClassLoader.getSystemResource(".").getFile());
11  15 for (File f = file; f != null; f = f.getParentFile()) {
12  15 File build = new File(f, "build");
13  15 if (build.exists() && build.isDirectory()) {
14  3 return build;
15    }
16  12 build = new File(f, "out");
17  12 if (build.exists() && build.isDirectory()) {
18  0 return build;
19    }
20    }
21  0 throw new NoSuchElementException("Failed to resolve build directory");
22    }
23   
 
24  1 toggle public static File getOrCreateDirectoryInBuildDirectory(String path) throws IOException {
25  1 File file = new File(buildDir(), path);
26  1 if (file.mkdirs()) {
27  1 return file;
28    }
29  0 throw new IllegalStateException(
30    String.format("Failed to create directory %s in %s", path, buildDir()));
31    }
32   
 
33  1 toggle public static File getOrCreateFileInBuildDirectory(String path) throws IOException {
34  1 File file = new File(buildDir(), path);
35  1 if (file.createNewFile()) {
36  1 return file;
37    }
38  0 throw new IllegalStateException(
39    String.format("Failed to create file %s in %s", path, buildDir()));
40    }
41    }