Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add makefile code sample for tests #56

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion pkg/analyzer/analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,15 @@ func TestMatchingFiles(t *testing.T) {
Language: "PHP",
},
{
FilePath: filepath.Join(codeSamplesDir, "Makefile"),
Extension: "Makefile",
Language: "Makefile",
},
{
FilePath: filepath.Join(codeSamplesDir, "App.vue"),
Extension: ".vue",
Language: "Vue",
},
},
},
},
{
Expand Down Expand Up @@ -180,6 +185,12 @@ func TestMatchingFiles(t *testing.T) {
Language: "PHP",
},
{

FilePath: filepath.Join(codeSamplesDir, "Makefile"),
Extension: "Makefile",
Language: "Makefile",
},
{
FilePath: filepath.Join(codeSamplesDir, "App.vue"),
Extension: ".vue",
Language: "Vue",
Expand Down Expand Up @@ -252,6 +263,11 @@ func TestMatchingFiles(t *testing.T) {
Language: "PHP",
},
{
FilePath: filepath.Join(codeSamplesDir, "Makefile"),
Extension: "Makefile",
Language: "Makefile",
},
{
FilePath: filepath.Join(codeSamplesDir, "App.vue"),
Extension: ".vue",
Language: "Vue",
Expand Down
12 changes: 12 additions & 0 deletions pkg/scanner/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ func TestScan(t *testing.T) {
Language: "PHP",
},
{
FilePath: filepath.Join(codeSamplesDir, "Makefile"),
Extension: "Makefile",
Language: "Makefile",
},
{
FilePath: filepath.Join(codeSamplesDir, "App.vue"),
Extension: ".vue",
Language: "Vue",
Expand Down Expand Up @@ -177,6 +182,13 @@ func TestScan(t *testing.T) {
},
{
Metadata: files[12],
Lines: 24,
CodeLines: 19,
BlankLines: 4,
Comments: 1,
},
{
Metadata: files[13],
Lines: 51,
CodeLines: 39,
BlankLines: 7,
Expand Down
24 changes: 24 additions & 0 deletions test/fixtures/code_samples/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.PHONY:build

# build
build:
@echo "building the gcloc executable"
go build -o bin/gcloc cmd/gcloc/main.go
@echo "executable created bin/gcloc"

.PHONY:clean
clean:
@echo "cleaning the gcloc package"
rm -rf bin coverage.out coverage.html

.PHONY:unit-test
unit-test:
@echo "running unit tests"
go test -v `go list ./... | grep -v test/`

.PHONY:coverage
coverage:
@echo "coverage report"
go test -cover -v -timeout 60s -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
g tool cover -html=coverage.out -o coverage.html