Skip to content

Commit

Permalink
feat: add test for ignore cases
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Sep 17, 2020
1 parent 31a925d commit 0a8ccb7
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 2 deletions.
1 change: 1 addition & 0 deletions _fixtures/cloc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!someignore/.idea/
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions _fixtures/cloc/someignore/.idea/hello.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion cmd/cloc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestCloc(t *testing.T) {
}

func TestClocByDirectory(t *testing.T) {
abs := "../_fixtures/cloc"
abs := "../_fixtures/cloc/normal"

analysis := []testcase.CmdTestCase{{
Name: "analysis",
Expand All @@ -37,4 +37,22 @@ func TestClocByDirectory(t *testing.T) {
Golden: "testdata/cloc_directory.txt",
}}
RunTestCmd(t, tests)
}

func TestShouldReturnNullWhenIgnoreDir(t *testing.T) {
abs := "../_fixtures/cloc/someignore"

analysis := []testcase.CmdTestCase{{
Name: "analysis",
Cmd: "analysis -p " + abs,
Golden: "",
}}
RunTestCmd(t, analysis)

tests := []testcase.CmdTestCase{{
Name: "cloc",
Cmd: "cloc " + abs + " --by-directory",
Golden: "testdata/cloc_ignore.txt",
}}
RunTestCmd(t, tests)
}
2 changes: 1 addition & 1 deletion cmd/testdata/cloc_directory.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
package,summary,Java,Kotlin
pkg2,20,17,3
pkg,20,17,3
1 change: 1 addition & 0 deletions cmd/testdata/cloc_ignore.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package,summary,Java

0 comments on commit 0a8ccb7

Please sign in to comment.