Commit graph

116 commits

Author SHA1 Message Date
Daniel Shahaf 3ff5bec82e test harness: Let tests fail early by exiting non-zero or by setting a flag.
Fixes #609.
2020-03-19 00:37:21 +00:00
Daniel Shahaf c4bb260a30 test harness: Print the test name when $skip_test is set. 2020-03-19 00:16:09 +00:00
Daniel Shahaf 9bdeb4aa4a test harness: Remove a bogus check.
We already declare $expected_region_highlight in run_test_internal().
Therefore, it will always be declared.
2020-03-19 00:03:24 +00:00
Daniel Shahaf 63852df983 test harness: Fix $skip_test support, broken yesterday.
It was broken by commit e6eea1f9b7,
"test harness: Don't leak options from test files to the test harness.".
2020-03-19 00:00:51 +00:00
Daniel Shahaf bdb4e8b70e test harness: When the cardinality check fails, pretty-print \$expected_region_highlight and \$region_highlight. 2020-03-17 17:06:32 +00:00
Daniel Shahaf e6eea1f9b7 test harness: Don't leak options from test files to the test harness.
Fixes an issue whereby the '# TODO "issue #687"' directive in the output of
opt-shwordsplit1.zsh was truncated, because the test itself had set the
SH_WORD_SPLIT option and that affected the evaluation of
«${(z)expected_region_highlight[i]}» in the test harness.

Furthermore, this patch also independently fixes the error under
zsh-5.0.8 and earlier that was fixed by the previous commit.
2020-03-17 16:48:57 +00:00
Daniel Shahaf 99389327ae test harness: Fix test failures under zsh 5.0.8 and older.
The output of test-data/opt-shwordsplit1.zsh on zsh 5.7 is:
.
    1..2
    ## opt-shwordsplit1
    # BUFFER=vim
    not ok 1 - [1,7] «$EDITOR» - expected (1 7 "function"), observed (1 7 "unknown-token"). # TODO "issue
    ok 2 - cardinality check # SKIP cardinality check disabled whilst regular test points are expected to fail

On zsh 5.0.8, tap_escape() choked when called on the arguments argv=('[1,7]'
'«vim»').  This patch fixes that.

As you may have noticed, under zsh 5.7 the diagnostic message of test point 1
is truncated.  That'll be fixed in the next commit.
2020-03-17 16:22:56 +00:00
Daniel Shahaf 61c1cfe99f test harness: Change cardinality check semantics
The cardinality check shall —

- if the test sets \$expected_mismatch, be XFail;
- elif any test points is XFail, be skipped;
- else, be expected to pass.

To test this, change «6 * 9» to «6 + 9» in test-data/arith1.zsh that
will be added in the after-next (grandchild) commit.
2020-03-17 15:05:22 +00:00
Daniel Shahaf ea2f1060f6 test harness: No-op change to minimize the next diff. 2020-03-17 15:05:22 +00:00
Daniel Shahaf f63f07417d Merge remote-tracking branch 'danielsh/tests-skip-cardinality-v1'
* danielsh/tests-skip-cardinality-v1:
  tests: Minor documentation readability tweak
  Add a test for issue #641.5, using the infrastructure added in the previous commits.
  tests: Skip cardinality tests whenever any test point is expected to fail.
  tests: Make $expected_mismatch skip the cardinality check, rather than consider it an expected failure.
  tests: Include the name of the 'cardinality check' test point in the output
2020-03-15 18:38:26 +00:00
Daniel Shahaf 37b6f5052f test harness: Update tests/edit-failed-tests for harness output changes in commit 2b3638a211, "test harness: Tweak quiet-test output". 2020-03-15 13:33:09 +00:00
Daniel Shahaf 8e3578240c tests harness docs: Add paragraph breaks. 2020-02-28 22:36:57 +00:00
Daniel Shahaf 027f522300 test harness: Honour $expected_mismatch when there are more expected than observed highlights.
Required for the next commit.
2020-02-28 22:31:43 +00:00
Daniel Shahaf 2b3638a211 test harness: Tweak quiet-test output
- Print the test name and data after the plan line

- Split on the plan line rather than on comments

  + That makes tap-filter more suitable to filter TAP output generated by other
    TAP producers.

  + However, the filtered output deletes the plan line and adds a blank line in
    its stead.  This suits our use-case of interactive test runs.
2020-02-22 15:12:24 +00:00
Daniel Shahaf 3414c7c0d2 test harness: Include $PREBUFFER and $BUFFER in the output.
For human readers' benefit.
2020-02-22 15:12:24 +00:00
Daniel Shahaf 4a043b4d15 noop: Whitespace changes only.
./.editorconfig is already set correctly.
2020-02-22 15:12:24 +00:00
Daniel Shahaf dc70e89bfd tests: Support non-arrays in typeset_p(). 2020-02-22 15:12:24 +00:00
Daniel Shahaf deee22ed42 tests: Don't filter out tests that aborted.
Useful in piping Travis CI output through tap-filter manually.
2020-01-24 00:49:51 +00:00
Daniel Shahaf 9ed2a46ed2 dev tools: New script to ease opening $EDITOR on failing tests.
Has room for improvement; for now, I use it with CTRL-W_f.
2020-01-16 17:19:25 +00:00
Daniel Shahaf 1c6a6d92b0 dev tools: Allow specifying preamble code when generating test cases. 2020-01-16 17:19:25 +00:00
Daniel Shahaf c0ad50e645 dev tools: Fix regression introduced in commit "Print the test data to stdout for convenience.".
tee(1) truncated $fname.  Fortunately, the data that got truncated had just
been `git add`-ed, so no harm was done.
2020-01-11 20:49:12 +00:00
Daniel Shahaf 6f1f595e3e dev tools: Print the test data to stdout for convenience. 2020-01-07 19:59:49 +00:00
Daniel Shahaf b7592e581d tests: Minor documentation readability tweak 2019-11-10 11:49:47 +00:00
Daniel Shahaf 4952325051 tests: Skip cardinality tests whenever any test point is expected to fail.
When writing an expected-to-fail test case, the cardinality of $region_highlight
at the time the test is written may differ from the cardinality it will have
once the bug is fixed.  For example, with issue #641.5, the current highlighting
is ['nice', 'x=y', 'y', 'ls'] — four elements — but the correct highlighting
would have three elements: ['nice', 'x=y', 'ls'].  There is no point in reporting
a separate test failure for the cardinality check in this case, nor for 'ls' being
highlighted as 'command' rather than 'default'.

