-
Notifications
You must be signed in to change notification settings - Fork 3k
[eunit] Slave module deprecation: Replace slave with peer in code and comments #10128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[eunit] Slave module deprecation: Replace slave with peer in code and comments #10128
Conversation
CT Test Results 2 files 12 suites 4m 7s ⏱️ Results for commit adc67fd. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts
// Erlang/OTP Github Action Bot |
3055ad2
to
14eaba3
Compare
Parse commandline function for eunit Test added and passing
c7f029d
to
f3e2aba
Compare
lib/eunit/doc/guides/chapter.md
Outdated
@@ -1009,11 +1009,13 @@ The following representations specify fixture handling for test sets: | |||
|
|||
- **`{node, Node::atom(), Tests | Instantiator}`** | |||
|
|||
- **`{node, Node::atom(), Args::string(), Tests | Instantiator}`** - `node` is | |||
like `setup`, but with a built-in behaviour: it starts a slave node for the | |||
- **`{node, Node::atom(), Args::string()|[string()], Tests | Instantiator}`** - `node` is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
follow convention and wrap string()|[string()]
with space characters as on the right in same line, so it isstring() | [string]
lib/eunit/doc/guides/chapter.md
Outdated
- **`{node, Node::atom(), Args::string(), Tests | Instantiator}`** - `node` is | ||
like `setup`, but with a built-in behaviour: it starts a slave node for the | ||
- **`{node, Node::atom(), Args::string()|[string()], Tests | Instantiator}`** - `node` is | ||
like `setup`, but with a built-in behaviour: it starts a follower node for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naming is difficult :-)
I dislike follower
term. arguments:
- when used as "EUnit follower" providing additional context might be required for users to understand it
- it suggest being passive and not doing job, one may think it is a monitor of some sort
- is not aligned with common test
- the less different terms to describe the same the better it is
- the more self explanatory the term the better it is
I know common_test is not yet "slave free" but can we think about a term that would be shared between test frameworks?
I'm currently thinking about:
- test node
- peer test node
but maybe we can figure out something better.
@IngelaAndin can you have a look on this naming comment only? what is your opinion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the use of follower is confusing term here. I think it feel like there is some new concept that is not being explained.
From doc.
A "fixture" is some state that is necessary for a particular set of tests to run. EUnit's support for fixtures makes it easy to set up such state locally for a test set, and automatically tear it down again when the test set is finished, regardless of the outcome (success, failures, timeouts, etc.).
And then
node is like setup, but with a built-in behaviour: it starts a slave node for the duration of the tests. The atom Node should have the format [email protected], and Args are the optional arguments to the new node; see [slave:start_link/3](https://www.erlang.org/docs/28/apps/stdlib/slave#start_link/3) for details.
In the context I think replacing slave with peer can suffice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixture is commonly used as "small things set up (in the database or filesystem), necessary for running a test"
Calling a node 'fixture' would be confusing
Maybe use any word + node. Test node, peer node, follower node/leader node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed and this and we should go with peer (as that is what the replacement module is called, unless it is semantically incorrect).
lib/eunit/doc/guides/chapter.md
Outdated
node; see `slave:start_link/3` for details. | ||
node; see `peer:start_link/1` for details. For compatibility | ||
reasons `Args` can be either a string or a list of strings, and if a single | ||
string is passed, it will be parsed into a list with `argparse` module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why mentioning argparse here at all?
is this needed?
where argparse is used in eunit code?
i can't find it, is it a left over and you went for implementing it yourself? why? am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There isn't argparse, needs to be removed. I implemented the logic myself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slave starts node passing args as a string, peer starts node passing args as a list of strings. There needs to be support of string conversion to be passed as a list of args. Initially i wanted to use argparse and it was reflected in the docs, but now it is not used, so the mention was removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I understand that.
but why argparse is not enough in this case, I guess argparse might be capable of parsing the string but not necessarily producing list of strings as an output. but I just speculate here, wanted to learn the story :-)
lib/eunit/doc/overview.edoc
Outdated
@@ -963,11 +985,13 @@ tests, with optional teardown afterwards. The arguments are described in | |||
detail below. | |||
</dd> | |||
<dt>`{node, Node::atom(), Tests | Instantiator}'</dt> | |||
<dt>`{node, Node::atom(), Args::string(), Tests | Instantiator}'</dt> | |||
<dt>`{node, Node::atom(), Args::string()|[string()], Tests | Instantiator}'</dt> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrap |
with spaces
lib/eunit/doc/guides/chapter.md
Outdated
duration of the tests. The atom `Node` should have the format | ||
`[email protected]`, and `Args` are the optional arguments to the new | ||
node; see `slave:start_link/3` for details. | ||
node; see `peer:start_link/1` for details. For compatibility | ||
reasons `Args` can be either a string or a list of strings, and if a single |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand we have:
- new type expected by peer module and recommended by us (make it 1st on lists?), as less processing is performed when used
- a legacy type kept for compatibility reasons but always converted to format preferred by peer
maybe above is the information we would like to share with users. so that those who read docs, understand better what they should use to get best results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the "processing cost" perspective it is negligible. Breaking a list into words is cheap. I can emphasize this dual type of node arguments, that new type is list of strings, and string is just supported to not break old tests (from the experience some tests will still break but hopefully users will find the explanation in this doc paragraph we are editing now).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. but even if negligible, users might understand why 2 possibilities exist and which is preferred these days.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the wording in markdown docs and edoc yesterday, please have a look
lib/eunit/src/eunit_data.erl
Outdated
-spec parse_peer_args(string() | [string()]) -> [string()]. | ||
parse_peer_args([]) -> []; | ||
parse_peer_args(Args) when is_list(Args) -> % can be string or list of strings | ||
IsCodepoint = fun(CP) -> is_integer(CP) andalso 0 =< CP andalso CP < 16#110000 end, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not rely on one of io_lib:printable*
functions? maybe we could then avoid this code?
pls. squash commits before merging. |
Eunit - Summary of changes
slave
is removed from comments and private APIs as a unwelcome word.follower
(or no word if removed)slave
)As
slave
module is also deprecated, usage ofslave:start
in the tests is updated topeer:start