Commit Graph
215 Commits
Author SHA1 Message Date
Eric Entin b206ce368f Fix assertion errors with more than 1 pinned var 2015-09-26 10:50:55 -04:00
Andrea Leopardi cd9253d102 Add a couple of tests for assert_raise/3 2015-09-13 13:34:47 +02:00
José Valim 3fff57d51f Merge pull request #3713 from lexmag/print-pinned-assertion
Display pinned vars in the receive assertions
2015-09-11 23:10:51 +02:00
eksperimental ed5671b4f8 Standardize use of backticks and quotes; including Error messages and Title Case commands
This is a large commit that does the following:
* Removes backticks from messages and comments.
  All references to backticks have been replaced with double quotes everywhere the
  code is not interpreted as Markdown, (ie. anywhere outside documentation and
  markdown files, such as in code comments, or error messages).

* Variables in Exception messages are printed using `inspect`
  The way no-matching error message are printed, have changed because now we use inspect for printing
  variables. The following file and their respective test have been changed:
  - lib/elixir/lib/exception.ex
  - lib/elixir/lib/inspect/algebra.ex
  - lib/elixir/test/elixir/inspect_test.exs
  - lib/ex_unit/test/ex_unit/formatter_test.exs
  - lib/elixir/test/elixir/exception_test.exs

* Properly use Title Case for Mix, Git, Dializer

* Use backticks when citing a command

****************************************************
CONVENTION FOR RENAMING USING BACKTICKS AND QUOTES

https://github.com/elixir-lang/elixir/pull/3697#issuecomment-138811747

1. Backticks should never be printed in error messages, neither be included anywhere where Markdown code is not interpreted as such.

2. Do not use single quotes anywhere. We should favor double quotes everywhere, to avoid confusion

3. If you want to format something in error messages, use inspect. For example, if you want to show the dependency name and that is an atom, instead of the dependency "foo", let's show the dependency :foo. Less noise and may click better

4. Similarly, if you want to show something with double quotes, call inspect, as it handles escaping as well as the quotes

5. Things like "--all" just add verbosity, we can definitely read --all without ambiguity.

6. When using switches with a single hyphen (such as "-o"), we can make it explicit in the text: e.g. "... give the switch -o when choosing ..."

****************************************************
SHELL COMMANDS TO DETECT CODE BREAKING THE RULES

* Detect values surrounded by single-quotes where we want double-quotes.

    # regular variables
    ag "'#{"
    # constants or ENV variables
    ag "'[A-Z][A-Z0-9_-]+"
    # switches
    ag -i "(?<!(\[))'--?[a-z0-9][a-z0-9_-]+'"
    # atoms
    ag -i "(?<!(\[))':[a-z0-9][a-z0-9_-]+'"

    # DETECT BACKTICKS OUTSIDE DOCS
    ag "^\s+(?<!(#))#[^#\r\n]*\`" --ignore "*.md"
    ag '^\s+["%].*`' --ignore "*.md"
    ag -s '(raise|Error)\b(?!(`|/)).*\`'

* Spot mentions to running a command that is not using backticks:

    commands="elixir|elixirc|mix|iex|ex_doc|git|make|rebar|dialyzer|erl|rm|cd|mkdir|rmdir|ln|ls|pwd"
    actions="runs?|running|executes?|executing|types?|typing|enters?|entering|calls?|calling"
    ag '(?i)('${actions}')(?-i)\b[^`\r\n/]+[\ \t]+(?!(`))('${commands}')'
    ag '(?-i)\b(?!(`))('${commands}')[\ \t]+[^`\r\n/]+(?i)(commands?)'

* Spot where a command is mentioned:

    #commands="erlang|elixir|eex|iex|ex_unit|ex_doc|logger|elixirc|git|make|rebar|dialyzer|erl|rm|cd|mkdir|rmdir|ln|ls|pwd"
    commands="mix|elixirc|git|make|rebar|dialyzer|erl|rm|cd|mkdir|rmdir|ln|ls|pwd"
    ag -s '(?<!(\`))(?<!(\.))(?<!(/))(?<!(:))(?<!(_))\b('${commands}')\b(?!(:))(?!(\?))(?!(_))(?!(-))(?!(\.))(?!(\`))(?!(/))(?!(>))' \
    --ignore "*.erl" --ignore "*.yrl" --ignore "*.src"
