From ed8ba3fb63a38d115f8cbee669ee2cdfe53001e7 Mon Sep 17 00:00:00 2001 From: Stanislav Pankevich Date: Wed, 25 Mar 2020 22:03:03 +0100 Subject: [PATCH 1/6] pyproject.toml: add invoke 1.3.0 --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 79ed0c8..b0df73a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,6 +10,7 @@ python = "^3.4" [tool.poetry.dev-dependencies] lit = "^0.9" bump2version = "0.5.11" +invoke = "1.3.0" [tool.poetry.scripts] filecheck = "filecheck.FileCheck:main" From 300c7e573b6cc53b45fbec0af0140a82980eb12d Mon Sep 17 00:00:00 2001 From: Stanislav Pankevich Date: Wed, 25 Mar 2020 23:04:21 +0100 Subject: [PATCH 2/6] invoke: running LIT tests: LLVM and Py --- tasks.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tasks.py diff --git a/tasks.py b/tasks.py new file mode 100644 index 0000000..398d663 --- /dev/null +++ b/tasks.py @@ -0,0 +1,52 @@ +import os +import re + +from invoke import task + +FILECHECK_LLVM_8_EXEC = 'FileCheck-8.0.1' +FILECHECK_LLVM_9_EXEC = 'FileCheck-9.0.1' + + +def get_filecheck_py_path(): + cwd = os.getcwd() + return "{cwd}/filecheck/FileCheck.py".format(cwd=cwd) + + +def get_filecheck_llvm_path(filecheck_exec): + cwd = os.getcwd() + exec = "{cwd}/tests/integration/tools/FileCheck/{filecheck_exec}".format(cwd=cwd, filecheck_exec=filecheck_exec) + return exec + + +def formatted_command(string): + return re.sub('\\s+', ' ', string).strip() + + +def run_lit_tests(c, filecheck_exec, llvm_only): + assert c + assert filecheck_exec + assert llvm_only is not None + + llvm_only_value = "1" if llvm_only else "" + + cwd = os.getcwd() + + command = formatted_command(""" + CURRENT_DIR={cwd} + REAL_ONLY={llvm_only_value} \ + FILECHECK_EXEC={filecheck_exec} + PATH={cwd}/tests/integration/tools/FileCheck:{cwd}/tests/integration/tools:$PATH + lit + -vv + {cwd}/tests/integration + """).format(cwd=cwd, filecheck_exec=filecheck_exec, llvm_only_value=llvm_only_value) + + print(command) + c.run("{}".format(command)) + + +@task +def test(c): + run_lit_tests(c, get_filecheck_llvm_path(FILECHECK_LLVM_8_EXEC), True) + run_lit_tests(c, get_filecheck_llvm_path(FILECHECK_LLVM_9_EXEC), True) + run_lit_tests(c, get_filecheck_py_path(), False) From 8734c39e98b8e1b58fcff4c28f6abde6789cd8e7 Mon Sep 17 00:00:00 2001 From: Stanislav Pankevich Date: Wed, 25 Mar 2020 23:05:54 +0100 Subject: [PATCH 3/6] Git hook: switch to invoke --- git-precommit-hook.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/git-precommit-hook.sh b/git-precommit-hook.sh index 0f068c9..1e75f3c 100755 --- a/git-precommit-hook.sh +++ b/git-precommit-hook.sh @@ -1,3 +1,4 @@ #!/bin/bash -make test-lit +invoke test + From 93b6d3aad90baa8549b0b042fcee0bd69fc0cea8 Mon Sep 17 00:00:00 2001 From: Stanislav Pankevich Date: Thu, 26 Mar 2020 21:29:12 +0100 Subject: [PATCH 4/6] invoke: move 'clean' task from Makefile --- tasks.py | 27 +++++++++++++++++++++++++++ tests/integration/Makefile | 24 ------------------------ 2 files changed, 27 insertions(+), 24 deletions(-) delete mode 100644 tests/integration/Makefile diff --git a/tasks.py b/tasks.py index 398d663..d70b0b4 100644 --- a/tasks.py +++ b/tasks.py @@ -50,3 +50,30 @@ def test(c): run_lit_tests(c, get_filecheck_llvm_path(FILECHECK_LLVM_8_EXEC), True) run_lit_tests(c, get_filecheck_llvm_path(FILECHECK_LLVM_9_EXEC), True) run_lit_tests(c, get_filecheck_py_path(), False) + +@task +def clean(c): + find_command = formatted_command(""" + find + . + -type f \\( + -name '*.script' + \\) + -or -type d \\( + -name '*.dSYM' -or + -name 'Sandbox' -or + -name 'Output' + \\) + -not -path "**Expected**" + -not -path "**Input**" + """) + + find_result = c.run("{}".format(find_command)) + find_result_stdout = find_result.stdout.strip() + + echo_command = formatted_command( + """echo {find_result} | xargs rm -rfv""".format(find_result=find_result_stdout) + ) + + print(echo_command) + c.run("{}".format(echo_command)) diff --git a/tests/integration/Makefile b/tests/integration/Makefile deleted file mode 100644 index f3aab1a..0000000 --- a/tests/integration/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -# Self-Documented Makefile -# http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html -.PHONY: help -help: ## Show this help message. - @grep -E '^[a-zA-Z0-9_\.-\%]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' - -CLEAN_FIND_CMD=find \ - . \ - -type f \( \ - -name '*.script' \ - \) \ - -or -type d \( \ - -name '*.dSYM' -or \ - -name 'Sandbox' -or \ - -name 'Output' \ - \) \ - -not -path "**Expected**" \ - -not -path "**Input**" - -CLEAN_FILES=$(shell $(CLEAN_FIND_CMD)) -clean: ## Clean all temporary artefacts - echo $(CLEAN_FILES) | \ - xargs rm -rfv - From 2d49cfb4bd6a3e4d2097d9e880c8f2414012bfa4 Mon Sep 17 00:00:00 2001 From: Stanislav Pankevich Date: Thu, 26 Mar 2020 21:36:36 +0100 Subject: [PATCH 5/6] invoke: 'changelog' task --- tasks.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tasks.py b/tasks.py index d70b0b4..27bed0a 100644 --- a/tasks.py +++ b/tasks.py @@ -66,7 +66,7 @@ def clean(c): \\) -not -path "**Expected**" -not -path "**Input**" - """) + """) find_result = c.run("{}".format(find_command)) find_result_stdout = find_result.stdout.strip() @@ -75,5 +75,17 @@ def clean(c): """echo {find_result} | xargs rm -rfv""".format(find_result=find_result_stdout) ) - print(echo_command) c.run("{}".format(echo_command)) + + +# https://github.com/github-changelog-generator/github-changelog-generator +# gem install github_changelog_generator +@task +def changelog(c, github_token): + command = formatted_command(""" + CHANGELOG_GITHUB_TOKEN={github_token} + github_changelog_generator + --user stanislaw + --project FileCheck.py + """).format(github_token=github_token) + c.run("{}".format(command)) From 5be4e31bbfebfb62c539dc736808882a2577b3ba Mon Sep 17 00:00:00 2001 From: Stanislav Pankevich Date: Thu, 26 Mar 2020 21:37:10 +0100 Subject: [PATCH 6/6] Switch from Makefile to Invoke (closes #102) --- Makefile | 62 -------------------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 Makefile diff --git a/Makefile b/Makefile deleted file mode 100644 index a55f718..0000000 --- a/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -### HELP ####################################################################### - -.PHONY: help -help: - @ grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' - -.DEFAULT_GOAL := help - -.PHONY: test-lit - -ifdef REAL_ONLY -test-lit: test-lit-real ## Run tests against FileCheck C++ only (only when REAL_ONLY is provided). - @echo "Have run real FileCheck C++ tests." -else -test-lit: test-lit-real test-lit-py ## Run tests against both FileCheck C++ and FileCheck.py. - @echo "Have run both real FileCheck C++ and FileCheck.py tests." -endif - -FILECHECK_PY_EXEC=$(PWD)/filecheck/FileCheck.py -test-lit-py: ## Run tests against FileCheck.py. - @echo "--- Running integration tests against FileCheck.py ---" - cd tests/integration && make clean - - CURRENT_DIR=$(PWD) \ - FILECHECK_EXEC=$(FILECHECK_PY_EXEC) \ - PATH=$(PWD)/tests/integration/tools/FileCheck:$(PWD)/tests/integration/tools:$$PATH \ - lit \ - -vv $(PWD)/tests/integration - -test-lit-real: test-lit-real-8 test-lit-real-9 ## Run tests against FileCheck C++. - -FILECHECK_REAL_8_EXEC=$(PWD)/tests/integration/tools/FileCheck/FileCheck-8.0.1 -test-lit-real-8: ## Run tests against LLVM FileCheck 8. - @echo "--- Running integration tests against LLVM FileCheck 8.0.1 ---" - cd tests/integration && make clean - - CURRENT_DIR=$(PWD) \ - REAL_ONLY=1 \ - FILECHECK_EXEC=$(FILECHECK_REAL_8_EXEC) \ - PATH=$(PWD)/tests/integration/tools/FileCheck:$(PWD)/tests/integration/tools:$$PATH \ - lit \ - -vv $(PWD)/tests/integration - -FILECHECK_REAL_9_EXEC=$(PWD)/tests/integration/tools/FileCheck/FileCheck-9.0.1 -test-lit-real-9: ## Run tests against LLVM FileCheck 9. - @echo "--- Running integration tests against LLVM FileCheck 9.0.1 ---" - cd tests/integration && make clean - - CURRENT_DIR=$(PWD) \ - REAL_ONLY=1 \ - FILECHECK_EXEC=$(FILECHECK_REAL_9_EXEC) \ - PATH=$(PWD)/tests/integration/tools/FileCheck:$(PWD)/tests/integration/tools:$$PATH \ - lit \ - -vv $(PWD)/tests/integration - -# https://github.com/github-changelog-generator/github-changelog-generator -# gem install github_changelog_generator -changelog: ## Generate changelog - CHANGELOG_GITHUB_TOKEN=$(CHANGELOG_GITHUB_TOKEN) github_changelog_generator \ - --user stanislaw \ - --project FileCheck.py -