-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve CLI output name handling by adding file extensions (#2914)
* FileExtensionHandler added + Tests #2800 * solution for path problem #2800 * case: path without filename considered #2800 * CodeMaatImporter + CSVImporter fixed #2800 * RawTextParser + TokeiImporter fixed #2800 * minor refactoring to prevent files from being created while testing #2800 * pipeline fehler #2800 * write jsons in terminal for golden_test.sh #2800 * updated changes with review remarks #2800 * fix test #2800 * remove test boolean #2800 * remove comment, sysout variable #2800 * refacotor OutputFileHandler.kt, adjust parsers #2800 * refactor RawText Parser and adjust tests #2800 * remove sysout from golden_test.sh #2800 * Add tests to GitLogParser and SVNLogParser #2800 * Refactor SVNLogParser.kt for linter correctness #2800 * Fix file ending for CrococosmoImporter #2800 * Fix path-separator not correctly added in OutputFileHandler Refactor/simplify CrococosmoImporter, so it handles suffixes properly Enhance tests for Crococosmo and MetricGardener #2800 * Update CHANGELOG.md #2800 * Fix EdgeFilter and MergeFilter not using the new OutputFileHandler #2800 * Refactor a test for linter happiness #2800 * Add a test for the EdgeFilter #2800 * Refactor test for MergeFilter to JUnit Add more tests for MergeFilter #2800 * Fix StructureModifier not using new OutputFileHandler Refactor all Importers/Parsers for more consistent line breaks #2800 Co-authored-by: MW-Friedrich <108457762+MW-Friedrich@users.noreply.github.com> Co-authored-by: ChristianSpa <cspahn@gmx.net>
- Loading branch information
1 parent
6d13754
commit e8d52b5
Showing
39 changed files
with
616 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...EdgeFilter/src/test/kotlin/de/maibornwolff/codecharta/filter/edgefilter/EdgeFilterTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package de.maibornwolff.codecharta.filter.edgefilter | ||
|
||
import de.maibornwolff.codecharta.filter.edgefilter.EdgeFilter.Companion.main | ||
import org.junit.jupiter.api.Assertions.assertTrue | ||
import org.junit.jupiter.api.Test | ||
import java.io.File | ||
|
||
class EdgeFilterTest { | ||
@Test | ||
fun `should create json uncompressed file`() { | ||
main( | ||
arrayOf( | ||
"src/test/resources/coupling.json", "-o=src/test/resources/output" | ||
) | ||
) | ||
val file = File("src/test/resources/output.cc.json") | ||
file.deleteOnExit() | ||
|
||
assertTrue(file.exists()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 74 additions & 49 deletions
123
...geFilter/src/test/kotlin/de/maibornwolff/codecharta/filter/mergefilter/MergeFilterTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,85 @@ | ||
package de.maibornwolff.codecharta.filter.mergefilter | ||
|
||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.hamcrest.Matchers.containsString | ||
import org.hamcrest.Matchers.not | ||
import org.spekframework.spek2.Spek | ||
import org.spekframework.spek2.style.specification.describe | ||
import de.maibornwolff.codecharta.filter.mergefilter.MergeFilter.Companion.main | ||
import org.hamcrest.MatcherAssert | ||
import org.hamcrest.Matchers | ||
import org.junit.jupiter.api.Assertions | ||
import org.junit.jupiter.api.Test | ||
import picocli.CommandLine | ||
import java.io.ByteArrayOutputStream | ||
import java.io.File | ||
import java.io.PrintStream | ||
|
||
class MergeFilterTest : Spek({ | ||
class MergeFilterTest { | ||
private val mergeFilter = MergeFilter() | ||
val outContent = ByteArrayOutputStream() | ||
val originalOut = System.out | ||
val errContent = ByteArrayOutputStream() | ||
val originalErr = System.err | ||
describe("merge filter test") { | ||
|
||
context("merging a folder") { | ||
val projectLocation = "src/test/resources/mergeFolderTest" | ||
val valueInFile1 = "SourceMonCsvConverterTest.java" | ||
val valueInFile2 = "SourceMonCsvConverter.java" | ||
val invalidFile = "invalid.json" | ||
|
||
System.setOut(PrintStream(outContent)) | ||
System.setErr(PrintStream(errContent)) | ||
CommandLine(MergeFilter()).execute(projectLocation).toString() | ||
System.setOut(originalOut) | ||
System.setErr(originalErr) | ||
|
||
it("should ignore files starting with a dot") { | ||
assertThat(outContent.toString(), not(containsString("ShouldNotAppear.java"))) | ||
} | ||
|
||
it("should merge all valid projects in folder") { | ||
assertThat(outContent.toString(), containsString(valueInFile1)) | ||
assertThat(outContent.toString(), containsString(valueInFile2)) | ||
} | ||
|
||
it("should warn about skipped files") { | ||
assertThat(errContent.toString(), containsString(invalidFile)) | ||
} | ||
} | ||
|
||
context("merging files") { | ||
System.setOut(PrintStream(outContent)) | ||
CommandLine(MergeFilter()).execute( | ||
"src/test/resources/mergeFolderTest/file1.cc.json", "src/test/resources/mergeFolderTest/file2.cc.json" | ||
).toString() | ||
System.setOut(originalOut) | ||
val valueInFile1 = "SourceMonCsvConverterTest.java" | ||
val valueInFile2 = "SourceMonCsvConverter.java" | ||
|
||
it("should merge all indicated files") { | ||
assertThat(outContent.toString(), containsString(valueInFile1)) | ||
assertThat(outContent.toString(), containsString(valueInFile2)) | ||
} | ||
} | ||
|
||
@Test | ||
fun `should merge all files in a folder correctly`() { | ||
val projectLocation = "src/test/resources/mergeFolderTest" | ||
val valueInFile1 = "SourceMonCsvConverterTest.java" | ||
val valueInFile2 = "SourceMonCsvConverter.java" | ||
val invalidFile = "invalid.json" | ||
|
||
System.setOut(PrintStream(outContent)) | ||
System.setErr(PrintStream(errContent)) | ||
CommandLine(MergeFilter()).execute(projectLocation).toString() | ||
System.setOut(originalOut) | ||
System.setErr(originalErr) | ||
|
||
// should ignore files starting with a dot | ||
MatcherAssert.assertThat(outContent.toString(), Matchers.not(Matchers.containsString("ShouldNotAppear.java"))) | ||
|
||
// should merge all valid projects in folder | ||
MatcherAssert.assertThat(outContent.toString(), Matchers.containsString(valueInFile1)) | ||
MatcherAssert.assertThat(outContent.toString(), Matchers.containsString(valueInFile2)) | ||
|
||
// should warn about skipped files | ||
MatcherAssert.assertThat(errContent.toString(), Matchers.containsString(invalidFile)) | ||
} | ||
|
||
@Test | ||
fun `should merge all indicated files`() { | ||
System.setOut(PrintStream(outContent)) | ||
CommandLine(MergeFilter()).execute( | ||
"src/test/resources/mergeFolderTest/file1.cc.json", "src/test/resources/mergeFolderTest/file2.cc.json" | ||
).toString() | ||
System.setOut(originalOut) | ||
val valueInFile1 = "SourceMonCsvConverterTest.java" | ||
val valueInFile2 = "SourceMonCsvConverter.java" | ||
|
||
MatcherAssert.assertThat(outContent.toString(), Matchers.containsString(valueInFile1)) | ||
MatcherAssert.assertThat(outContent.toString(), Matchers.containsString(valueInFile2)) | ||
} | ||
|
||
@Test | ||
fun `should create json uncompressed file`() { | ||
main( | ||
arrayOf( | ||
"src/test/resources/test.json", "src/test/resources/test2.json", "-nc", | ||
"-o=src/test/resources/output" | ||
) | ||
) | ||
val file = File("src/test/resources/output.cc.json") | ||
file.deleteOnExit() | ||
|
||
Assertions.assertTrue(file.exists()) | ||
} | ||
|
||
@Test | ||
fun `should create json gzip file`() { | ||
main( | ||
arrayOf( | ||
"src/test/resources/test.json", "src/test/resources/test2.json", | ||
"-o=src/test/resources/output" | ||
) | ||
) | ||
val file = File("src/test/resources/output.cc.json.gz") | ||
file.deleteOnExit() | ||
|
||
Assertions.assertTrue(file.exists()) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.