2015-09-11 18:49:51 +07:00
Aleksei Magusev 4062277d87 Indent pinned vars and received messages in the receive assertions 2015-09-11 13:12:35 +02:00
Aleksei Magusev 261f08c8eb Improve assertion readability in test 2015-09-11 13:12:35 +02:00
Aleksei Magusev 890bb46139 Display pinned vars in the receive assertions 2015-09-11 13:12:31 +02:00
eksperimental a251ccc722 Format raise message consistently
Kernel.raise messages should not start with uppercase, and should not
have trailing punctuation.

Mix.raise messages should start with uppercase, and should not have a trailing
puntuation.

    # starting with uppercase
    # exclude (Mix.raise, and any message that starts with all uppecase such as: I or IO
    ag '(?<!Mix\.)raise\s+\"+(?!([A-Z]+\b))[A-Z]'

    # Mix.raise should start with upper case
    # except when `mix` or `rebar` are mentioned
    ag 'Mix\.raise\s+\"(?!(mix|rebar))+[a-z]'

    # ending in period
    ag "raise\s+\"+.+\.\"\s*\n"
2015-09-08 00:44:17 +07:00
José Valim 045277d5e0 Raise nice error message if ExUnit.Case was not used
Closes #3633
2015-09-01 10:11:17 +02:00
eksperimental a57482b42d ExUnit: Fix warning in test
removes the following warnings:
- test/ex_unit/assertions_test.exs:218: warning: variable x is unused
- test/ex_unit/assertions_test.exs:229: warning: variable x is unused
2015-08-29 17:29:53 +07:00
José Valim 1a7412502f Also store lines in typedoc and ensure @*doc return strings 2015-08-24 13:28:48 +02:00
José Valim dc78ac4423 Merge pull request #3600 from jisaacstone/lineno
Line numbers for doctest errors. Fixes issue #3592
2015-08-24 13:11:02 +02:00
Aleksei Magusev b8d94a1622 Improve error messages for match? assertions 2015-08-22 19:06:47 +02:00
jisaacstone 2320097aa7 Line numbers for doctest errors. Fixes issue #3592
Note that this will change all line numbers retured by `Code.get_docs`.
2015-08-19 11:04:50 -07:00
José Valim 935b3af78d Match errors should have higher priority on assert = 2015-08-18 10:30:59 +02:00
José Valim 285c80a971 Do not change the code semantics in assert/receive 2015-08-18 09:38:07 +02:00
Aleksei Magusev b20fe7db12 Fix race condition in CaptureLogTest 2015-08-13 23:27:42 +02:00
José Valim 65f81054aa Allow tests to be skipped with @tag :skip 2015-08-10 14:58:46 +02:00
Abel Muiño fe4c851424 doctests raising exceptions and assert_raise show original stacktrace
Currently doctests report the type and message of the raised exception,
but a synthetic stacktrace.
`assert_raise` does not provide any information about why
the wrong exception was raised, since the stacktrace points to test
line.

