From d093ce3d844939abebcbfb9f18f1342341f18bbf Mon Sep 17 00:00:00 2001 From: Felix Schurk <75752337+felixschurk@users.noreply.github.com> Date: Sun, 28 Apr 2024 22:38:14 +0300 Subject: [PATCH] Fix test script paths (#3387) * fix path to task executable in pyton tests The current approach would copy the current files into the `build/test` directory. Updating the paths according to the custom user setup. By the copy I appended `.py` to have a clear visible distingtion which ones are the python tests. As soon as a source file in the normal directory is changed, it is copied over and the corresponding file is updated. From now on the python tests would need to get run in the according build directory. * reflect the current build instruction in PR template * update paths and globing in run_all * add line break for every cpp test * remove .gitignore in test folder As now all the auxillary files such as `all.log` as well as the executables are present in the `build` directory there is no longer a need to ignore them. * update paths in python test scripts and enable deactivated * remove .py extension when copy to build Further remove glob pattern for `*.t.py` tests. * remove accidentally added template.t from test files --- .github/pull_request_template.md | 2 +- test/.gitignore | 41 -------- test/CMakeLists.txt | 163 ++++++++++++++++++++++++++++++- test/basetest/CMakeLists.txt | 8 ++ test/basetest/utils.py | 6 +- test/bash_completion.t | 2 +- test/run_all | 4 +- test/simpletap/CMakeLists.txt | 1 + test/template.t | 0 test/tw-1379.t | 2 +- test/tw-1837.t | 0 test/tw-2575.t | 0 12 files changed, 179 insertions(+), 50 deletions(-) delete mode 100644 test/.gitignore create mode 100644 test/basetest/CMakeLists.txt create mode 100644 test/simpletap/CMakeLists.txt mode change 100644 => 100755 test/template.t mode change 100644 => 100755 test/tw-1837.t mode change 100644 => 100755 test/tw-2575.t diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 724bf7829..221297751 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -5,7 +5,7 @@ Replace this text with a description of the PR. #### Additional information... - [ ] I changed C++ code or build infrastructure. - Please run the test suite and include the output of `cd test && ./problems`. + Please run the test suite and include the output of `cd build/test && make && ./problems`. - [ ] I changed Rust code or build infrastructure. Please run `cargo test` and address any failures before submitting. diff --git a/test/.gitignore b/test/.gitignore deleted file mode 100644 index cdb132ea3..000000000 --- a/test/.gitignore +++ /dev/null @@ -1,41 +0,0 @@ -*.o -*.pyc -*.data -*.sqlite3 -*.log -*.runlog -col.t -dom.t -eval.t -lexer.t -t.t -taskmod.t -tdb2.t -uri.t -util.t -variant_add.t -variant_and.t -variant_cast.t -variant_divide.t -variant_equal.t -variant_exp.t -variant_gt.t -variant_gte.t -variant_inequal.t -variant_lt.t -variant_lte.t -variant_match.t -variant_math.t -variant_modulo.t -variant_multiply.t -variant_nomatch.t -variant_not.t -variant_or.t -variant_partial.t -variant_subtract.t -variant_xor.t -view.t -tc.t -tw-2689.t - -json_test diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 482014895..853abd814 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,7 +18,39 @@ include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/taskchampion/lib ${TASK_INCLUDE_DIRS}) -set (test_SRCS col.t dom.t eval.t lexer.t t.t tw-2689.t tdb2.t tc.t util.t variant_add.t variant_and.t variant_cast.t variant_divide.t variant_equal.t variant_exp.t variant_gt.t variant_gte.t variant_inequal.t variant_lt.t variant_lte.t variant_match.t variant_math.t variant_modulo.t variant_multiply.t variant_nomatch.t variant_not.t variant_or.t variant_partial.t variant_subtract.t variant_xor.t view.t) +set (test_SRCS + col.t + dom.t + eval.t + lexer.t + t.t + tw-2689.t + tdb2.t + tc.t + util.t + variant_add.t + variant_and.t + variant_cast.t + variant_divide.t + variant_equal.t + variant_exp.t + variant_gt.t + variant_gte.t + variant_inequal.t + variant_lt.t + variant_lte.t + variant_match.t + variant_math.t + variant_modulo.t + variant_multiply.t + variant_nomatch.t + variant_not.t + variant_or.t + variant_partial.t + variant_subtract.t + variant_xor.t + view.t + ) add_custom_target (test ./run_all --verbose DEPENDS ${test_SRCS} task_executable @@ -37,6 +69,135 @@ endforeach (src_FILE) configure_file(run_all run_all COPYONLY) configure_file(problems problems COPYONLY) +configure_file(bash_tap.sh bash_tap.sh COPYONLY) +configure_file(bash_tap_tw.sh bash_tap_tw.sh COPYONLY) + +add_subdirectory(basetest) +add_subdirectory(simpletap) +set (pythonTests + abbreviation.t + add.t + alias.t + annotate.t + append.t + args.t + bash_completion.t + blocked.t + bulk.t + burndown.t + calc.t + calendar.t + caseless.t + color.cmd.t + color.rules.t + columns.t + commands.t + completed.t + configuration.t + confirmation.t + context.t + count.t + custom.config.t + custom.recur_ind.t + custom.t + custom.tag_ind.t + date.iso.t + dateformat.t + datesort.t + datetime-negative.t + debug.t + default.t + delete.t + denotate.t + dependencies.t + diag.t + diag_color.t + dom2.t + due.t + duplicate.t + edit.t + encoding.t + enpassant.t + exec.t + export.t + feature.559.t + feature.default.project.t + feature.print.empty.columns.t + feature.recurrence.t + feedback.t + filter.t + fontunderline.t + format.t + gc.t + helpers.t + history.t + hooks.env.t + hooks.on-add.t + hooks.on-launch.t + hooks.on-modify.t + hyphenate.t + ids.t + import.t + info.t + limit.t + list.all.projects.t + log.t + logo.t + math.t + modify.t + nag.t + obfuscate.t + oldest.t + operators.t + overdue.t + partial.t + prepend.t + pri_sort.t + project.t + quotes.t + rc.override.t + recurrence.t + reports.t + search.t + sequence.t + shell.t + show.t + sorting.t + special.t + start.t + stats.t + substitute.t + sugar.t + summary.t + tag.t + taskrc.t + timesheet.t + tw-1379.t + tw-1837.t + tw-20.t + tw-2575.t + tw-262.t + tw-295.t + uda.t + uda_orphan.t + uda_report.t + uda_sort.t + undo.t + unicode.t + unique.t + upgrade.t + urgency.t + urgency_inherit.t + uuid.t + verbose.t + version.t + wait.t + hooks.on-exit.t + ) + +foreach (python_Test ${pythonTests}) + configure_file(${python_Test} ${python_Test} COPYONLY) +endforeach(python_Test) #SET(CMAKE_BUILD_TYPE gcov) #SET(CMAKE_CXX_FLAGS_GCOV "--coverage") diff --git a/test/basetest/CMakeLists.txt b/test/basetest/CMakeLists.txt new file mode 100644 index 000000000..f78450e77 --- /dev/null +++ b/test/basetest/CMakeLists.txt @@ -0,0 +1,8 @@ +configure_file(__init__.py __init__.py COPYONLY) +configure_file(compat.py compat.py COPYONLY) +configure_file(exceptions.py exceptions.py COPYONLY) +configure_file(hooks.py hooks.py COPYONLY) +configure_file(meta.py meta.py COPYONLY) +configure_file(task.py task.py COPYONLY) +configure_file(testing.py testing.py COPYONLY) +configure_file(utils.py utils.py) \ No newline at end of file diff --git a/test/basetest/utils.py b/test/basetest/utils.py index 0c8a941d0..c6a1970eb 100644 --- a/test/basetest/utils.py +++ b/test/basetest/utils.py @@ -29,17 +29,17 @@ CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) # Location of binary files (usually the src/ folder) BIN_PREFIX = os.path.abspath( - os.path.join(CURRENT_DIR, "..", "..", "src") + os.path.join("${CMAKE_BINARY_DIR}","src") ) # Default location of test certificates DEFAULT_CERT_PATH = os.path.abspath( - os.path.join(CURRENT_DIR, "..", "test_certs") + os.path.join("${CMAKE_SOURCE_DIR}", "test", "test_certs") ) # Default location of test hooks DEFAULT_HOOK_PATH = os.path.abspath( - os.path.join(CURRENT_DIR, "..", "test_hooks") + os.path.join("${CMAKE_SOURCE_DIR}", "test", "test_hooks") ) diff --git a/test/bash_completion.t b/test/bash_completion.t index c2e479bf2..7c6de41e1 100755 --- a/test/bash_completion.t +++ b/test/bash_completion.t @@ -36,7 +36,7 @@ sys.path.append(os.path.dirname(os.path.abspath(__file__))) from basetest import Task, TestCase from basetest.utils import BIN_PREFIX -TASKSH = os.path.abspath(os.path.join(BIN_PREFIX, "..", "scripts/bash/task.sh")) +TASKSH = os.path.abspath(os.path.join(BIN_PREFIX, "..", "..", "scripts/bash/task.sh")) @contextmanager diff --git a/test/run_all b/test/run_all index 8668d685f..e27e3c571 100755 --- a/test/run_all +++ b/test/run_all @@ -70,7 +70,7 @@ class TestRunner(object): self._outputq = Queue() def _find_tests(self): - for test in glob.glob("*.t") + glob.glob("*.t.exe"): + for test in glob.glob("*.t"): if os.access(test, os.X_OK): # Executables only if self._is_parallelizable(test): @@ -123,7 +123,7 @@ class TestRunner(object): with open(test, 'rb') as fh: header = fh.read(100).split(b"\n") if len(header) >= 2 and \ - ((b"/usr/bin/env python3" in header[0]) or \ + ((b"!#/usr/bin/env python3" in header[0]) or \ (header[1][-14:] == b"bash_tap_tw.sh")): return True else: diff --git a/test/simpletap/CMakeLists.txt b/test/simpletap/CMakeLists.txt new file mode 100644 index 000000000..040a465d6 --- /dev/null +++ b/test/simpletap/CMakeLists.txt @@ -0,0 +1 @@ +configure_file(__init__.py __init__.py COPYONLY) \ No newline at end of file diff --git a/test/template.t b/test/template.t old mode 100644 new mode 100755 diff --git a/test/tw-1379.t b/test/tw-1379.t index 98050fc57..07077ecbc 100755 --- a/test/tw-1379.t +++ b/test/tw-1379.t @@ -41,7 +41,7 @@ class TestBug1379(TestCase): self.t = Task() # Themes are a special case that cannot be set via "task config" with open(self.t.taskrc, 'a') as fh: - fh.write("include " + REPO_DIR + "/doc/rc/no-color.theme\n") + fh.write("include " + REPO_DIR + "/../doc/rc/no-color.theme\n") self.t.config("color.alternate", "") self.t.config("_forcecolor", "1") diff --git a/test/tw-1837.t b/test/tw-1837.t old mode 100644 new mode 100755 diff --git a/test/tw-2575.t b/test/tw-2575.t old mode 100644 new mode 100755