Commit Graph
655 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
José Valim e3560a8763 Bring unused warnings into tests 2015-09-25 19:42:56 +02:00
José Valim ff51926fe8 Move away from HashDict and HashSet 2015-09-25 12:46:22 +02:00
Suraj N. Kurapati feeea8c943 assert_raise: document that message can be regex
This patch documents the fact that assert_raise()
can also accept a Regex as the expected message.
2015-09-19 10:22:34 -07:00
Andrea Leopardi cd9253d102 Add a couple of tests for assert_raise/3 2015-09-13 13:34:47 +02:00
Andrea Leopardi db93099120 Use multiline failure message for asser_raise/3
Before this commit, `assert_raise/3` in ExUnit used an uncomfortable
failure message when the expected exception message and the real one
didn't match: they were both written on the same line, which caused
problems for long-ish messages.

Now, each exception message is printed on its own line, which should
make it clearer to spot differences and cleaner in general.
2015-09-13 13:33:07 +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 bc0142557c Correct "truth value" with "truthy value" 2015-09-11 19:51:11 +07:00
eksperimental a624573757 Replace all occurrences of em-dashes in favour of hyphens 2015-09-11 19:47:24 +07: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
José Valim 74048fa76f Set ex_unit stacktrace to 20 by default, closes #3705 2015-09-11 10:48:39 +02:00
José Valim 5d26dc9301 Improve assert docs, closes #3709 2015-09-11 10:29:47 +02:00
eksperimental 7b2fa9192a Use Title Case and backticks for Erlang and Elixir applications
It includes Erlang, Elixir, ExUnit, ExDoc, Logger, IEx, elixirc

It leaves Mix for a different PR.

Command to spot these words:

    ag -s '(?<!(\`))(?<!(\.))(?<!(/))(?<!(:))(?<!(_))(erlang|elixir|eex|iex|ex_unit|ex_doc|logger|elixirc)(?!(:))(?!(\?))(?!(_))(?!(-))(?!(\.))(?!(\`))(?!(/))(?!(>))' \
    --ignore "*.erl" --ignore "*.yrl" --ignore "*.src"
2015-09-09 01:51:22 +07:00
Josh Crews d60b395403 spelling miliseconds -> milliseconds 2015-09-07 15:27:19 -05: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
eksperimental c79d63f7c1 Correct spaces in iex>
It also removes the comment with doble ##,
So we can validate faulty indentation in iex>, ...>, ##  with command:

    # only 0, 2, 6, 10 spaces is valid for iex>, ...>, ##
    ag "^(\ {1}|\ {3,5}|\ {7,9}|\ {11,100})(iex>|\.\.\.>|##)" --ignore "*.sh" --ignore "*.md" --ignore "lib/ex_unit/test/ex_unit/doc_test_test.exs"
2015-09-07 23:28:30 +07:00
José Valim 0572d8e82e Merge pull request #3682 from eksperimental/doc_verb_tense
Correct descriptions in docs to use Present Continuous
2015-09-07 13:58:07 +02:00
eksperimental 8d5c009b13 Correct descriptions in @doc, @moduledoc, @shortdoc to use Present Continuous
It makes it consistent with the rest of the docs.

I have just looked for the first line in @doc, @moduledoc, so lines bellow it may still need
to be corrected.

@shortdoc all have been corrected.

Inspired by: https://github.com/elixir-lang/elixir/pull/2942

Command to list the first lines:

```sh
  # first line in @moduledoc / @doc
  ag '(@(module)?doc)\s+("{3})(\r|\n|.)\s*+[\w-]+(?<!s)\b'

  # also @shortdoc
  ag '(@shortdoc)\s+("{1,3})(\r|\n|.)\s*+[\w-]+(?<!s)\b'
```
2015-09-07 18:40:58 +07:00
eksperimental aeb3e82918 Correct indefinite article a/an
Run the following command, and reviewed the occurences one by one.

 # find words starting with vowels
 ag -i '\ban?\s+[aeiou]\w+\b'

 # find acronyms
 ag '\ban?\s+[BCDFGHJKLMNPQRSTVWXYZ][A-Z]+\b'

 # starting with "h"
 ag -i '\ban?\s+[aeiou]\w+\b'
2015-09-07 18:26:51 +07:00
José Valim a920812846 Raise nice error merge when setup returns bad data 2015-09-05 20:59:51 +02:00
José Valim 4bb4e916fd Convert remaining test :atom to strings 2015-09-05 20:35:26 +02:00
José Valim a5954552bc Provide detailed description on how to change timeout 2015-09-01 12:46:23 +02: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
José Valim 4bce6d063a Keep metadata when rewriting assertions 2015-08-24 00:19:00 +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 592a25a026 Merge pull request #3569 from MSch/default-capture_log
Introduce :capture_log ExUnit configuration.
2015-08-11 16:13:05 +02:00
Martin Schürrer 6aaf5f0d0a Introduce :capture_log ExUnit configuration. 2015-08-11 16:10:16 +02:00
José Valim 859d176037 Warn when numbers or binaries are not used within a block 2015-08-11 15:41:36 +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
Andrea Leopardi 3acd886d3d Mention expressions without results in doctests
I mentioned that you can write an expression without a result if you
don't want to assert on the value of that expression:

    iex> pid = spawn fn -> :ok end
    iex> is_pid pid
    true

I also killed some trailing whitespace in the same file.
2015-08-08 11:48:00 +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
eksperimental 51767139d4 update links to https. remove period adjacent to URLs. 2015-07-13 22:27:36 +07:00
José Valim 9be5393e24 Do not rely on ansi escapes, closes #3456 2015-07-04 11:21:26 +02:00
René Föhring 39fe4c2ecc Clarify example in ExUnit.Callbacks docs 2015-07-03 10:27:21 +02:00