6
6
import org .utplsql .api .reporter .ReporterFactory ;
7
7
import org .utplsql .cli .ReporterOptions ;
8
8
9
+ import java .nio .file .Path ;
9
10
import java .nio .file .Paths ;
10
11
import java .sql .Connection ;
11
12
import java .sql .SQLException ;
@@ -27,15 +28,34 @@ public LocalAssetsCoverageHTMLReporter(String selfType, Object[] attributes) {
27
28
public Reporter init (Connection con , CompatibilityProxy compatibilityProxy , ReporterFactory reporterFactory ) throws SQLException {
28
29
super .init (con , compatibilityProxy , reporterFactory );
29
30
30
- if ( options != null && options .outputToFile () )
31
- writeReportAssetsTo (Paths .get (getAssetsPath ()));
31
+ if ( hasOutputToFile () ) {
32
+ writeReportAssetsTo (getPhysicalAssetPath ());
33
+ }
32
34
33
35
return this ;
34
36
}
35
37
38
+ private String getNameOfOutputFile () {
39
+ Path outputPath = Paths .get (options .getOutputFileName ());
40
+ return outputPath .getName (outputPath .getNameCount ()-1 ).toString ();
41
+ }
42
+
43
+ private Path getPhysicalAssetPath () {
44
+ Path outputPath = Paths .get (options .getOutputFileName ());
45
+ if ( outputPath .getNameCount () > 1 )
46
+ return outputPath .getParent ().resolve (getAssetsPath ());
47
+ else
48
+ return Paths .get (getAssetsPath ());
49
+ }
50
+
36
51
private void setAssetsPathFromOptions () {
37
- if ( options != null && options .outputToFile () )
38
- setAssetsPath (options .getOutputFileName ()+"_assets/" );
52
+ if ( hasOutputToFile () ) {
53
+ setAssetsPath (getNameOfOutputFile () + "_assets/" );
54
+ }
55
+ }
56
+
57
+ private boolean hasOutputToFile () {
58
+ return (options != null && options .outputToFile ());
39
59
}
40
60
41
61
@ Override
0 commit comments