diff options
| -rw-r--r-- | .github/workflows/cpp-ci.yml | 8 | ||||
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | Makefile | 10 | ||||
| -rw-r--r-- | Makefile.ckati | 11 | ||||
| -rw-r--r-- | Makefile.kati | 25 | ||||
| -rw-r--r-- | README.md | 39 | ||||
| -rwxr-xr-x | clang-format-check | 4 | ||||
| -rw-r--r-- | go.mod | 8 | ||||
| -rw-r--r-- | go.sum | 16 | ||||
| -rw-r--r-- | golang/cmd/kati/main.go (renamed from cmd/kati/main.go) | 2 | ||||
| -rw-r--r-- | golang/kati/ast.go (renamed from ast.go) | 0 | ||||
| -rw-r--r-- | golang/kati/bootstrap.go (renamed from bootstrap.go) | 0 | ||||
| -rw-r--r-- | golang/kati/buf.go (renamed from buf.go) | 0 | ||||
| -rw-r--r-- | golang/kati/buf_test.go (renamed from buf_test.go) | 0 | ||||
| -rw-r--r-- | golang/kati/dep.go (renamed from dep.go) | 0 | ||||
| -rw-r--r-- | golang/kati/depgraph.go (renamed from depgraph.go) | 0 | ||||
| -rw-r--r-- | golang/kati/doc.go (renamed from doc.go) | 0 | ||||
| -rw-r--r-- | golang/kati/eval.go (renamed from eval.go) | 0 | ||||
| -rw-r--r-- | golang/kati/evalcmd.go (renamed from evalcmd.go) | 0 | ||||
| -rw-r--r-- | golang/kati/exec.go (renamed from exec.go) | 0 | ||||
| -rw-r--r-- | golang/kati/expr.go (renamed from expr.go) | 0 | ||||
| -rw-r--r-- | golang/kati/expr_test.go (renamed from expr_test.go) | 0 | ||||
| -rw-r--r-- | golang/kati/fileutil.go (renamed from fileutil.go) | 0 | ||||
| -rw-r--r-- | golang/kati/flags.go (renamed from flags.go) | 0 | ||||
| -rw-r--r-- | golang/kati/func.go (renamed from func.go) | 0 | ||||
| -rw-r--r-- | golang/kati/func_test.go (renamed from func_test.go) | 0 | ||||
| -rw-r--r-- | golang/kati/log.go (renamed from log.go) | 0 | ||||
| -rw-r--r-- | golang/kati/ninja.go (renamed from ninja.go) | 0 | ||||
| -rw-r--r-- | golang/kati/ninja_test.go (renamed from ninja_test.go) | 0 | ||||
| -rw-r--r-- | golang/kati/parser.go (renamed from parser.go) | 0 | ||||
| -rw-r--r-- | golang/kati/pathutil.go (renamed from pathutil.go) | 0 | ||||
| -rw-r--r-- | golang/kati/pathutil_test.go (renamed from pathutil_test.go) | 0 | ||||
| -rw-r--r-- | golang/kati/query.go (renamed from query.go) | 0 | ||||
| -rw-r--r-- | golang/kati/rule_parser.go (renamed from rule_parser.go) | 0 | ||||
| -rw-r--r-- | golang/kati/rule_parser_test.go (renamed from rule_parser_test.go) | 0 | ||||
| -rw-r--r-- | golang/kati/serialize.go (renamed from serialize.go) | 0 | ||||
| -rw-r--r-- | golang/kati/shellutil.go (renamed from shellutil.go) | 0 | ||||
| -rw-r--r-- | golang/kati/shellutil_test.go (renamed from shellutil_test.go) | 0 | ||||
| -rw-r--r-- | golang/kati/stats.go (renamed from stats.go) | 0 | ||||
| -rw-r--r-- | golang/kati/strutil.go (renamed from strutil.go) | 0 | ||||
| -rw-r--r-- | golang/kati/strutil_test.go (renamed from strutil_test.go) | 0 | ||||
| -rw-r--r-- | golang/kati/symtab.go (renamed from symtab.go) | 0 | ||||
| -rw-r--r-- | golang/kati/var.go (renamed from var.go) | 0 | ||||
| -rw-r--r-- | golang/kati/version.go (renamed from version.go) | 0 | ||||
| -rw-r--r-- | golang/kati/worker.go (renamed from worker.go) | 0 | ||||
| -rwxr-xr-x | m2n | 120 | ||||
| -rwxr-xr-x | make-c.sh | 21 | ||||
| -rw-r--r-- | make-c/main.go | 58 | ||||
| -rwxr-xr-x | pack.sh | 29 | ||||
| -rw-r--r-- | run_test.go | 512 | ||||
| -rwxr-xr-x | runtest.rb | 440 | ||||
| -rw-r--r-- | src/Android.bp (renamed from Android.bp) | 0 | ||||
| -rw-r--r-- | src/affinity.cc (renamed from affinity.cc) | 0 | ||||
| -rw-r--r-- | src/affinity.h (renamed from affinity.h) | 0 | ||||
| -rw-r--r-- | src/command.cc (renamed from command.cc) | 0 | ||||
| -rw-r--r-- | src/command.h (renamed from command.h) | 0 | ||||
| -rw-r--r-- | src/dep.cc (renamed from dep.cc) | 0 | ||||
| -rw-r--r-- | src/dep.h (renamed from dep.h) | 0 | ||||
| -rw-r--r-- | src/eval.cc (renamed from eval.cc) | 0 | ||||
| -rw-r--r-- | src/eval.h (renamed from eval.h) | 0 | ||||
| -rw-r--r-- | src/exec.cc (renamed from exec.cc) | 0 | ||||
| -rw-r--r-- | src/exec.h (renamed from exec.h) | 0 | ||||
| -rw-r--r-- | src/expr.cc (renamed from expr.cc) | 0 | ||||
| -rw-r--r-- | src/expr.h (renamed from expr.h) | 0 | ||||
| -rw-r--r-- | src/file.cc (renamed from file.cc) | 0 | ||||
| -rw-r--r-- | src/file.h (renamed from file.h) | 0 | ||||
| -rw-r--r-- | src/file_cache.cc (renamed from file_cache.cc) | 0 | ||||
| -rw-r--r-- | src/file_cache.h (renamed from file_cache.h) | 0 | ||||
| -rw-r--r-- | src/fileutil.cc (renamed from fileutil.cc) | 0 | ||||
| -rw-r--r-- | src/fileutil.h (renamed from fileutil.h) | 0 | ||||
| -rw-r--r-- | src/fileutil_bench.cc (renamed from fileutil_bench.cc) | 0 | ||||
| -rw-r--r-- | src/find.cc (renamed from find.cc) | 0 | ||||
| -rw-r--r-- | src/find.h (renamed from find.h) | 0 | ||||
| -rw-r--r-- | src/find_test.cc (renamed from find_test.cc) | 0 | ||||
| -rw-r--r-- | src/flags.cc (renamed from flags.cc) | 0 | ||||
| -rw-r--r-- | src/flags.h (renamed from flags.h) | 0 | ||||
| -rw-r--r-- | src/func.cc (renamed from func.cc) | 0 | ||||
| -rw-r--r-- | src/func.h (renamed from func.h) | 0 | ||||
| -rw-r--r-- | src/io.cc (renamed from io.cc) | 0 | ||||
| -rw-r--r-- | src/io.h (renamed from io.h) | 0 | ||||
| -rw-r--r-- | src/loc.h (renamed from loc.h) | 0 | ||||
| -rw-r--r-- | src/log.cc (renamed from log.cc) | 0 | ||||
| -rw-r--r-- | src/log.h (renamed from log.h) | 0 | ||||
| -rw-r--r-- | src/main.cc (renamed from main.cc) | 0 | ||||
| -rw-r--r-- | src/ninja.cc (renamed from ninja.cc) | 0 | ||||
| -rw-r--r-- | src/ninja.h (renamed from ninja.h) | 0 | ||||
| -rw-r--r-- | src/ninja_test.cc (renamed from ninja_test.cc) | 0 | ||||
| -rw-r--r-- | src/parser.cc (renamed from parser.cc) | 0 | ||||
| -rw-r--r-- | src/parser.h (renamed from parser.h) | 0 | ||||
| -rw-r--r-- | src/regen.cc (renamed from regen.cc) | 0 | ||||
| -rw-r--r-- | src/regen.h (renamed from regen.h) | 0 | ||||
| -rw-r--r-- | src/regen_dump.cc (renamed from regen_dump.cc) | 0 | ||||
| -rw-r--r-- | src/rule.cc (renamed from rule.cc) | 0 | ||||
| -rw-r--r-- | src/rule.h (renamed from rule.h) | 0 | ||||
| -rw-r--r-- | src/stats.cc (renamed from stats.cc) | 0 | ||||
| -rw-r--r-- | src/stats.h (renamed from stats.h) | 0 | ||||
| -rw-r--r-- | src/stmt.cc (renamed from stmt.cc) | 0 | ||||
| -rw-r--r-- | src/stmt.h (renamed from stmt.h) | 0 | ||||
| -rw-r--r-- | src/string_piece.cc (renamed from string_piece.cc) | 0 | ||||
| -rw-r--r-- | src/string_piece.h (renamed from string_piece.h) | 0 | ||||
| -rw-r--r-- | src/string_piece_test.cc (renamed from string_piece_test.cc) | 0 | ||||
| -rw-r--r-- | src/stringprintf.cc (renamed from stringprintf.cc) | 0 | ||||
| -rw-r--r-- | src/stringprintf.h (renamed from stringprintf.h) | 0 | ||||
| -rw-r--r-- | src/strutil.cc (renamed from strutil.cc) | 0 | ||||
| -rw-r--r-- | src/strutil.h (renamed from strutil.h) | 0 | ||||
| -rw-r--r-- | src/strutil_bench.cc (renamed from strutil_bench.cc) | 0 | ||||
| -rw-r--r-- | src/strutil_test.cc (renamed from strutil_test.cc) | 0 | ||||
| -rw-r--r-- | src/symtab.cc (renamed from symtab.cc) | 0 | ||||
| -rw-r--r-- | src/symtab.h (renamed from symtab.h) | 0 | ||||
| -rw-r--r-- | src/testutil.h (renamed from testutil.h) | 0 | ||||
| -rw-r--r-- | src/thread_pool.cc (renamed from thread_pool.cc) | 0 | ||||
| -rw-r--r-- | src/thread_pool.h (renamed from thread_pool.h) | 0 | ||||
| -rw-r--r-- | src/timeutil.cc (renamed from timeutil.cc) | 0 | ||||
| -rw-r--r-- | src/timeutil.h (renamed from timeutil.h) | 0 | ||||
| -rw-r--r-- | src/var.cc (renamed from var.cc) | 0 | ||||
| -rw-r--r-- | src/var.h (renamed from var.h) | 0 | ||||
| -rw-r--r-- | src/version.h (renamed from version.h) | 0 | ||||
| -rw-r--r-- | src/version_unknown.cc (renamed from version_unknown.cc) | 0 | ||||
| -rw-r--r-- | testcase/abspath.mk | 4 | ||||
| -rw-r--r-- | testcase/comment_in_command.mk | 2 | ||||
| -rw-r--r-- | testcase/curdir_var.mk | 3 | ||||
| -rw-r--r-- | testcase/err_export_override.mk | 2 | ||||
| -rw-r--r-- | testcase/err_override_export.mk | 2 | ||||
| -rw-r--r-- | testcase/err_suffixes.mk | 2 | ||||
| -rw-r--r-- | testcase/find_command.mk | 5 | ||||
| -rw-r--r-- | testcase/implicit_pattern_rule_chain2.mk | 2 | ||||
| -rw-r--r-- | testcase/implicit_pattern_rule_prefix.mk | 2 | ||||
| -rw-r--r-- | testcase/include_glob_order.mk | 2 | ||||
| -rw-r--r-- | testcase/multi_implicit_output_patterns.mk | 2 | ||||
| -rw-r--r-- | testcase/multiline_recipe.mk | 4 | ||||
| -rw-r--r-- | testcase/ninja_normalized_path.mk | 3 | ||||
| -rwxr-xr-x | testcase/ninja_regen.sh | 12 | ||||
| -rwxr-xr-x | testcase/ninja_regen_filefunc_read.sh | 13 | ||||
| -rwxr-xr-x | testcase/ninja_regen_find_link.sh | 8 | ||||
| -rwxr-xr-x | testcase/ninja_regen_glob.sh | 6 | ||||
| -rw-r--r-- | testcase/order_only2.mk | 2 | ||||
| -rw-r--r-- | testcase/posix_var.mk | 2 | ||||
| -rw-r--r-- | testcase/realpath.mk | 15 | ||||
| -rw-r--r-- | testcase/shell.mk | 2 | ||||
| -rw-r--r-- | testcase/shell_var_with_args.mk | 2 | ||||
| -rw-r--r-- | testcase/strip_and_shell.mk | 2 | ||||
| -rw-r--r-- | testcase/var_with_space.mk | 2 | ||||
| -rw-r--r-- | testcase/vpath.mk | 2 | ||||
| -rw-r--r-- | testcase/wildcard.mk | 2 | ||||
| -rw-r--r-- | testcase/wildcard_cache.mk | 2 | ||||
| -rw-r--r-- | testcase/wildcard_target.mk | 2 |
146 files changed, 602 insertions, 813 deletions
diff --git a/.github/workflows/cpp-ci.yml b/.github/workflows/cpp-ci.yml index c076cf1..5e86550 100644 --- a/.github/workflows/cpp-ci.yml +++ b/.github/workflows/cpp-ci.yml @@ -20,7 +20,7 @@ jobs: - name: install ninja run: | mkdir -p ${GITHUB_WORKSPACE}/ninja-bin; cd ${GITHUB_WORKSPACE}/ninja-bin - wget https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-linux.zip + wget https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-linux.zip unzip ninja-linux.zip rm ninja-linux.zip echo "::add-path::${GITHUB_WORKSPACE}/ninja-bin" @@ -29,11 +29,11 @@ jobs: - name: clang format run: ./clang-format-check - name: run standalone tests - run: ruby runtest.rb -c + run: go test --ckati - name: run ninja tests - run: ruby runtest.rb -c -n + run: go test --ckati --ninja - name: run ninja all targets tests - run: ruby runtest.rb -c -n -a + run: go test --ckati --ninja --all - name: run ninja unit tests run: ./ninja_test - name: run stringpiece unit tests @@ -1,5 +1,5 @@ kati -!cmd/kati/ +!golang/cmd/kati/ ckati para *.o @@ -16,5 +16,4 @@ ninja_test string_piece_test strutil_bench strutil_test -go_src_stamp version.cc @@ -17,14 +17,8 @@ all: ckati ckati_tests include Makefile.kati include Makefile.ckati -test: run_tests - -test_quietly: run_tests -test_quietly: RUN_TESTS_QUIETLY := -q - -run_tests: all ckati_tests - ruby runtest.rb -c -n $(RUN_TESTS_QUIETLY) - +test: all ckati_tests + go test --ckati --ninja clean: ckati_clean diff --git a/Makefile.ckati b/Makefile.ckati index 0984c4e..6d45095 100644 --- a/Makefile.ckati +++ b/Makefile.ckati @@ -13,12 +13,12 @@ # limitations under the License. # Find source file location from path to this Makefile -KATI_SRC_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) +KATI_SRC_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))/src # Set defaults if they weren't set by the including Makefile KATI_CXX ?= $(CXX) KATI_LD ?= $(CXX) -KATI_INTERMEDIATES_PATH ?= . +KATI_INTERMEDIATES_PATH ?= out KATI_BIN_PATH ?= . KATI_CXX_SRCS := \ @@ -103,11 +103,13 @@ $(KATI_CXX_TEST_EXES): $(KATI_BIN_PATH)/%: $(KATI_INTERMEDIATES_PATH)/%.o # Rule to generate version.cc KATI_GIT_DIR := $(shell cd $(KATI_SRC_PATH); realpath `git rev-parse --git-dir`) +KATI_VERSION_DEPS := ifneq ($(KATI_GIT_DIR),) -KATI_VERSION_DEPS := $(KATI_GIT_DIR)/HEAD $(KATI_GIT_DIR)/index +KATI_VERSION_DEPS := $(wildcard $(KATI_GIT_DIR)/HEAD $(KATI_GIT_DIR)/index) +endif +ifneq ($(KATI_VERSION_DEPS),) KATI_VERSION := $(shell git -C $(KATI_GIT_DIR) rev-parse HEAD) else -KATI_VERSION_DEPS := KATI_VERSION := unknown endif $(KATI_INTERMEDIATES_PATH)/version.cc: $(KATI_VERSION_DEPS) @@ -127,6 +129,7 @@ ckati_clean: rm -rf $(KATI_INTERMEDIATES_PATH)/*.d rm -rf $(KATI_INTERMEDIATES_PATH)/version.cc rm -rf $(KATI_CXX_TEST_EXES) + rm -rf $(KATI_BIN_PATH)/ckati rm -rf out .PHONY: ckati_clean diff --git a/Makefile.kati b/Makefile.kati index df91cbb..f4f5f4c 100644 --- a/Makefile.kati +++ b/Makefile.kati @@ -12,30 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -GO_SRCS:=$(wildcard *.go) +GO_SRCS:=$(wildcard golang/kati/*.go golang/cmd/*/*.go) -ifeq (${GOPATH},) -KATI_GOPATH:=$$(pwd)/out -else -KATI_GOPATH:=$$(pwd)/out:$${GOPATH} -endif - -kati: go_src_stamp - -rm -f out/bin/kati - GOPATH=${KATI_GOPATH} go install -ldflags "-X github.com/google/kati.gitVersion=$(shell git rev-parse HEAD)" github.com/google/kati/cmd/kati - cp out/bin/kati $@ - -go_src_stamp: $(GO_SRCS) $(wildcard cmd/*/*.go) - -rm -rf out/src out/pkg - mkdir -p out/src/github.com/google/kati - cp -a $(GO_SRCS) cmd out/src/github.com/google/kati - GOPATH=${KATI_GOPATH} go get github.com/google/kati/cmd/kati - touch $@ +kati: $(GO_SRCS) + go build -o $@ -ldflags "-X github.com/google/kati.gitVersion=$(shell git rev-parse HEAD)" github.com/google/kati/golang/cmd/kati go_test: $(GO_SRCS) - GOPATH=${KATI_GOPATH} go test *.go + go test ./golang/kati go_clean: - rm -rf out kati go_src_stamp + rm -rf kati .PHONY: go_clean go_test @@ -16,42 +16,3 @@ For Android-N+, ckati and ninja is used automatically. There is a prebuilt checked in under prebuilts/build-tools that is used. All Android's build commands (m, mmm, mmma, etc.) should just work. - -How to use for Android (deprecated -- only for Android M or earlier) ----------------------- - -Set up kati: - - % cd ~/src - % git clone https://github.com/google/kati - % cd kati - % make - -Build Android: - - % cd <android-directory> - % source build/envsetup.sh - % lunch <your-choice> - % ~/src/kati/m2n --kati_stats - % ./ninja.sh - -You need ninja in your $PATH. - -More usage examples (deprecated way) -------------------- - -### "make clean" - - % ./ninja.sh -t clean - -Note ./ninja.sh passes all parameters to ninja. - -### Build a specific target - -For example, the following is equivalent to "make cts": - - % ./ninja.sh cts - -Or, if you know the path you want, you can do: - - % ./ninja.sh out/host/linux-x86/bin/adb diff --git a/clang-format-check b/clang-format-check index c0a01f2..acbf3ce 100755 --- a/clang-format-check +++ b/clang-format-check @@ -4,11 +4,11 @@ if [ -z "$CLANG_FORMAT" ]; then CLANG_FORMAT="clang-format" fi -for f in $(ls *.cc *.h); do +for f in $(ls src/*.cc src/*.h); do if ! diff -U 1 <($CLANG_FORMAT $f) $f; then echo echo "!!!!!!" - echo "!! Failed clang-format check, please run 'clang-format -i *.cc *.h'" 1>&2 + echo "!! Failed clang-format check, please run 'clang-format -i src/*.cc src/*.h'" 1>&2 echo "!!!!!!" exit 1 fi @@ -0,0 +1,8 @@ +module github.com/google/kati + +go 1.14 + +require ( + github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b + github.com/sergi/go-diff v1.1.0 +) @@ -0,0 +1,16 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/cmd/kati/main.go b/golang/cmd/kati/main.go index 67c3a97..e27c6c0 100644 --- a/cmd/kati/main.go +++ b/golang/cmd/kati/main.go @@ -27,7 +27,7 @@ import ( "time" "github.com/golang/glog" - "github.com/google/kati" + "github.com/google/kati/golang/kati" ) const shellDateTimeformat = time.RFC3339 diff --git a/ast.go b/golang/kati/ast.go index 2b43176..2b43176 100644 --- a/ast.go +++ b/golang/kati/ast.go diff --git a/bootstrap.go b/golang/kati/bootstrap.go index 9ef396a..9ef396a 100644 --- a/bootstrap.go +++ b/golang/kati/bootstrap.go diff --git a/buf.go b/golang/kati/buf.go index 737e7c9..737e7c9 100644 --- a/buf.go +++ b/golang/kati/buf.go diff --git a/buf_test.go b/golang/kati/buf_test.go index 8ee14a0..8ee14a0 100644 --- a/buf_test.go +++ b/golang/kati/buf_test.go diff --git a/dep.go b/golang/kati/dep.go index 2c9870d..2c9870d 100644 --- a/dep.go +++ b/golang/kati/dep.go diff --git a/depgraph.go b/golang/kati/depgraph.go index 5b32287..5b32287 100644 --- a/depgraph.go +++ b/golang/kati/depgraph.go diff --git a/doc.go b/golang/kati/doc.go index 488675e..488675e 100644 --- a/doc.go +++ b/golang/kati/doc.go diff --git a/eval.go b/golang/kati/eval.go index 30308c3..30308c3 100644 --- a/eval.go +++ b/golang/kati/eval.go diff --git a/evalcmd.go b/golang/kati/evalcmd.go index 37f94b8..37f94b8 100644 --- a/evalcmd.go +++ b/golang/kati/evalcmd.go diff --git a/exec.go b/golang/kati/exec.go index fbcf41e..fbcf41e 100644 --- a/exec.go +++ b/golang/kati/exec.go diff --git a/expr.go b/golang/kati/expr.go index 79978b6..79978b6 100644 --- a/expr.go +++ b/golang/kati/expr.go diff --git a/expr_test.go b/golang/kati/expr_test.go index ad51a89..ad51a89 100644 --- a/expr_test.go +++ b/golang/kati/expr_test.go diff --git a/fileutil.go b/golang/kati/fileutil.go index feef812..feef812 100644 --- a/fileutil.go +++ b/golang/kati/fileutil.go diff --git a/flags.go b/golang/kati/flags.go index f2353a2..f2353a2 100644 --- a/flags.go +++ b/golang/kati/flags.go diff --git a/func.go b/golang/kati/func.go index bdc560d..bdc560d 100644 --- a/func.go +++ b/golang/kati/func.go diff --git a/func_test.go b/golang/kati/func_test.go index b56291e..b56291e 100644 --- a/func_test.go +++ b/golang/kati/func_test.go diff --git a/log.go b/golang/kati/log.go index 4b3098f..4b3098f 100644 --- a/log.go +++ b/golang/kati/log.go diff --git a/ninja.go b/golang/kati/ninja.go index f90ff24..f90ff24 100644 --- a/ninja.go +++ b/golang/kati/ninja.go diff --git a/ninja_test.go b/golang/kati/ninja_test.go index 48a52f6..48a52f6 100644 --- a/ninja_test.go +++ b/golang/kati/ninja_test.go diff --git a/parser.go b/golang/kati/parser.go index aef20e2..aef20e2 100644 --- a/parser.go +++ b/golang/kati/parser.go diff --git a/pathutil.go b/golang/kati/pathutil.go index ad11c22..ad11c22 100644 --- a/pathutil.go +++ b/golang/kati/pathutil.go diff --git a/pathutil_test.go b/golang/kati/pathutil_test.go index 33b7e32..33b7e32 100644 --- a/pathutil_test.go +++ b/golang/kati/pathutil_test.go diff --git a/query.go b/golang/kati/query.go index 5da1f61..5da1f61 100644 --- a/query.go +++ b/golang/kati/query.go diff --git a/rule_parser.go b/golang/kati/rule_parser.go index 1bea505..1bea505 100644 --- a/rule_parser.go +++ b/golang/kati/rule_parser.go diff --git a/rule_parser_test.go b/golang/kati/rule_parser_test.go index be12041..be12041 100644 --- a/rule_parser_test.go +++ b/golang/kati/rule_parser_test.go diff --git a/serialize.go b/golang/kati/serialize.go index 3ccb469..3ccb469 100644 --- a/serialize.go +++ b/golang/kati/serialize.go diff --git a/shellutil.go b/golang/kati/shellutil.go index b7a16ac..b7a16ac 100644 --- a/shellutil.go +++ b/golang/kati/shellutil.go diff --git a/shellutil_test.go b/golang/kati/shellutil_test.go index 39c2c64..39c2c64 100644 --- a/shellutil_test.go +++ b/golang/kati/shellutil_test.go diff --git a/stats.go b/golang/kati/stats.go index a8ea461..a8ea461 100644 --- a/stats.go +++ b/golang/kati/stats.go diff --git a/strutil.go b/golang/kati/strutil.go index 39d282b..39d282b 100644 --- a/strutil.go +++ b/golang/kati/strutil.go diff --git a/strutil_test.go b/golang/kati/strutil_test.go index 56bfe87..56bfe87 100644 --- a/strutil_test.go +++ b/golang/kati/strutil_test.go diff --git a/symtab.go b/golang/kati/symtab.go index f8fc1f8..f8fc1f8 100644 --- a/symtab.go +++ b/golang/kati/symtab.go diff --git a/var.go b/golang/kati/var.go index 5e7e996..5e7e996 100644 --- a/var.go +++ b/golang/kati/var.go diff --git a/version.go b/golang/kati/version.go index 4ec6e6a..4ec6e6a 100644 --- a/version.go +++ b/golang/kati/version.go diff --git a/worker.go b/golang/kati/worker.go index a339d23..a339d23 100644 --- a/worker.go +++ b/golang/kati/worker.go @@ -1,120 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 Google Inc. All rights reserved -# -# Licensed 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. -# -# A wrapper for kati which generates build.ninja mainly for Android. -# - -set -e - -kati_dir=$(cd $(dirname $0) && pwd) -extra_flags= -goma_flag= -goma_dir=${GOMA_DIR:-$HOME/goma} - -while [ x"$1" != x"" ]; do - case "$1" in - --help) - cat - <<EOF -Usage: - m2n # for default full-build - m2n --goma # use goma. \$HOME/goma must exist, or set \$GOMA_DIR - m2n --go # use go version. Slower but maybe more portable. - m2n cts # for target 'cts' -EOF - exit 1 - ;; - - --go) - kati=${kati_dir}/kati - shift - ${kati} --m2n "$@" - echo - echo ninja.sh and build.ninja were generated, please run ./ninja.sh - exit - ;; - - --goma) - if [ ! -e $goma_dir/goma_ctl.py ]; then - echo "To use Goma you must set GOMA_DIR, or install goma in $HOME/goma" - exit 1 - fi - $goma_dir/goma_ctl.py ensure_start - goma_flag=--goma_dir=$goma_dir - shift - ;; - - --mmm) - echo 'Note: --mmm may not work' - shift; - mmm="$1" - shift - ;; - - -*) - extra_flags+=" $1" - shift - ;; - - *) - targets="${targets} $1" - shift - ;; - esac -done - -if [ x"${goma_flag}" != x ]; then - for k in CC_WRAPPER CXX_WRAPPER JAVAC_WRAPPER; do - val=$(eval echo \$$k) - if [ x"${val}" != x ]; then - echo "Note: \$$k=${val} may confuse m2n --goma, unsetting" - unset $k - fi - done -fi - -kati=${kati_dir}/ckati - -ninja_suffix= -ninja_suffix_flag= - -if [ x"${mmm}" != x"" ]; then - mk="${mmm}/Android.mk" - if [ ! -f ${mk} ]; then - echo "${mk} does not exist" - exit 1 - fi - - export ONE_SHOT_MAKEFILE=${mk} - echo ONE_SHOT_MAKEFILE=${ONE_SHOT_MAKEFILE} - - ninja_suffix+=-mmm-${mmm} -fi - -if [ x"${targets}" != x"" ]; then - ninja_suffix+=-$(echo ${targets} | sed 's/ /-/') -elif [ x"${mmm}" != x"" ]; then - targets=all_modules -fi - -if [ x"${ninja_suffix}" != x"" ]; then - ninja_suffix=$(echo ${ninja_suffix} | sed 'y/\//_/') - ninja_suffix_flag=--ninja_suffix=${ninja_suffix} -fi - -${kati} --ninja ${ninja_suffix_flag} --ignore_optional_include=out/%.P --ignore_dirty=out/% --use_find_emulator --detect_android_echo --detect_depfiles --gen_all_targets ${goma_flag} ${extra_flags} ${targets} - -echo -echo ninja${ninja_suffix}.sh and build${ninja_suffix}.ninja were generated, please run ./ninja${ninja_suffix}.sh diff --git a/make-c.sh b/make-c.sh deleted file mode 100755 index d17b9a8..0000000 --- a/make-c.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# Copyright 2015 Google Inc. All rights reserved -# -# Licensed 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. -# -# simple tool to measure time to parse Makefiles in android. -# -# usage: -# $ ./repo/android.sh make-c.sh -dir=$(cd $(dirname $0); pwd) -go run ${dir}/make-c/main.go diff --git a/make-c/main.go b/make-c/main.go deleted file mode 100644 index 9c18c1d..0000000 --- a/make-c/main.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved -// -// Licensed 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. - -// make-c is simple program to measure time to parse Makefiles in android. -package main - -import ( - "bufio" - "bytes" - "fmt" - "os/exec" - "time" -) - -func main() { - parseDone := make(chan bool) - cmd := exec.Command("make", "-n") - r, err := cmd.StdoutPipe() - if err != nil { - panic(err) - } - t := time.Now() - go func() { - s := bufio.NewScanner(r) - for s.Scan() { - if bytes.HasPrefix(s.Bytes(), []byte("echo ")) { - parseDone <- true - return - } - fmt.Println(s.Text()) - } - if err := s.Err(); err != nil { - panic(err) - } - panic("unexpected end of make?") - }() - err = cmd.Start() - if err != nil { - panic(err) - } - select { - case <-parseDone: - fmt.Printf("make -c: %v\n", time.Since(t)) - } - cmd.Process.Kill() - cmd.Wait() -} diff --git a/pack.sh b/pack.sh deleted file mode 100755 index 1e73d6a..0000000 --- a/pack.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# -# Copyright 2015 Google Inc. All rights reserved -# -# Licensed 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. - -set -e - -make kati ckati - -rm -fr out/kati -mkdir out/kati -git archive --prefix src/ master | tar -C out/kati -xvf - - -cd out/kati -rm src/repo/android.tgz -cp ../../m2n ../../kati ../../ckati . -cd .. -tar -cvzf ../kati.tgz kati diff --git a/run_test.go b/run_test.go new file mode 100644 index 0000000..d295ddf --- /dev/null +++ b/run_test.go @@ -0,0 +1,512 @@ +// Copyright 2020 Google Inc. All rights reserved +// +// Licensed 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. + +package kati + +import ( + "bytes" + "flag" + "io/ioutil" + "os" + "os/exec" + "path/filepath" + "regexp" + "sort" + "strings" + "testing" + + "github.com/sergi/go-diff/diffmatchpatch" +) + +var ckati bool +var ninja bool +var genAllTargets bool + +func init() { + // suppress GNU make jobserver magic when calling "make" + os.Unsetenv("MAKEFLAGS") + os.Unsetenv("MAKELEVEL") + os.Setenv("NINJA_STATUS", "NINJACMD: ") + + flag.BoolVar(&ckati, "ckati", false, "use ckati") + flag.BoolVar(&ninja, "ninja", false, "use ninja") + flag.BoolVar(&genAllTargets, "all", false, "use --gen_all_targets") +} + +type normalization struct { + regexp *regexp.Regexp + replace string +} + +var normalizeQuotes = normalization{ + regexp.MustCompile("([`'\"]|\xe2\x80\x98|\xe2\x80\x99)"), `"`, +} + +var normalizeMakeLog = []normalization{ + normalizeQuotes, + {regexp.MustCompile(`make(?:\[\d+\])?: (Entering|Leaving) directory[^\n]*`), ""}, + {regexp.MustCompile(`make(?:\[\d+\])?: `), ""}, + + // Normalizations for old/new GNU make. + {regexp.MustCompile(" recipe for target "), " commands for target "}, + {regexp.MustCompile(" recipe commences "), " commands commence "}, + {regexp.MustCompile("missing rule before recipe."), "missing rule before commands."}, + {regexp.MustCompile(" (did you mean TAB instead of 8 spaces?)"), ""}, + {regexp.MustCompile("Extraneous text after"), "extraneous text after"}, + // Not sure if this is useful + {regexp.MustCompile(`\s+Stop\.`), ""}, + // GNU make 4.0 has this output. + {regexp.MustCompile(`Makefile:\d+: commands for target ".*?" failed\n`), ""}, + // We treat some warnings as errors. + {regexp.MustCompile(`/bin/(ba)?sh: line 0: `), ""}, + // Normalization for "include foo" with C++ kati + {regexp.MustCompile(`(: \S+: No such file or directory)\n\*\*\* No rule to make target "[^"]+".`), "$1"}, +} + +var normalizeMakeNinja = normalization{ + // We print out some ninja warnings in some tests to match what we expect + // ninja to produce. Remove them if we're not testing ninja + regexp.MustCompile("ninja: warning: [^\n]+"), "", +} + +var normalizeKati = []normalization{ + normalizeQuotes, + + // kati specific log messages + {regexp.MustCompile(`\*kati\*[^\n]*`), ""}, + {regexp.MustCompile(`c?kati: `), ""}, + {regexp.MustCompile(`/bin/sh: line 0: `), ""}, + {regexp.MustCompile(`/bin/sh: `), ""}, + {regexp.MustCompile(`.*: warning for parse error in an unevaluated line: [^\n]*`), ""}, + {regexp.MustCompile(`([^\n ]+: )?FindEmulator: `), ""}, + // kati log ifles in find_command.mk + {regexp.MustCompile(` (\./+)+kati\.\S+`), ""}, + // json files in find_command.mk + {regexp.MustCompile(` (\./+)+test\S+.json`), ""}, + // Normalization for "include foo" with Go kati + {regexp.MustCompile(`(: )open (\S+): n(o such file or directory)\nNOTE:[^\n]*`), "${1}${2}: N${3}"}, + // Bionic libc has different error messages than glibc + {regexp.MustCompile(`Too many symbolic links encountered`), "Too many levels of symbolic links"}, +} + +var normalizeNinja = []normalization{ + {regexp.MustCompile(`NINJACMD: [^\n]*\n`), ""}, + {regexp.MustCompile(`ninja: no work to do\.\n`), ""}, + {regexp.MustCompile(`ninja: error: (.*, needed by .*),[^\n]*`), + "*** No rule to make target ${1}."}, + {regexp.MustCompile(`ninja: warning: multiple rules generate (.*)\. builds involving this target will not be correct[^\n]*`), + "ninja: warning: multiple rules generate ${1}."}, +} + +var normalizeNinjaFail = []normalization{ + {regexp.MustCompile(`FAILED: ([^\n]+\n/bin/bash)?[^\n]*\n`), "*** [test] Error 1\n"}, + {regexp.MustCompile(`ninja: [^\n]+\n`), ""}, +} + +var normalizeNinjaIgnoreFail = []normalization{ + {regexp.MustCompile(`FAILED: ([^\n]+\n/bin/bash)?[^\n]*\n`), ""}, + {regexp.MustCompile(`ninja: [^\n]+\n`), ""}, +} + +var circularRE = regexp.MustCompile(`(Circular .* dropped\.\n)`) + +func normalize(log []byte, normalizations []normalization) []byte { + // We don't care when circular dependency detection happens. + ret := []byte{} + for _, circ := range circularRE.FindAllSubmatch(log, -1) { + ret = append(ret, circ[1]...) + } + ret = append(ret, circularRE.ReplaceAll(log, []byte{})...) + + for _, n := range normalizations { + ret = n.regexp.ReplaceAll(ret, []byte(n.replace)) + } + return ret +} + +func runMake(t *testing.T, prefix []string, dir string, silent bool, tc string) string { + write := func(f string, data []byte) { + suffix := "" + if tc != "" { + suffix = "_" + tc + } + if err := ioutil.WriteFile(filepath.Join(dir, f+suffix), data, 0666); err != nil { + t.Error(err) + } + } + + args := append(prefix, "make") + if silent { + args = append(args, "-s") + } + if tc != "" { + args = append(args, tc) + } + args = append(args, "SHELL=/bin/bash") + + cmd := exec.Command(args[0], args[1:]...) + cmd.Dir = dir + output, _ := cmd.CombinedOutput() + write("stdout", output) + + output = normalize(output, normalizeMakeLog) + if !ninja { + output = normalize(output, []normalization{normalizeMakeNinja}) + } + + write("stdout_normalized", output) + return string(output) +} + +func runKati(t *testing.T, test, dir string, silent bool, tc string) string { + write := func(f string, data []byte) { + suffix := "" + if tc != "" { + suffix = "_" + tc + } + if err := ioutil.WriteFile(filepath.Join(dir, f+suffix), data, 0666); err != nil { + t.Error(err) + } + } + + var cmd *exec.Cmd + if ckati { + cmd = exec.Command("../../../ckati", "--use_find_emulator") + } else { + json := tc + if json == "" { + json = "test" + } + cmd = exec.Command("../../../kati", "-save_json="+json+".json", "-log_dir=.", "--use_find_emulator") + } + if ninja { + cmd.Args = append(cmd.Args, "--ninja") + } + if genAllTargets { + cmd.Args = append(cmd.Args, "--gen_all_targets") + } + if silent { + cmd.Args = append(cmd.Args, "-s") + } + cmd.Args = append(cmd.Args, "SHELL=/bin/bash") + if tc != "" && (!genAllTargets || strings.Contains(test, "makecmdgoals")) { + cmd.Args = append(cmd.Args, tc) + } + cmd.Dir = dir + output, err := cmd.CombinedOutput() + write("stdout", output) + if err != nil { + output := normalize(output, normalizeKati) + write("stdout_normalized", output) + return string(output) + } + + if ninja { + ninjaCmd := exec.Command("./ninja.sh", "-j1", "-v") + if genAllTargets && tc != "" { + ninjaCmd.Args = append(ninjaCmd.Args, tc) + } + ninjaCmd.Dir = dir + ninjaOutput, _ := ninjaCmd.CombinedOutput() + write("stdout_ninja", ninjaOutput) + ninjaOutput = normalize(ninjaOutput, normalizeNinja) + if test == "err_error_in_recipe.mk" { + ninjaOutput = normalize(ninjaOutput, normalizeNinjaIgnoreFail) + } else if strings.HasPrefix(test, "fail_") { + ninjaOutput = normalize(ninjaOutput, normalizeNinjaFail) + } + write("stdout_ninja_normalized", ninjaOutput) + output = append(output, ninjaOutput...) + } + + output = normalize(output, normalizeKati) + write("stdout_normalized", output) + return string(output) +} + +func runKatiInScript(t *testing.T, script, dir string, isNinjaTest bool) string { + write := func(f string, data []byte) { + if err := ioutil.WriteFile(filepath.Join(dir, f), data, 0666); err != nil { + t.Error(err) + } + } + + args := []string{"bash", script} + if ckati { + args = append(args, "../../../ckati") + if isNinjaTest { + args = append(args, "--ninja", "--regen") + } + } else { + args = append(args, "../../../kati --use_cache -log_dir=.") + } + args = append(args, "SHELL=/bin/bash") + + cmd := exec.Command(args[0], args[1:]...) + cmd.Dir = dir + output, _ := cmd.Output() + write("stdout", output) + if isNinjaTest { + output = normalize(output, normalizeNinja) + } + output = normalize(output, normalizeKati) + write("stdout_normalized", output) + return string(output) +} + +func inList(list []string, item string) bool { + for _, i := range list { + if item == i { + return true + } + } + return false +} + +func diffLists(a, b []string) (onlyA []string, onlyB []string) { + for _, i := range a { + if !inList(b, i) { + onlyA = append(onlyA, i) + } + } + for _, i := range b { + if !inList(a, i) { + onlyB = append(onlyB, i) + } + } + return +} + +func outputFiles(t *testing.T, dir string) []string { + ret := []string{} + files, err := ioutil.ReadDir(dir) + if err != nil { + t.Fatal(err) + } + ignoreFiles := []string{ + ".", "..", "Makefile", "build.ninja", "env.sh", "ninja.sh", "gmon.out", "submake", + } + for _, fi := range files { + name := fi.Name() + if inList(ignoreFiles, name) || + strings.HasPrefix(name, ".") || + strings.HasSuffix(name, ".json") || + strings.HasPrefix(name, "kati") || + strings.HasPrefix(name, "stdout") { + continue + } + ret = append(ret, fi.Name()) + } + return ret +} + +var testcaseRE = regexp.MustCompile(`^test\d*`) + +func uniqueTestcases(c []byte) []string { + seen := map[string]bool{} + ret := []string{} + for _, line := range bytes.Split(c, []byte("\n")) { + line := string(line) + s := testcaseRE.FindString(line) + if s == "" { + continue + } + if _, ok := seen[s]; ok { + continue + } + seen[s] = true + ret = append(ret, s) + } + sort.Strings(ret) + if len(ret) == 0 { + return []string{""} + } + return ret +} + +var todoRE = regexp.MustCompile(`^# TODO(?:\(([-a-z|]+)(?:/([-a-z0-9|]+))?\))?`) + +func isExpectedFailure(c []byte, tc string) bool { + for _, line := range bytes.Split(c, []byte("\n")) { + line := string(line) + if !strings.HasPrefix(line, "#!") && !strings.HasPrefix(line, "# TODO") { + break + } + + todo := todoRE.FindStringSubmatch(line) + if todo == nil { + continue + } + + if todo[1] == "" { + return true + } + + todos := strings.Split(todo[1], "|") + if (inList(todos, "go") && !ckati) || + (inList(todos, "c") && ckati) || + (inList(todos, "go-ninja") && !ckati && ninja) || + (inList(todos, "c-ninja") && ckati && ninja) || + (inList(todos, "c-exec") && ckati && !ninja) || + (inList(todos, "ninja") && ninja) || + (inList(todos, "ninja-genall") && ninja && genAllTargets) || + (inList(todos, "all")) { + + if todo[2] == "" { + return true + } + tcs := strings.Split(todo[2], "|") + if inList(tcs, tc) { + return true + } + } + } + return false +} + +func TestKati(t *testing.T) { + if ckati { + os.Setenv("KATI_VARIANT", "c") + if _, err := os.Stat("ckati"); err != nil { + t.Fatalf("ckati must be built before testing: %s", err) + } + } else { + if _, err := os.Stat("kati"); err != nil { + t.Fatalf("kati must be built before testing: %s", err) + } + } + if ninja { + if _, err := exec.LookPath("ninja"); err != nil { + t.Fatal(err) + } + } + + out, _ := filepath.Abs("out") + files, err := ioutil.ReadDir("testcase") + if err != nil { + t.Fatal(err) + } + for _, fi := range files { + name := fi.Name() + + isMkTest := strings.HasSuffix(name, ".mk") + isShTest := strings.HasSuffix(name, ".sh") + if strings.HasPrefix(name, ".") || !(isMkTest || isShTest) { + continue + } + + t.Run(name, func(t *testing.T) { + t.Parallel() + + c, err := ioutil.ReadFile(filepath.Join("testcase", name)) + if err != nil { + t.Fatal(err) + } + + out := filepath.Join(out, name) + if err := os.RemoveAll(out); err != nil { + t.Fatal(err) + } + outMake := filepath.Join(out, "make") + outKati := filepath.Join(out, "kati") + if err := os.MkdirAll(outMake, 0777); err != nil { + t.Fatal(err) + } + if err := os.MkdirAll(outKati, 0777); err != nil { + t.Fatal(err) + } + + testcases := []string{""} + expected := map[string]string{} + expectedFiles := map[string][]string{} + expectedFailures := map[string]bool{} + got := map[string]string{} + gotFiles := map[string][]string{} + + if isMkTest { + setup := func(dir string) { + if err = ioutil.WriteFile(filepath.Join(dir, "Makefile"), c, 0666); err != nil { + t.Fatal(err) + } + os.Symlink("../../../testcase/submake", filepath.Join(dir, "submake")) + } + setup(outMake) + setup(outKati) + + testcases = uniqueTestcases(c) + + isSilent := strings.HasPrefix(name, "submake_") + + for _, tc := range testcases { + expected[tc] = runMake(t, nil, outMake, ninja || isSilent, tc) + expectedFiles[tc] = outputFiles(t, outMake) + expectedFailures[tc] = isExpectedFailure(c, tc) + } + + for _, tc := range testcases { + got[tc] = runKati(t, name, outKati, isSilent, tc) + gotFiles[tc] = outputFiles(t, outKati) + } + } else if isShTest { + isNinjaTest := strings.HasPrefix(name, "ninja_") + if isNinjaTest && (!ckati || !ninja) { + t.SkipNow() + } + + scriptName := "../../../testcase/" + name + + expected[""] = runMake(t, []string{"bash", scriptName}, outMake, isNinjaTest, "") + expectedFailures[""] = isExpectedFailure(c, "") + + got[""] = runKatiInScript(t, scriptName, outKati, isNinjaTest) + } + + check := func(t *testing.T, m, k string, mFiles, kFiles []string, expectFail bool) { + if strings.Contains(m, "FAIL") { + t.Fatalf("Make returned 'FAIL':\n%q", m) + } + + if !expectFail && m != k { + dmp := diffmatchpatch.New() + diffs := dmp.DiffMain(k, m, true) + diffs = dmp.DiffCleanupSemantic(diffs) + t.Errorf("Different output from kati (red) to the expected value from make (green):\n%s", + dmp.DiffPrettyText(diffs)) + } else if expectFail && m == k { + t.Errorf("Expected failure, but output is the same") + } + + if !expectFail { + onlyMake, onlyKati := diffLists(mFiles, kFiles) + if len(onlyMake) > 0 { + t.Errorf("Files only created by Make:\n%q", onlyMake) + } + if len(onlyKati) > 0 { + t.Errorf("Files only created by Kati:\n%q", onlyKati) + } + } + } + + for _, tc := range testcases { + if tc == "" || len(testcases) == 1 { + check(t, expected[tc], got[tc], expectedFiles[tc], gotFiles[tc], expectedFailures[tc]) + } else { + t.Run(tc, func(t *testing.T) { + check(t, expected[tc], got[tc], expectedFiles[tc], gotFiles[tc], expectedFailures[tc]) + }) + } + } + }) + } +} diff --git a/runtest.rb b/runtest.rb deleted file mode 100755 index 173c66d..0000000 --- a/runtest.rb +++ /dev/null @@ -1,440 +0,0 @@ -#!/usr/bin/env ruby -# coding: binary -# -# Copyright 2015 Google Inc. All rights reserved -# -# Licensed 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. - -require 'fileutils' - -# suppress GNU make jobserver magic when calling "make" -ENV.delete('MAKEFLAGS') -ENV.delete('MAKELEVEL') - -while true - if ARGV[0] == '-s' - test_serialization = true - ARGV.shift - elsif ARGV[0] == '-c' - $ckati = true - ARGV.shift - ENV['KATI_VARIANT'] = 'c' - elsif ARGV[0] == '-n' - $via_ninja = true - ARGV.shift - ENV['NINJA_STATUS'] = 'NINJACMD: ' - elsif ARGV[0] == '-a' - gen_all_targets = true - ARGV.shift - elsif ARGV[0] == '-v' - $show_failing = true - ARGV.shift - elsif ARGV[0] == "-q" - $hide_passing = true - ARGV.shift - else - break - end -end - -def get_output_filenames - files = Dir.glob('*') - files.delete('Makefile') - files.delete('build.ninja') - files.delete('env.sh') - files.delete('ninja.sh') - files.delete('gmon.out') - files.delete('submake') - files.reject!{|f|f =~ /\.json$/} - files.reject!{|f|f =~ /^kati\.*/} - files -end - -def cleanup - (get_output_filenames + Dir.glob('.*')).each do |fname| - next if fname == '.' || fname == '..' - FileUtils.rm_rf fname - end -end - -def move_circular_dep(l) - # We don't care when circular dependency detection happens. - circ = '' - while l.sub!(/Circular .* dropped\.\n/, '') do - circ += $& - end - circ + l -end - -$expected_failures = [] -$unexpected_passes = [] -$failures = [] -$passes = [] - -if !ARGV.empty? - test_files = ARGV.map do |test| - "testcase/#{File.basename(test)}" - end -else - test_files = Dir.glob('testcase/*.mk').sort - test_files += Dir.glob('testcase/*.sh').sort -end - -def run_in_testdir(test_filename) - c = File.read(test_filename) - name = File.basename(test_filename) - dir = "out/#{name}" - - FileUtils.mkdir_p(dir) - Dir.glob("#{dir}/*").each do |fname| - FileUtils.rm_rf(fname) - end - - Dir.chdir(dir) do - yield name - end -end - -def normalize_ninja_log(log, mk) - log.gsub!(/^NINJACMD: .*\n/, '') - log.gsub!(/^ninja: no work to do\.\n/, '') - log.gsub!(/^ninja: error: (.*, needed by .*),.*/, - '*** No rule to make target \\1.') - log.gsub!(/^ninja: warning: multiple rules generate (.*)\. builds involving this target will not be correct.*$/, - 'ninja: warning: multiple rules generate \\1.') - - if mk =~ /err_error_in_recipe.mk/ - # This test expects ninja fails. Strip ninja specific error logs. - ninja_failed_subst = '' - elsif mk =~ /\/fail_/ - # Recipes in these tests fail. - ninja_failed_subst = "*** [test] Error 1\n" - end - if ninja_failed_subst - log.gsub!(/^FAILED: (.*\n\/bin\/bash)?.*\n/, ninja_failed_subst) - log.gsub!(/^ninja: .*\n/, '') - end - log -end - -def normalize_quotes(log) - log.gsub!(/[`'"]/, '"') - # For recent GNU find, which uses Unicode characters. - log.gsub!(/(\xe2\x80\x98|\xe2\x80\x99)/, '"') - log -end - -def normalize_make_log(expected, mk, via_ninja) - expected = normalize_quotes(expected) - expected.gsub!(/^make(?:\[\d+\])?: (Entering|Leaving) directory.*\n/, '') - expected.gsub!(/^make(?:\[\d+\])?: /, '') - expected = move_circular_dep(expected) - - # Normalizations for old/new GNU make. - expected.gsub!(' recipe for target ', ' commands for target ') - expected.gsub!(' recipe commences ', ' commands commence ') - expected.gsub!('missing rule before recipe.', 'missing rule before commands.') - expected.gsub!(' (did you mean TAB instead of 8 spaces?)', '') - expected.gsub!('Extraneous text after', 'extraneous text after') - # Not sure if this is useful. - expected.gsub!(/\s+Stop\.$/, '') - # GNU make 4.0 has this output. - expected.gsub!(/Makefile:\d+: commands for target ".*?" failed\n/, '') - # We treat some warnings as errors. - expected.gsub!(/^\/bin\/(ba)?sh: line 0: /, '') - # We print out some ninja warnings in some tests to match what we expect - # ninja to produce. Remove them if we're not testing ninja. - if !via_ninja - expected.gsub!(/^ninja: warning: .*\n/, '') - end - # Normalization for "include foo" with C++ kati. - expected.gsub!(/(: )(\S+): (No such file or directory)\n\*\*\* No rule to make target "\2"./, '\1\2: \3') - - expected -end - -def normalize_kati_log(output) - output = normalize_quotes(output) - output = move_circular_dep(output) - - # kati specific log messages. - output.gsub!(/^\*kati\*.*\n/, '') - output.gsub!(/^c?kati: /, '') - output.gsub!(/\/bin\/sh: ([^:]*): command not found/, - "\\1: Command not found") - output.gsub!(/.*: warning for parse error in an unevaluated line: .*\n/, '') - output.gsub!(/^([^ ]+: )?FindEmulator: /, '') - output.gsub!(/^\/bin\/sh: line 0: /, '') - output.gsub!(/ (\.\/+)+kati\.\S+/, '') # kati log files in find_command.mk - output.gsub!(/ (\.\/+)+test\S+.json/, '') # json files in find_command.mk - # Normalization for "include foo" with Go kati. - output.gsub!(/(: )open (\S+): n(o such file or directory)\nNOTE:.*/, - "\\1\\2: N\\3") - # Bionic libc has different error messages than glibc - output.gsub!(/Too many symbolic links encountered/, 'Too many levels of symbolic links') - output -end - -bash_var = ' SHELL=/bin/bash' - -def is_expected_failure(f) - c = File.read(f) - expected_failure = false - if c =~ /\A(#!\/bin\/bash\n)?# TODO(?:\(([-a-z|]+)\))?/ - if $2 - todos = $2.split('|') - if todos.include?('go') && !$ckati - expected_failure = true - end - if todos.include?('c') && $ckati - expected_failure = true - end - if todos.include?('go-ninja') && !$ckati && $via_ninja - expected_failure = true - end - if todos.include?('c-ninja') && $ckati && $via_ninja - expected_failure = true - end - if todos.include?('c-exec') && $ckati && !$via_ninja - expected_failure = true - end - if todos.include?('ninja') && $via_ninja - expected_failure = true - end - else - expected_failure = true - end - end - return expected_failure -end - -report_result = proc do |name, expected, output, expected_failure| - if expected != output - if expected_failure - if !$hide_passing - puts "#{name}: FAIL (expected)" - end - $expected_failures << name - else - puts "#{name}: FAIL" - $failures << name - end - if !expected_failure || $show_failing - puts `diff -u out.make out.kati` - end - else - if expected_failure - puts "#{name}: PASS (unexpected)" - $unexpected_passes << name - else - if !$hide_passing - puts "#{name}: PASS" - end - $passes << name - end - end -end - -run_make_test = proc do |mk| - expected_failure = is_expected_failure(mk) - c = File.read(mk) - run_in_testdir(mk) do |name| - File.open("Makefile", 'w') do |ofile| - ofile.print(c) - end - File.symlink('../../testcase/submake', 'submake') - - expected = '' - output = '' - - testcases = c.scan(/^test\d*/).sort.uniq - if testcases.empty? - testcases = [''] - end - - is_silent_test = mk =~ /\/submake_/ - - cleanup - testcases.each do |tc| - cmd = 'make' - if $via_ninja || is_silent_test - cmd += ' -s' - end - cmd += bash_var - cmd += " #{tc} 2>&1" - res = IO.popen(cmd, 'r:binary', &:read) - res = normalize_make_log(res, mk, $via_ninja) - expected += "=== #{tc} ===\n" + res - expected_files = get_output_filenames - expected += "\n=== FILES ===\n#{expected_files * "\n"}\n" - end - - cleanup - testcases.each do |tc| - json = "#{tc.empty? ? 'test' : tc}" - cmd = "../../kati -save_json=#{json}.json -log_dir=. --use_find_emulator" - if $ckati - cmd = "../../ckati --use_find_emulator" - end - if $via_ninja - cmd += ' --ninja' - end - if gen_all_targets - if !$ckati || !$via_ninja - raise "-a should be used with -c -n" - end - cmd += ' --gen_all_targets' - end - if is_silent_test - cmd += ' -s' - end - cmd += bash_var - if !gen_all_targets || mk =~ /makecmdgoals/ - cmd += " #{tc}" - end - cmd += " 2>&1" - res = IO.popen(cmd, 'r:binary', &:read) - if $via_ninja && File.exist?('build.ninja') && File.exists?('ninja.sh') - cmd = './ninja.sh -j1 -v' - if gen_all_targets - cmd += " #{tc}" - end - cmd += ' 2>&1' - log = IO.popen(cmd, 'r:binary', &:read) - res += normalize_ninja_log(log, mk) - end - res = normalize_kati_log(res) - output += "=== #{tc} ===\n" + res - output_files = get_output_filenames - output += "\n=== FILES ===\n#{output_files * "\n"}\n" - end - - File.open('out.make', 'w'){|ofile|ofile.print(expected)} - File.open('out.kati', 'w'){|ofile|ofile.print(output)} - - if expected =~ /FAIL/ - puts %Q(#{name} has a string "FAIL" in its expectation) - exit 1 - end - - report_result.call(name, expected, output, expected_failure) - - if name !~ /^err_/ && test_serialization && !expected_failure - testcases.each do |tc| - json = "#{tc.empty? ? 'test' : tc}" - cmd = "../../kati -save_json=#{json}_2.json -load_json=#{json}.json -n -log_dir=. #{tc} 2>&1" - res = IO.popen(cmd, 'r:binary', &:read) - if !File.exist?("#{json}.json") || !File.exist?("#{json}_2.json") - puts "#{name}##{json}: Serialize failure (not exist)" - puts res - else - json1 = File.read("#{json}.json") - json2 = File.read("#{json}_2.json") - if json1 != json2 - puts "#{name}##{json}: Serialize failure" - puts res - end - end - end - end - end -end - -run_shell_test = proc do |sh| - is_ninja_test = sh =~ /\/ninja_/ - if is_ninja_test && (!$ckati || !$via_ninja) - next - end - - expected_failure = is_expected_failure(sh) - - run_in_testdir(sh) do |name| - cleanup - cmd = "bash ../../#{sh} make" - if is_ninja_test - cmd += ' -s' - end - cmd += bash_var - expected = IO.popen(cmd, 'r:binary', &:read) - cleanup - - if is_ninja_test - if $ckati - cmd = "bash ../../#{sh} ../../ckati --ninja --regen" - else - next - end - else - if $ckati - cmd = "bash ../../#{sh} ../../ckati" - else - cmd = "bash ../../#{sh} ../../kati --use_cache -log_dir=." - end - end - cmd += bash_var - - output = IO.popen(cmd, 'r:binary', &:read) - - expected = normalize_make_log(expected, sh, is_ninja_test) - output = normalize_kati_log(output) - if is_ninja_test - output = normalize_ninja_log(output, sh) - end - File.open('out.make', 'w'){|ofile|ofile.print(expected)} - File.open('out.kati', 'w'){|ofile|ofile.print(output)} - - report_result.call(name, expected, output, expected_failure) - end -end - -test_files.each do |test| - if /\.mk$/ =~ test - run_make_test.call(test) - elsif /\.sh$/ =~ test - run_shell_test.call(test) - else - raise "Unknown test type: #{test}" - end -end - -puts - -if !$expected_failures.empty? && !$hide_passing - puts "=== Expected failures ===" - $expected_failures.each do |n| - puts n - end -end - -if !$unexpected_passes.empty? - puts "=== Unexpected passes ===" - $unexpected_passes.each do |n| - puts n - end -end - -if !$failures.empty? - puts "=== Failures ===" - $failures.each do |n| - puts n - end -end - -puts - -if !$unexpected_passes.empty? || !$failures.empty? - puts "FAIL! (#{$failures.size + $unexpected_passes.size} fails #{$passes.size} passes)" - exit 1 -else - puts 'PASS!' -end diff --git a/Android.bp b/src/Android.bp index 149d170..149d170 100644 --- a/Android.bp +++ b/src/Android.bp diff --git a/affinity.cc b/src/affinity.cc index 9e855f3..9e855f3 100644 --- a/affinity.cc +++ b/src/affinity.cc diff --git a/affinity.h b/src/affinity.h index e6f6adc..e6f6adc 100644 --- a/affinity.h +++ b/src/affinity.h diff --git a/command.cc b/src/command.cc index 04bb168..04bb168 100644 --- a/command.cc +++ b/src/command.cc diff --git a/command.h b/src/command.h index 5e86333..5e86333 100644 --- a/command.h +++ b/src/command.h diff --git a/file_cache.cc b/src/file_cache.cc index fe16c3b..fe16c3b 100644 --- a/file_cache.cc +++ b/src/file_cache.cc diff --git a/file_cache.h b/src/file_cache.h index fac2077..fac2077 100644 --- a/file_cache.h +++ b/src/file_cache.h diff --git a/fileutil.cc b/src/fileutil.cc index 7ebb8ec..7ebb8ec 100644 --- a/fileutil.cc +++ b/src/fileutil.cc diff --git a/fileutil.h b/src/fileutil.h index ba5b9b6..ba5b9b6 100644 --- a/fileutil.h +++ b/src/fileutil.h diff --git a/fileutil_bench.cc b/src/fileutil_bench.cc index 429d004..429d004 100644 --- a/fileutil_bench.cc +++ b/src/fileutil_bench.cc diff --git a/find_test.cc b/src/find_test.cc index e8d521c..e8d521c 100644 --- a/find_test.cc +++ b/src/find_test.cc diff --git a/ninja_test.cc b/src/ninja_test.cc index 15b0693..15b0693 100644 --- a/ninja_test.cc +++ b/src/ninja_test.cc diff --git a/parser.cc b/src/parser.cc index 4980f77..4980f77 100644 --- a/parser.cc +++ b/src/parser.cc diff --git a/regen_dump.cc b/src/regen_dump.cc index 9916a3f..9916a3f 100644 --- a/regen_dump.cc +++ b/src/regen_dump.cc diff --git a/string_piece.cc b/src/string_piece.cc index 32a7be0..32a7be0 100644 --- a/string_piece.cc +++ b/src/string_piece.cc diff --git a/string_piece.h b/src/string_piece.h index df3562f..df3562f 100644 --- a/string_piece.h +++ b/src/string_piece.h diff --git a/string_piece_test.cc b/src/string_piece_test.cc index 0434cbe..0434cbe 100644 --- a/string_piece_test.cc +++ b/src/string_piece_test.cc diff --git a/stringprintf.cc b/src/stringprintf.cc index b0d4b4a..b0d4b4a 100644 --- a/stringprintf.cc +++ b/src/stringprintf.cc diff --git a/stringprintf.h b/src/stringprintf.h index 8b67e6c..8b67e6c 100644 --- a/stringprintf.h +++ b/src/stringprintf.h diff --git a/strutil.cc b/src/strutil.cc index 797775f..797775f 100644 --- a/strutil.cc +++ b/src/strutil.cc diff --git a/strutil.h b/src/strutil.h index cc4d519..cc4d519 100644 --- a/strutil.h +++ b/src/strutil.h diff --git a/strutil_bench.cc b/src/strutil_bench.cc index d3b2e6c..d3b2e6c 100644 --- a/strutil_bench.cc +++ b/src/strutil_bench.cc diff --git a/strutil_test.cc b/src/strutil_test.cc index d0db1f3..d0db1f3 100644 --- a/strutil_test.cc +++ b/src/strutil_test.cc diff --git a/symtab.cc b/src/symtab.cc index 3d49f2e..3d49f2e 100644 --- a/symtab.cc +++ b/src/symtab.cc diff --git a/testutil.h b/src/testutil.h index be6125c..be6125c 100644 --- a/testutil.h +++ b/src/testutil.h diff --git a/thread_pool.cc b/src/thread_pool.cc index 4acf7b9..4acf7b9 100644 --- a/thread_pool.cc +++ b/src/thread_pool.cc diff --git a/thread_pool.h b/src/thread_pool.h index 0384ce8..0384ce8 100644 --- a/thread_pool.h +++ b/src/thread_pool.h diff --git a/timeutil.cc b/src/timeutil.cc index 0b43bf4..0b43bf4 100644 --- a/timeutil.cc +++ b/src/timeutil.cc diff --git a/timeutil.h b/src/timeutil.h index bff78b9..bff78b9 100644 --- a/timeutil.h +++ b/src/timeutil.h diff --git a/version.h b/src/version.h index 4235985..4235985 100644 --- a/version.h +++ b/src/version.h diff --git a/version_unknown.cc b/src/version_unknown.cc index 4ce90f5..4ce90f5 100644 --- a/version_unknown.cc +++ b/src/version_unknown.cc diff --git a/testcase/abspath.mk b/testcase/abspath.mk index 9522dd3..89d96f9 100644 --- a/testcase/abspath.mk +++ b/testcase/abspath.mk @@ -1,5 +1,5 @@ -foo = $(abspath ./foo bar/../foo bar//..//foo / /usr) -bar = $(abspath .. ./. ./ /aa/.. a///) +foo = $(subst /kati,,$(subst /make,,$(abspath ./foo bar/../foo bar//..//foo / /usr))) +bar = $(subst /kati,,$(subst /make,,$(abspath .. ./. ./ /aa/.. a///))) test: echo $(foo) diff --git a/testcase/comment_in_command.mk b/testcase/comment_in_command.mk index 881a241..a734bc2 100644 --- a/testcase/comment_in_command.mk +++ b/testcase/comment_in_command.mk @@ -1,4 +1,4 @@ -MAKEVER:=$(shell make --version | ruby -n0e 'puts $$_[/Make (\d)/,1]') +MAKEVER:=$(shell make --version | grep "Make [0-9]" | sed -E 's/.*Make ([0-9]).*/\1/') test1: # foo diff --git a/testcase/curdir_var.mk b/testcase/curdir_var.mk index 391f09f..6d35f77 100644 --- a/testcase/curdir_var.mk +++ b/testcase/curdir_var.mk @@ -1,2 +1,3 @@ test: - echo $(CURDIR) + # Make and kati will be executed in different subdirs + echo $(dir $(CURDIR)) diff --git a/testcase/err_export_override.mk b/testcase/err_export_override.mk index 6bb9f75..fc901f5 100644 --- a/testcase/err_export_override.mk +++ b/testcase/err_export_override.mk @@ -2,7 +2,7 @@ # GNU make 4 accepts this syntax. Note kati doesn't agree with make 4 # either. -MAKEVER:=$(shell make --version | ruby -n0e 'puts $$_[/Make (\d)/,1]') +MAKEVER:=$(shell make --version | grep "Make [0-9]" | sed -E 's/.*Make ([0-9]).*/\1/') ifeq ($(MAKE)$(MAKEVER),make4) $(error test skipped) endif diff --git a/testcase/err_override_export.mk b/testcase/err_override_export.mk index 2d72aab..b08f5e1 100644 --- a/testcase/err_override_export.mk +++ b/testcase/err_override_export.mk @@ -2,7 +2,7 @@ # GNU make 4 accepts this syntax. Note kati doesn't agree with make 4 # either. -MAKEVER:=$(shell make --version | ruby -n0e 'puts $$_[/Make (\d)/,1]') +MAKEVER:=$(shell make --version | grep "Make [0-9]" | sed -E 's/.*Make ([0-9]).*/\1/') ifeq ($(MAKE)$(MAKEVER),make4) $(error test skipped) endif diff --git a/testcase/err_suffixes.mk b/testcase/err_suffixes.mk index 2ac6d09..0e566be 100644 --- a/testcase/err_suffixes.mk +++ b/testcase/err_suffixes.mk @@ -1,4 +1,4 @@ -# TODO: Fix +# TODO(all/test2): Fix test1: touch a.src diff --git a/testcase/find_command.mk b/testcase/find_command.mk index b714879..941b7d0 100644 --- a/testcase/find_command.mk +++ b/testcase/find_command.mk @@ -1,4 +1,5 @@ -# TODO(go|ninja): This test is only for ckati. ninja: multiple problems +# TODO(go): This test is only for ckati. +# TODO(ninja/test2|test4|test5) ninja: multiple problems # go: symlink support isn't enough. # ninja: find . finds ninja temporary files # ninja: escaping ! doesn't seem to be working @@ -31,7 +32,7 @@ test1: ln -s ../../testdir/dir1 testdir/dir2/link2 ln -s broken testdir/dir2/link3 mkdir -p build/tools - cp ../../testcase/tools/findleaves.py build/tools + cp ../../../testcase/tools/findleaves.py build/tools mkdir -p testdir3/b/c/d ln -s b testdir3/a diff --git a/testcase/implicit_pattern_rule_chain2.mk b/testcase/implicit_pattern_rule_chain2.mk index 65e914b..a995a9f 100644 --- a/testcase/implicit_pattern_rule_chain2.mk +++ b/testcase/implicit_pattern_rule_chain2.mk @@ -1,4 +1,4 @@ -# TODO: Fix. We probably need to assume foo.y exists as there's a rule +# TODO(all/test2): Fix. We probably need to assume foo.y exists as there's a rule # to generate it. test1: diff --git a/testcase/implicit_pattern_rule_prefix.mk b/testcase/implicit_pattern_rule_prefix.mk index 6df648c..8972e2c 100644 --- a/testcase/implicit_pattern_rule_prefix.mk +++ b/testcase/implicit_pattern_rule_prefix.mk @@ -1,4 +1,4 @@ -MAKEVER:=$(shell make --version | ruby -n0e 'puts $$_[/Make (\d)/,1]') +MAKEVER:=$(shell make --version | grep "Make [0-9]" | sed -E 's/.*Make ([0-9]).*/\1/') test: abcd diff --git a/testcase/include_glob_order.mk b/testcase/include_glob_order.mk index 8b337f9..bceae5f 100644 --- a/testcase/include_glob_order.mk +++ b/testcase/include_glob_order.mk @@ -1,4 +1,4 @@ -MAKEVER:=$(shell make --version | ruby -n0e 'puts $$_[/Make (\d)/,1]') +MAKEVER:=$(shell make --version | grep "Make [0-9]" | sed -E 's/.*Make ([0-9]).*/\1/') # GNU make 4 doesn't sort glob results. ifeq ($(MAKEVER,4)) diff --git a/testcase/multi_implicit_output_patterns.mk b/testcase/multi_implicit_output_patterns.mk index 8b53b49..4ff3d62 100644 --- a/testcase/multi_implicit_output_patterns.mk +++ b/testcase/multi_implicit_output_patterns.mk @@ -1,6 +1,6 @@ # TODO(go): Fix -MAKEVER:=$(shell make --version | ruby -n0e 'puts $$_[/Make (\d)/,1]') +MAKEVER:=$(shell make --version | grep "Make [0-9]" | sed -E 's/.*Make ([0-9]).*/\1/') all: a.h.x a.c.x a.h.z a.c.z b.h.x b.c.x b.h.z b.c.z diff --git a/testcase/multiline_recipe.mk b/testcase/multiline_recipe.mk index 74b4d27..69e37fb 100644 --- a/testcase/multiline_recipe.mk +++ b/testcase/multiline_recipe.mk @@ -1,5 +1,5 @@ -# TODO(c): fix test6 - \t$${empty} should be empty. -MAKEVER:=$(shell make --version | ruby -n0e 'puts $$_[/Make (\d)/,1]') +# TODO(c/test6): fix test6 - \t$${empty} should be empty. +MAKEVER:=$(shell make --version | grep "Make [0-9]" | sed -E 's/.*Make ([0-9]).*/\1/') ifeq ($(MAKEVER),4) AT=@ endif diff --git a/testcase/ninja_normalized_path.mk b/testcase/ninja_normalized_path.mk index f46f603..183237f 100644 --- a/testcase/ninja_normalized_path.mk +++ b/testcase/ninja_normalized_path.mk @@ -1,4 +1,5 @@ -# TODO(ninja): This is tough to fix with ninja. Ninja normalizes +# TODO(ninja-genall) +# TODO(ninja/test2): This is tough to fix with ninja. Ninja normalizes # target names while make does not. test1: diff --git a/testcase/ninja_regen.sh b/testcase/ninja_regen.sh index b63bb9b..73ef34a 100755 --- a/testcase/ninja_regen.sh +++ b/testcase/ninja_regen.sh @@ -19,12 +19,6 @@ set -e log=/tmp/log mk="$@" -sleep_if_necessary() { - if [ x$(uname) != x"Linux" -o x"${TRAVIS}" != x"" ]; then - sleep "$@" - fi -} - export VAR=hoge cat <<EOF > Makefile @@ -37,7 +31,7 @@ if [ -e ninja.sh ]; then ./ninja.sh fi -sleep_if_necessary 1 +sleep 1 cat <<EOF > Makefile \$(KATI_deprecated_var VAR4) \$(KATI_obsolete_var VAR5) @@ -123,7 +117,7 @@ if [ -e ninja.sh ]; then ./ninja.sh fi -sleep_if_necessary 1 +sleep 1 touch PASS.mk ${mk} 2> ${log} if [ -e ninja.sh ]; then @@ -133,7 +127,7 @@ if [ -e ninja.sh ]; then ./ninja.sh fi -sleep_if_necessary 1 +sleep 1 touch XXX ${mk} 2> ${log} if [ -e ninja.sh ]; then diff --git a/testcase/ninja_regen_filefunc_read.sh b/testcase/ninja_regen_filefunc_read.sh index 01fb7e6..ce26614 100755 --- a/testcase/ninja_regen_filefunc_read.sh +++ b/testcase/ninja_regen_filefunc_read.sh @@ -19,12 +19,6 @@ set -e log=/tmp/log mk="$@" -sleep_if_necessary() { - if [ x$(uname) != x"Linux" -o x"${TRAVIS}" != x"" ]; then - sleep "$@" - fi -} - cat <<EOF > Makefile # Make 4.1 does not support file reading, which was added in 4.2 # We don't actually care though, since we're just testing kati's regen @@ -48,12 +42,13 @@ if [ -e ninja.sh ]; then ./ninja.sh fi +sleep 1 echo regen >file_a ${mk} 2> ${log} if [ -e ninja.sh ]; then if ! grep regenerating ${log} >/dev/null; then - echo 'Should be regenerated' + echo 'Should be regenerated (file add)' fi ./ninja.sh fi @@ -66,13 +61,13 @@ if [ -e ninja.sh ]; then ./ninja.sh fi -sleep_if_necessary 1 +sleep 1 echo regen >>file_a ${mk} 2> ${log} if [ -e ninja.sh ]; then if ! grep regenerating ${log} >/dev/null; then - echo 'Should be regenerated' + echo 'Should be regenerated (file change)' fi ./ninja.sh fi diff --git a/testcase/ninja_regen_find_link.sh b/testcase/ninja_regen_find_link.sh index 657f8ae..f9fc7e3 100755 --- a/testcase/ninja_regen_find_link.sh +++ b/testcase/ninja_regen_find_link.sh @@ -16,12 +16,6 @@ set -e -sleep_if_necessary() { - if [ x"${TRAVIS}" != x"" ]; then - sleep "$@" - fi -} - mk="$@" if echo "${mk}" | grep kati > /dev/null; then mk="${mk} --use_find_emulator" @@ -42,7 +36,7 @@ touch dir1/file1 dir2/file2 ln -s ../../dir1 linkdir/d/link build -sleep_if_necessary 1 +sleep 1 touch dir1/file1_2 build diff --git a/testcase/ninja_regen_glob.sh b/testcase/ninja_regen_glob.sh index 71dca29..ae73c9b 100755 --- a/testcase/ninja_regen_glob.sh +++ b/testcase/ninja_regen_glob.sh @@ -19,12 +19,6 @@ set -e log=/tmp/log mk="$@" -sleep_if_necessary() { - if [ x$(uname) != x"Linux" -o x"${TRAVIS}" != x"" ]; then - sleep "$@" - fi -} - touch xe.mk yc.mk xa.mk yb.mk xd.mk cat <<EOF > Makefile diff --git a/testcase/order_only2.mk b/testcase/order_only2.mk index 6baf49c..96dc795 100644 --- a/testcase/order_only2.mk +++ b/testcase/order_only2.mk @@ -1,4 +1,4 @@ -# TODO(ninja): Ninja does not believe the timestamp so this test is invalid. +# TODO(ninja/test2): Ninja does not believe the timestamp so this test is invalid. test1: touch -t 197101010000 old1 diff --git a/testcase/posix_var.mk b/testcase/posix_var.mk index 5574f09..8065d3a 100644 --- a/testcase/posix_var.mk +++ b/testcase/posix_var.mk @@ -1,6 +1,6 @@ # TODO(go): Fix -MAKEVER:=$(shell make --version | ruby -n0e 'puts $$_[/Make (\d)/,1]') +MAKEVER:=$(shell make --version | grep "Make [0-9]" | sed -E 's/.*Make ([0-9]).*/\1/') # GNU make 3.82 has this feature though. ifeq ($(MAKEVER),3) diff --git a/testcase/realpath.mk b/testcase/realpath.mk index 0d57e3b..456230d 100644 --- a/testcase/realpath.mk +++ b/testcase/realpath.mk @@ -1,13 +1,12 @@ -foo = $(realpath ./foo) -bar = $(realpath ./bar) -foofoo = $(realpath ./foo ./foo) -foobar = $(realpath ./foo ./bar) +$(shell touch ../foo) -test: foo +foo = $(realpath ../foo) +bar = $(realpath ../bar) +foofoo = $(realpath ../foo ../foo) +foobar = $(realpath ../foo ../bar) + +test: echo $(foo) echo $(bar) echo $(foofoo) echo $(foobar) - -foo: - touch foo diff --git a/testcase/shell.mk b/testcase/shell.mk index 5698d1a..d149ff7 100644 --- a/testcase/shell.mk +++ b/testcase/shell.mk @@ -1,5 +1,5 @@ test: - echo $(shell pwd) + echo $(shell dirname $$(pwd)) echo $(shell false) echo $(shell /bin/echo -e "\na \n b \n " ) echo $(shell /bin/echo -e "\na \n b \n " )X diff --git a/testcase/shell_var_with_args.mk b/testcase/shell_var_with_args.mk index 4256eb0..b163106 100644 --- a/testcase/shell_var_with_args.mk +++ b/testcase/shell_var_with_args.mk @@ -1,6 +1,6 @@ # TODO(go): Fix -MAKEVER:=$(shell make --version | ruby -n0e 'puts $$_[/Make (\d)/,1]') +MAKEVER:=$(shell make --version | grep "Make [0-9]" | sed -E 's/.*Make ([0-9]).*/\1/') ifeq ($(MAKEVER),4) diff --git a/testcase/strip_and_shell.mk b/testcase/strip_and_shell.mk index cb550f3..fccc37f 100644 --- a/testcase/strip_and_shell.mk +++ b/testcase/strip_and_shell.mk @@ -1,4 +1,4 @@ # TODO(c-ninja): $(shell) in another make expression is not supported. test: - echo $(strip $(shell pwd)) + echo $(strip $(shell dirname $$(pwd))) diff --git a/testcase/var_with_space.mk b/testcase/var_with_space.mk index 6f74816..1bfb782 100644 --- a/testcase/var_with_space.mk +++ b/testcase/var_with_space.mk @@ -1,4 +1,4 @@ -MAKEVER:=$(shell make --version | ruby -n0e 'puts $$_[/Make (\d)/,1]') +MAKEVER:=$(shell make --version | grep "Make [0-9]" | sed -E 's/.*Make ([0-9]).*/\1/') ifeq ($(MAKEVER),4) # A variable name with space is invalid on GNU make 4. diff --git a/testcase/vpath.mk b/testcase/vpath.mk index 3a86668..5e37264 100644 --- a/testcase/vpath.mk +++ b/testcase/vpath.mk @@ -1,4 +1,4 @@ -# TODO(c): bar is built even if foo doesn't exist. +# TODO(c/test2): bar is built even if foo doesn't exist. VPATH=dir diff --git a/testcase/wildcard.mk b/testcase/wildcard.mk index 33adfd6..5bfe18c 100644 --- a/testcase/wildcard.mk +++ b/testcase/wildcard.mk @@ -1,6 +1,6 @@ # TODO(go): Fix -MAKEVER:=$(shell make --version | ruby -n0e 'puts $$_[/Make (\d)/,1]') +MAKEVER:=$(shell make --version | grep "Make [0-9]" | sed -E 's/.*Make ([0-9]).*/\1/') files = $(wildcard M*) diff --git a/testcase/wildcard_cache.mk b/testcase/wildcard_cache.mk index 83ba3db..957e4c2 100644 --- a/testcase/wildcard_cache.mk +++ b/testcase/wildcard_cache.mk @@ -1,7 +1,7 @@ # TODO(c): Fix this. Maybe $(wildcard) always runs at eval-phase. # GNU make 4 agrees with ckati. -MAKEVER:=$(shell make --version | ruby -n0e 'puts $$_[/Make (\d)/,1]') +MAKEVER:=$(shell make --version | grep "Make [0-9]" | sed -E 's/.*Make ([0-9]).*/\1/') ifeq ($(MAKE)$(MAKEVER),make4) $(error test skipped) endif diff --git a/testcase/wildcard_target.mk b/testcase/wildcard_target.mk index 8cfbe1c..2b8f9af 100644 --- a/testcase/wildcard_target.mk +++ b/testcase/wildcard_target.mk @@ -1,4 +1,4 @@ -# TODO(c): Implement wildcard expansion in prerequisites. +# TODO(c/test2): Implement wildcard expansion in prerequisites. test1: touch foo.x |