This change makes it display the original stacktrace too, which is more
useful for debugging and keeps symmetry with the information that
standard ExTests provide.
2015-08-10 13:41:22 +02:00
Aleksei Magusev a9611f19d8 Avoid race condition in capture_io "device re-registering" test 2015-07-31 02:09:48 +02:00
Aleksei Magusev d5f1421251 Improve capture_io/3 on exit test 2015-07-20 14:01:46 +02:00
Aleksei Magusev 3c4dd82bb1 Use spawn_monitor/1 to avoid race condition 2015-07-20 13:57:12 +02:00
José Valim 03bc18dafc Avoid race condition in tests 2015-07-20 10:56:46 +02:00
Aleksei Magusev aee812c3dc Fix re-registering of device after exit signal in ExUnit.CaptureIO 2015-07-19 23:06:50 +02:00
José Valim 8e3c1496b3 Merge pull request #3449 from lexmag/more-capture_log-test
Add test for log capture removal on exit
2015-07-17 11:26:05 +02:00
José Valim 9be5393e24 Do not rely on ansi escapes, closes #3456 2015-07-04 11:21:26 +02:00
Aleksei Magusev 35403364bb Add test for log capture removal on exit 2015-06-30 22:36:57 +02:00
José Valim f2815673f3 Move add/remove logger backend to client 2015-06-30 13:31:57 +02:00
Aleksei Magusev 4ab0b0d8ed Add muting for the :console backend for the duration of capture 2015-06-25 22:16:02 +02:00
Aleksei Magusev 6395775a60 Get rid of ProxyIO and merge :console and :capture backends 2015-06-25 14:46:49 +02:00
Aleksei Magusev 14b5767167 Add support for :capture_log ExUnit test tagging 2015-06-24 23:48:03 +02:00
Aleksei Magusev 589c1e55aa Rename Logger.CaptureLog to ExUnit.CaptureLog 2015-06-24 23:48:03 +02:00
Aleksei Magusev b88c747fab Rename ProxyIO to ExUnit.ProxyIO 2015-06-24 23:48:03 +02:00
José Valim 702cfbf870 Not implemented test sets tag 2015-06-23 15:08:08 +02:00
Hubert Łępicki cfb356788c raise 'Not yet implemented error' on such tests 2015-06-23 13:08:00 +02:00
Aleksei Magusev 177e363ae6 Fix StringIO processes leakage in the ExUnit.CaptureIO 2015-06-06 19:14:22 +02:00
José Valim 29bad60ff9 Fix runner test 2015-05-15 11:16:05 +02:00
José Valim 0b7148e0f9 Properly set remaining timeouts 2015-05-08 15:52:05 +02:00
José Valim d13cce1320 Improve error message and increase test timeout to 60 seconds 2015-05-08 15:48:35 +02:00
José Valim 766348d85d Tag async tests as such
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2015-04-07 11:36:24 +02:00
José Valim f76e7a9f2d Check the number of schedulers online in exunit suite, closes #3199 2015-03-23 17:43:22 -07:00
eksperimental 61675c3ea8 Add space after comma: Format consistently 2015-03-17 22:55:27 +07:00
Martin Svalin 684e174699 Filter :moduledoc 2015-03-17 09:28:21 +01:00
Martin Svalin 469017b6c1 Fix doctest :only, so it accepts multiple functions
There is a bug in `doctest` with the `:only` option, such that it only works if
the list is of size 1. If you pass two functions to the option, `filter_by_opts`
will always be empty, since the function is checked with `Enum.all?`.

`Enum.any?` returns false for an empty list. Thus the extra `Enum.empty?` check.
2015-03-15 11:51:00 +01:00
Or Neeman 5e29ec3356 Correct usage of ExUnit.Assertions.flunk and add guard for it
Closes #3083:
- Fix incorrect call to `flunk` in test_helper.exs
- Add a guard to `flunk` to check the argument is the right type
2015-02-14 12:46:05 -06:00
Lauro Caetano ce967cacb9 Refactor the runner configuration to make it testable 2015-02-09 12:34:30 -02:00
eksperimental 950cef13e5 singular plural issue fixed for tests 2015-02-07 21:34:25 +07:00
Lauro Caetano 8b013c9e7b Add the timeout option for tests
This option enables the global timeout configuration for running the
tests.

Example:

```
  ExUnit.start(timeout: 60_000)
```
2015-02-06 17:02:12 -02:00
José Valim c06206d553 Ensure ExUnit survives inspect and exception message failures 2015-01-07 09:49:15 +01:00
Xavier Defrang 6b4db71f85 Failing test demonstrating ExUnit crash on inspect failure
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2015-01-07 09:49:14 +01:00