@@ -13,36 +13,52 @@ echo "=================================="
1313GO_VERSION=$( go version | awk ' {print $3}' | sed ' s/go//' )
1414echo -e " ${YELLOW} Using Go version: ${GO_VERSION}${NC} "
1515
16- # Only run go mod download if we're using Go 1.11 or higher
17- if [ " $( printf ' %s\n' " 1.11" " $GO_VERSION " | sort -V | head -n1) " = " 1.11" ]; then
18- echo -e " ${YELLOW} Go modules supported. Checking dependencies...${NC} "
19- # Skip go mod download since we don't have external dependencies yet
20- # If we add dependencies later, we can uncomment this
21- # go mod download
16+ # Function to compare versions
17+ version_gt () {
18+ test " $( printf ' %s\n' " $1 " " $2 " | sort -V | head -n1) " ! = " $1 "
19+ }
20+
21+ # Only run go mod commands if we're using Go 1.11 or higher
22+ if version_gt " $GO_VERSION " " 1.10" ; then
23+ echo -e " ${YELLOW} Go modules supported (Go $GO_VERSION ).${NC} "
24+
25+ # We don't need go mod download since we don't have external dependencies yet
26+ # If we add dependencies later, we can uncomment this
27+ # echo -e "${YELLOW}Downloading dependencies...${NC}"
28+ # go mod download
2229else
23- echo -e " ${YELLOW} Go modules not supported in this version. Skipping dependency check .${NC} "
30+ echo -e " ${YELLOW} Go modules not supported in this version (Go $GO_VERSION ) . Skipping module commands .${NC} "
2431fi
2532
2633# Format check
2734echo -e " \n${YELLOW} Checking code formatting...${NC} "
2835if [ " $( gofmt -l . | wc -l) " -gt 0 ]; then
29- echo -e " ${RED} The following files need formatting:${NC} "
30- gofmt -l .
31- echo -e " ${YELLOW} Running gofmt to fix formatting issues...${NC} "
32- gofmt -w .
33- echo -e " ${GREEN} Formatting fixed.${NC} "
36+ echo -e " ${RED} The following files need formatting:${NC} "
37+ gofmt -l .
38+ echo -e " ${YELLOW} Running gofmt to fix formatting issues...${NC} "
39+ gofmt -w .
40+ echo -e " ${GREEN} Formatting fixed.${NC} "
3441else
35- echo -e " ${GREEN} All files are properly formatted.${NC} "
42+ echo -e " ${GREEN} All files are properly formatted.${NC} "
3643fi
3744
3845# Lint check
3946echo -e " \n${YELLOW} Running linter...${NC} "
4047if command -v golint > /dev/null; then
41- golint ./...
48+ golint ./...
4249else
43- echo -e " ${RED} golint not installed. Installing...${NC} "
44- go install golang.org/x/lint/golint@latest
45- $( go env GOPATH) /bin/golint ./...
50+ echo -e " ${RED} golint not installed. Installing...${NC} "
51+ if version_gt " $GO_VERSION " " 1.16" ; then
52+ go install golang.org/x/lint/golint@latest
53+ else
54+ go get -u golang.org/x/lint/golint
55+ fi
56+
57+ if command -v golint > /dev/null; then
58+ golint ./...
59+ else
60+ $( go env GOPATH) /bin/golint ./...
61+ fi
4662fi
4763
4864# Vet check
@@ -73,25 +89,25 @@ go build -v ./cmd/stremax
7389# Run examples
7490echo -e " \n${YELLOW} Running example programs...${NC} "
7591if [ -f " ./stremax" ]; then
76- echo -e " ${YELLOW} Running simple.sx${NC} "
77- ./stremax run -file ./examples/simple.sx
78-
79- echo -e " \n${YELLOW} Running arithmetic.sx${NC} "
80- ./stremax run -file ./examples/arithmetic.sx
81-
82- echo -e " \n${YELLOW} Running strings.sx${NC} "
83- ./stremax run -file ./examples/strings.sx
84-
85- echo -e " \n${YELLOW} Running conditionals.sx${NC} "
86- ./stremax run -file ./examples/conditionals.sx
87-
88- echo -e " \n${YELLOW} Running boolean.sx${NC} "
89- ./stremax run -file ./examples/boolean.sx
90-
91- echo -e " \n${YELLOW} Running combined.sx${NC} "
92- ./stremax run -file ./examples/combined.sx
92+ echo -e " ${YELLOW} Running simple.sx${NC} "
93+ ./stremax run -file ./examples/simple.sx
94+
95+ echo -e " \n${YELLOW} Running arithmetic.sx${NC} "
96+ ./stremax run -file ./examples/arithmetic.sx
97+
98+ echo -e " \n${YELLOW} Running strings.sx${NC} "
99+ ./stremax run -file ./examples/strings.sx
100+
101+ echo -e " \n${YELLOW} Running conditionals.sx${NC} "
102+ ./stremax run -file ./examples/conditionals.sx
103+
104+ echo -e " \n${YELLOW} Running boolean.sx${NC} "
105+ ./stremax run -file ./examples/boolean.sx
106+
107+ echo -e " \n${YELLOW} Running combined.sx${NC} "
108+ ./stremax run -file ./examples/combined.sx
93109else
94- echo -e " ${RED} stremax binary not found. Build failed?${NC} "
110+ echo -e " ${RED} stremax binary not found. Build failed?${NC} "
95111fi
96112
97113echo -e " \n${GREEN} All tests completed!${NC} "
0 commit comments