At the same time, in other cases the current and correct highlighting may have the
same number of elements (for example, this would be the case for a hypothetical
"the command word is highlighted as an alias rather than a function" bug).  Thus,
the previous commit, q.v..
2019-11-10 11:49:13 +00:00
Daniel Shahaf d5a4a6e195 tests: Make $expected_mismatch skip the cardinality check, rather
than consider it an expected failure.

With this change, if $expected_region_highlight and $region_highlight
coincidentally have the same number of elements, the test won't be considered
to fail.

This is useful in conjunction with the next commit, q.v..

At this time, no tests set $expected_mismatch explicitly.  However, the
commit after next (this commit's grandchild) will add a test that will
set $expected_mismatch implicitly, using the functionality in the next
commit (this commit's child).
2019-11-10 11:48:40 +00:00
Daniel Shahaf e209cbe61a tests: Include the name of the 'cardinality check' test point in the output 2019-11-10 11:20:21 +00:00
Sean Wei 4fb570e104
docs: Enable Syntax Highlighting for Code Snippits 2019-01-13 16:12:41 +08:00
Matthew Martin 693757bfd7 tests: Run harness in an anon function to catch global variables
Thanks Daniel for the set -- suggestion.
2019-01-12 00:36:42 -06:00
Matthew Martin 3259fe338d Revert "tests: Run tests in an anon function to catch global variables"
This reverts commit ba2d8fcf76.

Breaks 4.3.12 and .11
2019-01-06 21:38:13 -06:00
Matthew Martin ba2d8fcf76 tests: Run tests in an anon function to catch global variables
This would have caught #593.
2019-01-06 21:23:46 -06:00
Matthew Martin 9bd38c6fc0 tests: Use root variable for root of the project 2019-01-06 21:21:42 -06:00
Matthew Martin dddea5d5dd tests: Set harness variables local 2019-01-06 21:18:41 -06:00
Daniel Shahaf 06893a3873 tests: Escape region_highlight and expected_region_highlight in TAP output.
Required for TAP compliance in case the output ever contains '#' or '\n'.
2018-12-29 12:15:34 +00:00
Daniel Shahaf 580ccaebb8 tests: (try to) Fix test failure under zsh<5.3, where 'typeset -p arrayvar''s is two lines long. 2018-12-29 11:57:15 +00:00
Daniel Shahaf 7cb5ad0f9b tests: Tweak XFAIL/XPASS output of cardinality check.
Stylistic tweaks only; no functional change, no effect on TAP compliance.
2018-12-29 11:46:18 +00:00
Daniel Shahaf cd1647f4d4 tests: Follow-up to grandparent: Make the cardinality check XPASS properly when it should. 2018-12-29 11:42:34 +00:00
Daniel Shahaf 864864442e tests: Allow marking the cardinality check as TODO (XFail).
Needed for next commit.
2018-12-29 11:31:18 +00:00
Matthew Martin a9be0975c8 tests: Directly diff expected_region_highlight against region_highlight 2018-02-10 14:49:07 -06:00
Matthew Martin 7b417be1ce tests: Escape newlines in TAP description 2018-02-10 13:23:08 -06:00
Daniel Shahaf c969a1f26a tests: Include the filename in error messages.
The new failure mode is:
.
    Running test main
    Bail out! On './highlighters/main/test-data/glob.zsh': Either 'PREBUFFER' or 'BUFFER' must be declared and non-blank
    Bail out! On './highlighters/main/test-data/glob.zsh': output on stderr
    Running test pattern

Fixes #478.
2018-01-12 14:28:08 +00:00
Daniel Shahaf 8652a8f4e4 Bump copyright years. 2017-12-25 08:42:30 +00:00
Matthew Martin f4d37b74cc tests: Add ability to skip tests 2017-11-06 07:08:53 -06:00
Matthew Martin 4bd30737dc tests: Support SKIP directive in tap-colorizer 2017-11-06 07:08:21 -06:00
Matthew Martin 038409c10d tests: Run tests with WARN_CREATE_GLOBAL 2017-11-05 15:04:49 -06:00
Matthew Martin c948a3caa0 tests: Declare local variables 2017-11-05 12:23:42 -06:00
Matthew Martin 18517cc98e tests: Run tests with NOUNSET 2017-11-05 08:06:45 -06:00
Matthew Martin 459c128f43 tests: Set ZLE variables to sane defaults 2017-11-05 08:06:45 -06:00
Matthew Martin 079ea39f74 tests: Ensure region highlight is unset if NONE is expected 2017-11-05 08:06:45 -06:00
Matthew Martin a9ce931439 Default possibly unset variables to empty 2017-11-04 20:26:07 -05:00
Matthew Martin a33c72e838 tests: Use idiomatic set check 2017-11-02 20:08:28 -05:00