diff --git a/README.md b/README.md index 81db2e0a..8ac4002d 100644 --- a/README.md +++ b/README.md @@ -70,11 +70,11 @@ provided as built-in. #### Built-in languages and toolchains -| Language | Toolchains | Default | -|----------|----------------------------------------------|----------------| -| java | gradle, gradle-wrapper, maven, maven-wrapper | gradle-wrapper | -| cpp | cmake | cmake | -| go | go-tools | go-tools | +| Language | Toolchains | Default | +|----------|----------------------------------------------------|----------------| +| java | gradle, gradle-wrapper, maven, maven-wrapper, make | gradle-wrapper | +| cpp | cmake, make | cmake | +| go | go-tools, make | go-tools | ### Base directory diff --git a/tcr-engine/language/cpp.go b/tcr-engine/language/cpp.go index 19d88ea4..c4f4960f 100644 --- a/tcr-engine/language/cpp.go +++ b/tcr-engine/language/cpp.go @@ -28,7 +28,7 @@ func init() { name: "cpp", toolchains: Toolchains{ Default: "cmake", - Compatible: []string{"cmake"}, + Compatible: []string{"cmake", "make"}, }, srcFileFilter: FileTreeFilter{ Directories: []string{"src", "include"}, diff --git a/tcr-engine/language/cpp_test.go b/tcr-engine/language/cpp_test.go index 0e94c017..db05c38f 100644 --- a/tcr-engine/language/cpp_test.go +++ b/tcr-engine/language/cpp_test.go @@ -64,6 +64,7 @@ func Test_cpp_default_toolchain(t *testing.T) { func Test_cpp_compatible_toolchains(t *testing.T) { assertCompatibleToolchains(t, []string{"cmake"}, cppLanguageName) + assertCompatibleToolchains(t, []string{"make"}, cppLanguageName) } func Test_cpp_incompatible_toolchains(t *testing.T) { diff --git a/tcr-engine/language/go.go b/tcr-engine/language/go.go index b0162006..ac283eca 100644 --- a/tcr-engine/language/go.go +++ b/tcr-engine/language/go.go @@ -28,7 +28,7 @@ func init() { name: "go", toolchains: Toolchains{ Default: "go-tools", - Compatible: []string{"go-tools"}, + Compatible: []string{"go-tools", "make"}, }, srcFileFilter: FileTreeFilter{ Directories: []string{"."}, diff --git a/tcr-engine/language/go_test.go b/tcr-engine/language/go_test.go index 0c5c0260..c298a0cc 100644 --- a/tcr-engine/language/go_test.go +++ b/tcr-engine/language/go_test.go @@ -62,6 +62,7 @@ func Test_go_default_toolchain(t *testing.T) { func Test_go_compatible_toolchains(t *testing.T) { assertCompatibleToolchains(t, []string{"go-tools"}, goLanguageName) + assertCompatibleToolchains(t, []string{"make"}, goLanguageName) } func Test_go_incompatible_toolchains(t *testing.T) { diff --git a/tcr-engine/language/java.go b/tcr-engine/language/java.go index d116bd4c..99f03718 100644 --- a/tcr-engine/language/java.go +++ b/tcr-engine/language/java.go @@ -28,7 +28,7 @@ func init() { name: "java", toolchains: Toolchains{ Default: "gradle-wrapper", - Compatible: []string{"gradle", "gradle-wrapper", "maven", "maven-wrapper"}, + Compatible: []string{"gradle", "gradle-wrapper", "maven", "maven-wrapper", "make"}, }, srcFileFilter: FileTreeFilter{ Directories: []string{"src/main"}, diff --git a/tcr-engine/language/java_test.go b/tcr-engine/language/java_test.go index e71f12a4..d9e51504 100644 --- a/tcr-engine/language/java_test.go +++ b/tcr-engine/language/java_test.go @@ -62,6 +62,7 @@ func Test_java_default_toolchain(t *testing.T) { func Test_java_compatible_toolchains(t *testing.T) { assertCompatibleToolchains(t, []string{"gradle", "gradle-wrapper", "maven", "maven-wrapper"}, javaLanguageName) + assertCompatibleToolchains(t, []string{"make"}, javaLanguageName) } func Test_java_incompatible_toolchains(t *testing.T) { diff --git a/tcr-engine/testdata/go/Makefile b/tcr-engine/testdata/go/Makefile new file mode 100644 index 00000000..b139ce8e --- /dev/null +++ b/tcr-engine/testdata/go/Makefile @@ -0,0 +1,32 @@ +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Example Makefile for Go language +# ---------------------------------------------------------------------------- + +.PHONY: build +build: + @go build -v ./... + +.PHONY: test +test: + @go test -v ./... + + diff --git a/tcr-engine/testdata/go/kata/dummy/dummy.go b/tcr-engine/testdata/go/kata/dummy/dummy.go index d4da0408..ea1abf93 100644 --- a/tcr-engine/testdata/go/kata/dummy/dummy.go +++ b/tcr-engine/testdata/go/kata/dummy/dummy.go @@ -23,5 +23,5 @@ SOFTWARE. package dummy func doSomething() int { - return 40 + return 42 } diff --git a/tcr-engine/testdata/go/kata/dummy/dummy_test.go b/tcr-engine/testdata/go/kata/dummy/dummy_test.go index 5b523c7f..db8233ff 100644 --- a/tcr-engine/testdata/go/kata/dummy/dummy_test.go +++ b/tcr-engine/testdata/go/kata/dummy/dummy_test.go @@ -28,5 +28,5 @@ import ( ) func Test_acceptance_test(t *testing.T) { - assert.Equal(t, 40, doSomething()) + assert.Equal(t, 42, doSomething()) } diff --git a/tcr-engine/testdata/java/Makefile b/tcr-engine/testdata/java/Makefile new file mode 100644 index 00000000..0f4dc2bb --- /dev/null +++ b/tcr-engine/testdata/java/Makefile @@ -0,0 +1,101 @@ +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Example Makefile for Java language +# ---------------------------------------------------------------------------- + +junit.ver = 1.8.2 +junit.jar = junit-platform-console-standalone-$(junit.ver).jar +maven.url = https://repo1.maven.org/maven2/org/junit/platform/junit-platform-console-standalone +junit.url = $(maven.url)/$(junit.ver)/$(junit.jar) + +src.dir = src +build.dir = build +build.lib.dir = $(build.dir)/lib + +src.main.dir = $(src.dir)/main/java +src.test.dir = $(src.dir)/test/java + +build.main.dir = $(build.dir)/classes +build.test.dir = $(build.dir)/test-classes + +src.main.files := $(shell find $(src.main.dir) -type f -name '*.java') +src.test.files := $(shell find $(src.test.dir) -type f -name '*.java') + +build.main.files = $(src.main.files:$(src.main.dir)/%.java=$(build.main.dir)/%.class) +build.test.files = $(src.test.files:$(src.test.dir)/%.java=$(build.test.dir)/%.class) + +# Classpath separator is platform-dependant +os.kernel := $(shell uname -s) +ifeq ($(os.kernel),Darwin) + classpath.sep = ":" +else ifeq ($(os.kernel),Linux) + classpath.sep = ":" +else + classpath.sep = ";" +endif + +.PHONY: build +build: build-main build-test + +.PHONY: test +test: build-test + -@echo "Running tests" + -@java -jar $(build.lib.dir)/$(junit.jar) \ + --class-path $(build.main.dir) \ + --class-path $(build.test.dir) \ + --scan-class-path --details=tree + +.PHONY: clean +clean: + -@echo "Cleaning up" + -@rm -rf $(build.dir) + +.PHONY: build-main +build-main: $(build.main.files) + +$(build.main.files): | $(build.main.dir) + +$(build.main.dir)/%.class: $(src.main.dir)/%.java + -@echo "Compiling $(