From 9994d99b1388c8ee442fb3d24e73b4d3d58d4ee5 Mon Sep 17 00:00:00 2001 From: Ashley Coleman Date: Mon, 7 Oct 2024 16:08:51 -0700 Subject: [PATCH 1/4] try adding wunit to root test --- build.wake | 1 + tests/wunit/pass.sh | 19 ++++++++ tests/wunit/stderr | 0 tests/wunit/stdout | 108 ++++++++++++++++++++++++++++++++++++++++++++ wake.spec.in | 1 + 5 files changed, 129 insertions(+) create mode 100755 tests/wunit/pass.sh create mode 100644 tests/wunit/stderr create mode 100644 tests/wunit/stdout diff --git a/build.wake b/build.wake index e9dfbe64c..3f0c59513 100644 --- a/build.wake +++ b/build.wake @@ -91,6 +91,7 @@ def bootstrapTarget targetFn variant = # Build all wake targets def targets = buildWake, + buildWakeUnit, buildWakeBox, buildFuseDaemon, buildShim, diff --git a/tests/wunit/pass.sh b/tests/wunit/pass.sh new file mode 100755 index 000000000..1471d4c19 --- /dev/null +++ b/tests/wunit/pass.sh @@ -0,0 +1,19 @@ +#! /bin/sh + +set -e + +function cleanup { + rm -rf job_cache_test + rm -rf .job_cache_test + rm -rf job_cache_test2 + rm -rf .job_cache_test2 +} +trap cleanup EXIT + +WAKE_UNIT="${1}/wake-unit" + +TERM=xterm-256color script --return --quiet -c "$WAKE_UNIT --no-color --tag threaded" /dev/null + +# We run the tests *twice* so that shared caching can run without a clean slate +TERM=xterm-256color script --return --quiet -c "$WAKE_UNIT --no-color --tag threaded" /dev/null > /dev/null + diff --git a/tests/wunit/stderr b/tests/wunit/stderr new file mode 100644 index 000000000..e69de29bb diff --git a/tests/wunit/stdout b/tests/wunit/stdout new file mode 100644 index 000000000..be1ccf226 --- /dev/null +++ b/tests/wunit/stdout @@ -0,0 +1,108 @@ +PASSED: + cli_options_basic + cli_options_shebang + cli_options_target + cli_options_timline + diff_add + diff_empty + diff_fuzz1 + diff_fuzz2 + diff_fuzz3 + diff_id + diff_permute + diff_sub + diff_unit_diff + diff_unit_same + doc_basic + doc_geometry + doc_large + doc_undo + doc_unicode + filepath_dir_range_basic + filepath_dir_range_empty + filepath_make_canonical + filepath_range_basic + filepath_range_empty_node + filepath_range_fuzz_garbage + filepath_range_fuzz_nice + filepath_range_no_node + filepath_range_one_node + filepath_range_only_slash + filepath_range_two_slash + filepath_relative_to + iterator_split_by_empty + iterator_split_by_no_delim + iterator_split_by_nominal + iterator_split_by_only_delim + job_cache_basic_fuzz + job_cache_basic_par_fuzz + option_assign1 + option_assign2 + option_copy + option_destructs + option_forward + option_inplace + option_move + option_no_construct + option_none_is_none + option_some + result_assign1 + result_assign2 + result_copy + result_destructs + result_err_is_err + result_forward_error + result_forward_value + result_inplace_error + result_inplace_value + result_move + result_no_construct + result_value + sanity_check1 + sanity_check2 + shell_escape_empty_string + shell_escape_nominal + shell_escape_spaces + shell_escape_special + term_basic_background_colors + term_basic_background_colors_dumb + term_basic_bold_background_colors + term_basic_bold_background_colors_dumb + term_basic_bold_foreground_colors + term_basic_bold_foreground_colors_dumb + term_basic_controls + term_basic_controls_dumb + term_basic_foreground_colors + term_basic_foreground_colors_dumb + term_basic_ignores + term_basic_intense_background_colors + term_basic_intense_foreground_colors + term_basic_resets + term_basic_resets_dumb + term_dumb_fuzz + term_dumb_gcc_smoke_test + term_dumb_git_smoke_test + term_dumb_unicode_smoke_test + term_gcc_smoke_test + term_git_smoke_test + term_rich_background_colors + term_rich_background_colors_dumb + term_rich_foreground_colors + term_rich_foreground_colors_dumb + term_unicode_smoke_test + trie_basic + trie_basic_const + trie_char + trie_empty_seq + trie_empty_seq_const + trie_fuzz + trie_long_seq + trie_max + trie_max_const + trie_string + trie_unique + trie_unit_seqs + trie_unit_seqs_const + + +SUCCESS diff --git a/wake.spec.in b/wake.spec.in index 9e91988e9..94cca2639 100644 --- a/wake.spec.in +++ b/wake.spec.in @@ -38,6 +38,7 @@ mkdir -p %{buildroot}/var/cache/wake /usr/bin/wake-rsc-tool /usr/bin/wake-format /usr/bin/job-cache +/usr/bin/wake-unit /usr/lib/wake /usr/share/wake %dir /var/cache/wake From bf425854c444571e1b0f31a055e3b2c7796287a2 Mon Sep 17 00:00:00 2001 From: Ashley Coleman Date: Tue, 8 Oct 2024 09:38:37 -0700 Subject: [PATCH 2/4] change shell --- tests/wunit/pass.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/wunit/pass.sh b/tests/wunit/pass.sh index 1471d4c19..f96f41117 100755 --- a/tests/wunit/pass.sh +++ b/tests/wunit/pass.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#! /bin/bash set -e From c84e48529fac7300cf508bb7fe1216ef2c10ca5d Mon Sep 17 00:00:00 2001 From: Ashley Coleman Date: Tue, 8 Oct 2024 10:25:29 -0700 Subject: [PATCH 3/4] cleanup --- .github/workflows/build.yaml | 2 +- Makefile | 4 -- tests/tests.wake | 98 -------------------------- tests/{wunit => wake-unit}/pass.sh | 0 tests/wake-unit/unit-test.sh | 13 ---- tests/wunit/stderr | 0 tests/wunit/stdout | 108 ----------------------------- 7 files changed, 1 insertion(+), 224 deletions(-) rename tests/{wunit => wake-unit}/pass.sh (100%) delete mode 100755 tests/wake-unit/unit-test.sh delete mode 100644 tests/wunit/stderr delete mode 100644 tests/wunit/stdout diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 054e8baff..a517962d7 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ jobs: run: make tarball - name: Run Tests - run: make test && make unittest + run: make test - name: Check Wake Formatting run: ./bin/wake-format.native-cpp14-release --auto --dry-run diff --git a/Makefile b/Makefile index 194155f62..c344ababb 100644 --- a/Makefile +++ b/Makefile @@ -76,10 +76,6 @@ format: test: wake.db $(WAKE_ENV) ./bin/wake --in test_wake runTests -# We need to bootstrap job-cache to run the tests -unittest: all - $(WAKE_ENV) ./bin/wake --in test_wake runUnitTests - remoteCacheTests: all $(WAKE_ENV) ./bin/wake -d -x 'testPostgres Unit' diff --git a/tests/tests.wake b/tests/tests.wake index fd522e0c3..b08958aa1 100644 --- a/tests/tests.wake +++ b/tests/tests.wake @@ -25,17 +25,6 @@ from wake import _ # If tests/ is used externally, the topic is empty and the invoking wake is tested instead. export topic wakeTestBinary: Unit => Result (Pair String (List Path)) Error -# We need to handle the fact that sometimes tests are invoked from within /tests -# and sometimes they're invoked from outside of /tests. Additionally only when -# we have access to build_wake in our test environment can we figure out how -# to build the wake unit tests that we want to run. Since test_wake cannot depend -# on build_wake we instead make a topic that build_wake can publish to. This topic -# will be empty if your workspace starts in /tests but have the proper function -# in it if you start from one directory out. This means we can just have this test -# fail if it isn't run from the proper place. It's hacky but it works around -# the way we test currently. -export topic wakeUnitTestBinary: (variant: Pair String String) => Result (List Path) Error - def wakeToTestDir Unit = match (subscribe wakeTestBinary) buildTestWake, Nil -> require Pass (Pair path visible) = buildTestWake Unit @@ -44,17 +33,6 @@ def wakeToTestDir Unit = match (subscribe wakeTestBinary) Nil -> Pass (Pair "{wakePath}" Nil) _ -> Fail (makeError "Two wake binaries declared for testing!") -def wakeUnitToTest Unit = - require buildWakeUnit, Nil = subscribe wakeUnitTestBinary - else failWithError "wake-unit binary not found" - - require Pass wakeUnitLst = buildWakeUnit (Pair "native-cpp14-release" "native-c11-release") - - require Some result = head wakeUnitLst - else failWithError "wake-unit binary not found" - - Pass result - def showDiff (expect: String) (actual: String): Result Unit Error = require Pass expectFile = writeTempFile "diff.expect" expect else failWithError "Unable to write expect file" @@ -135,82 +113,6 @@ export def runTests (cmdline: List String): Result String Error = Pass "All {len tests | str} tests completed successfully." -export def runUnitTests _: Result Unit Error = - def testDirectory = "{@here}/wake-unit" - - require Pass testScript = source "{testDirectory}/unit-test.sh" - - def testName = - testDirectory - | replace `^${quote @here}/` "" - - def readFile list = match list - Some file -> - require Pass content = read file - - Pass (Some content) - None -> Pass None - - require Pass expectedStdout = - source "{testDirectory}/stdout" - | getPass - | readFile - - require Pass expectedStderr = - source "{testDirectory}/stderr" - | getPass - | readFile - - require Pass visibleFiles = sources testDirectory `.*` - - def inTestDir path = relative testDirectory path - - require Pass wakeUnitBin = wakeUnitToTest Unit - - def testJob = - makeExecPlan - ("./{testScript.getPathName.inTestDir}", wakeUnitBin.getPathName.inTestDir, Nil) - (wakeUnitBin, visibleFiles) - | setPlanDirectory testDirectory - | setPlanLabel "testing: {testName}" - | setPlanStdout logNever - | setPlanStderr logNever - | setPlanShare False - | runJobWith localRunner - - def removeCarriageReturns = replace `\r` "" - - require Pass jobStdout = - testJob.getJobFailedStdout - | rmap removeCarriageReturns - - require Pass jobStderr = - testJob.getJobFailedStderr - | rmap removeCarriageReturns - - require Pass _ = match testJob.isJobOk - True -> Pass Unit - False -> - def _ = println jobStderr - - Fail (makeError "Test failed ({format testJob.getJobStatus}). See above for details") - - require Pass _ = match expectedStderr - Some x if x ==* jobStderr -> Pass Unit - None -> Pass Unit - Some _ -> - def _ = println jobStderr - - Fail (makeError "Unexpected standard error. See above for details") - - match expectedStdout - Some x if x ==* jobStdout -> Pass Unit - None -> Pass Unit - _ -> - def _ = println jobStdout - - Fail (makeError "Unexpected standard output. See above for details") - def runTest (testScript: Path): Result Unit Error = def shouldPass = testScript diff --git a/tests/wunit/pass.sh b/tests/wake-unit/pass.sh similarity index 100% rename from tests/wunit/pass.sh rename to tests/wake-unit/pass.sh diff --git a/tests/wake-unit/unit-test.sh b/tests/wake-unit/unit-test.sh deleted file mode 100755 index 7e83dd49e..000000000 --- a/tests/wake-unit/unit-test.sh +++ /dev/null @@ -1,13 +0,0 @@ -#! /bin/sh - -set -e - -TERM=xterm-256color script --return --quiet -c "$1 --no-color --tag threaded" /dev/null - -# We run the tests *twice* so that shared caching can run without a clean slate -TERM=xterm-256color script --return --quiet -c "$1 --no-color --tag threaded" /dev/null > /dev/null - -rm -rf job_cache_test -rm -rf .job_cache_test -rm -rf job_cache_test2 -rm -rf .job_cache_test2 \ No newline at end of file diff --git a/tests/wunit/stderr b/tests/wunit/stderr deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/wunit/stdout b/tests/wunit/stdout deleted file mode 100644 index be1ccf226..000000000 --- a/tests/wunit/stdout +++ /dev/null @@ -1,108 +0,0 @@ -PASSED: - cli_options_basic - cli_options_shebang - cli_options_target - cli_options_timline - diff_add - diff_empty - diff_fuzz1 - diff_fuzz2 - diff_fuzz3 - diff_id - diff_permute - diff_sub - diff_unit_diff - diff_unit_same - doc_basic - doc_geometry - doc_large - doc_undo - doc_unicode - filepath_dir_range_basic - filepath_dir_range_empty - filepath_make_canonical - filepath_range_basic - filepath_range_empty_node - filepath_range_fuzz_garbage - filepath_range_fuzz_nice - filepath_range_no_node - filepath_range_one_node - filepath_range_only_slash - filepath_range_two_slash - filepath_relative_to - iterator_split_by_empty - iterator_split_by_no_delim - iterator_split_by_nominal - iterator_split_by_only_delim - job_cache_basic_fuzz - job_cache_basic_par_fuzz - option_assign1 - option_assign2 - option_copy - option_destructs - option_forward - option_inplace - option_move - option_no_construct - option_none_is_none - option_some - result_assign1 - result_assign2 - result_copy - result_destructs - result_err_is_err - result_forward_error - result_forward_value - result_inplace_error - result_inplace_value - result_move - result_no_construct - result_value - sanity_check1 - sanity_check2 - shell_escape_empty_string - shell_escape_nominal - shell_escape_spaces - shell_escape_special - term_basic_background_colors - term_basic_background_colors_dumb - term_basic_bold_background_colors - term_basic_bold_background_colors_dumb - term_basic_bold_foreground_colors - term_basic_bold_foreground_colors_dumb - term_basic_controls - term_basic_controls_dumb - term_basic_foreground_colors - term_basic_foreground_colors_dumb - term_basic_ignores - term_basic_intense_background_colors - term_basic_intense_foreground_colors - term_basic_resets - term_basic_resets_dumb - term_dumb_fuzz - term_dumb_gcc_smoke_test - term_dumb_git_smoke_test - term_dumb_unicode_smoke_test - term_gcc_smoke_test - term_git_smoke_test - term_rich_background_colors - term_rich_background_colors_dumb - term_rich_foreground_colors - term_rich_foreground_colors_dumb - term_unicode_smoke_test - trie_basic - trie_basic_const - trie_char - trie_empty_seq - trie_empty_seq_const - trie_fuzz - trie_long_seq - trie_max - trie_max_const - trie_string - trie_unique - trie_unit_seqs - trie_unit_seqs_const - - -SUCCESS From c46b0970b8c49674fd59655eb95f7b29e140758d Mon Sep 17 00:00:00 2001 From: Ashley Coleman Date: Tue, 8 Oct 2024 10:29:32 -0700 Subject: [PATCH 4/4] ope --- build.wake | 4 ---- 1 file changed, 4 deletions(-) diff --git a/build.wake b/build.wake index 3f0c59513..4c2aff999 100644 --- a/build.wake +++ b/build.wake @@ -318,14 +318,10 @@ export def static _: Result Path Error = | getJobOutput from test_wake import topic wakeTestBinary -from test_wake import topic wakeUnitTestBinary publish wakeTestBinary = defaultWake, Nil -publish wakeUnitTestBinary = - buildWakeUnit, Nil - def defaultWake Unit = require Pass wakeVisible = doInstall "tmp" "default"