Skip to content

Commit

Permalink
Add integration tests; print build info; add makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
timdp committed Apr 28, 2018
1 parent 245ebc2 commit 9ceba0b
Show file tree
Hide file tree
Showing 13 changed files with 100,311 additions and 4 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
trap "go-junit-report < $TEST_RESULTS/go-test.out > $TEST_RESULTS/go-test-report.xml" EXIT
go test -v -cover -race -coverprofile=$TEST_RESULTS/coverage.out ./... | tee $TEST_RESULTS/go-test.out
- run: goveralls -coverprofile=$TEST_RESULTS/coverage.out -service=circle-ci -repotoken=$COVERALLS_TOKEN
- run: make test/integration
- save_cache:
key: v1-pkg-cache
paths:
Expand Down
10 changes: 9 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,13 @@ indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.go]
[*.go,Makefile]
indent_style = tab

[test/fixtures/**]
charset = ignore
end_of_line = ignore
indent_style = ignore
indent_size = ignore
insert_final_newline = ignore
trim_trailing_whitespace = ignore
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* text=auto
test/fixtures/** -text
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Thumbs.db
.DS_Store
/bin/
/dist/
/vendor/
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
GOCMD=go

MAIN=cmd/lwc/main.go
BIN=bin

VERSION=$(shell git describe --tags --abbrev=0 --always)
COMMIT=$(shell git log --pretty=format:'%h' -n 1)
# Same format as goreleaser
DATE=$(shell date +%Y-%m-%d_%H:%M:%S)
LDFLAGS="-s -w -X main.version=$(VERSION)+git.$(COMMIT) -X main.date=$(DATE)"

all: build test

clean:
rm -rf $(BIN)

build: build_debug build_release

test: test_unit test_integration

bin:
mkdir -p $(BIN)

build_debug: bin
$(GOCMD) build -o $(BIN)/lwc-debug -gcflags=all='-N -l' $(MAIN)

build_release: bin
$(GOCMD) build -o $(BIN)/lwc -ldflags=$(LDFLAGS) $(MAIN)

test_unit:
$(GOCMD) test -v ./...

test_integration: build_debug
test/integration.sh
5 changes: 3 additions & 2 deletions cmd/lwc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"github.com/timdp/lwc/internal/app/lwc"
)

var version = "master"
var version = ""
var date = ""

func main() {
lwc.Run(version)
lwc.Run(version, date)
}
6 changes: 5 additions & 1 deletion internal/app/lwc/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ package lwc
import (
"fmt"
"os"
"strings"
)

func Run(version string) {
func Run(version string, date string) {
// Read command-line args
config := NewConfig(os.Args)

switch {
case config.Version:
// Print version and exit
fmt.Printf("lwc %s\n", version)
if date != "" {
fmt.Printf("Built %s\n", strings.Replace(date, "_", " ", -1))
}
case config.Help:
// Print usage and exit
config.PrintUsage()
Expand Down
Loading

0 comments on commit 9ceba0b

Please # to comment.