Skip to content

Conversation

glowang
Copy link
Contributor

@glowang glowang commented May 9, 2020

Replaced the global argsManager gArgs with a locally defined one in getarg_tests. This is to avoid confusion in arg settings between the test's ArgsManager and the #18804

@fanquake fanquake added the Tests label May 9, 2020
@fanquake fanquake requested a review from ryanofsky May 10, 2020 06:25
@glowang glowang changed the title Pass ArgsManager into functions that register args with AddArg Pass ArgsManager into getarg_tests May 10, 2020
@glowang glowang marked this pull request as ready for review May 10, 2020 18:01
@glowang glowang force-pushed the replace_global_gArgs_with_local_argsman branch 2 times, most recently from 2503118 to af069fc Compare May 12, 2020 05:12
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK af069fc. This change seems good and is an improvement, but I left a suggestion to use a unique ArgsManager for each test case instead of a shared one.

@glowang glowang force-pushed the replace_global_gArgs_with_local_argsman branch from af069fc to a2efd77 Compare May 13, 2020 15:51
Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK. Thanks for switching the tests away from using gArgs this could badly interfere with later tests and cause hard to debug run-time issues

maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request May 14, 2020
Currently gArgs and argsman are aliases for each other, but long term
gArgs will be removed from the Setup*Args helpers, to avoid conflicts in
how gArgs is used. See bitcoin#18926 and bitcoin#18662

-BEGIN VERIFY SCRIPT-
sed -i -e 's/gArgs.Add/argsman.Add/g' ./src/init.cpp
-END VERIFY SCRIPT-
@glowang glowang force-pushed the replace_global_gArgs_with_local_argsman branch 2 times, most recently from 45b309d to c5ee239 Compare May 16, 2020 16:39
@glowang glowang force-pushed the replace_global_gArgs_with_local_argsman branch from c5ee239 to 03ca212 Compare May 19, 2020 05:22
@glowang glowang force-pushed the replace_global_gArgs_with_local_argsman branch 3 times, most recently from 42ba156 to ff003a6 Compare May 23, 2020 16:44
@glowang glowang requested review from maflcko, ryanofsky and dongcarl May 23, 2020 18:10
@glowang
Copy link
Contributor Author

glowang commented May 23, 2020

This is ready for re-review.

@maflcko maflcko changed the title Pass ArgsManager into getarg_tests test: Pass ArgsManager into getarg_tests May 23, 2020
Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost-ACK

glowang added 2 commits May 28, 2020 06:21
…d args manager

and put it into the getarg_tests namespace
-BEGIN VERIFY SCRIPT-
sed -i 's/\<gArgs\>/m_args/g' src/test/getarg_tests.cpp
-END VERIFY SCRIPT-
@glowang glowang force-pushed the replace_global_gArgs_with_local_argsman branch from ff003a6 to f871f15 Compare May 28, 2020 13:30
@maflcko
Copy link
Member

maflcko commented May 28, 2020

ACK f871f15

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK f871f15. Changes look good and thanks for updating. In future would recommend using clang-format-diff and following coding style notes, because it's atypical to indent namespace content, or indent protected keywords or put spaces around ::. Also it's fragile to define test setup class in a namespace, but test setup methods outside of the namespace and inside the test fixture instead. Would be simpler to just define the testing setup completely before using it without a namespace like:

class RPCTestingSetup : public TestingSetup
and it would have been a slightly smaller change too.

No need to change anything though, this is already better

@maflcko
Copy link
Member

maflcko commented May 29, 2020

If someone want to fix the "namespace issue" in a follow-up, the same should probably be done in the other test case too: #18926 (comment)

@maflcko maflcko merged commit cb88de3 into bitcoin:master May 29, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 31, 2020
f871f15 scripted-diff: replace gArgs with argsman (glowang)
357f02b Create a local class inherited from BasicTestingSetup with a localized args manager and put it into the getarg_tests namespace (glowang)

Pull request description:

  Replaced the global argsManager gArgs with a locally defined one in getarg_tests. This is to avoid confusion in arg settings between the test's ArgsManager and the   bitcoin#18804

ACKs for top commit:
  MarcoFalke:
    ACK f871f15
  ryanofsky:
    Code review ACK f871f15. Changes look good and thanks for updating. In future would recommend using clang-format-diff and following [coding style](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#coding-style-c) notes, because it's atypical to indent namespace content, or indent protected keywords or put spaces around ::. Also it's fragile to define test setup class in a namespace, but test setup methods outside of the namespace and inside the test fixture instead. Would be simpler to just define the testing setup completely before using it without a namespace like: https://github.com/bitcoin/bitcoin/blob/8ad5f1c376fe99eeccac2696ac0e18e662323a4d/src/test/rpc_tests.cpp#L23 and it would have been a slightly smaller change too.

Tree-SHA512: 016594639396d60667fadec8ea80ef7af634fbb2014c704f02406fe3251c5362757c21f1763d8bdb94ca4a3026ab9dc786a92a9a934efc8cd807655d9deee779
maflcko pushed a commit that referenced this pull request Jul 30, 2020
… args

8ed9002 refactor: use local argsmanager in CRegTestParams (Ivan Metlushko)
9b20f66 scripted-diff: Replace gArgs with local argsman (Ivan Metlushko)
a316e9c refactor: add unused ArgsManager to replace gArgs (Ivan Metlushko)

Pull request description:

  Rationale: reduce use of gArgs to decouple code and simplify future maintenance and easier unit testing.

  This PR is continuation of work started in  #18926 and #18662
  It covers only places that register args in ArgsManager with `AddArgs()` or `AddHiddenArgs()`.

  Closes #19511

ACKs for top commit:
  MarcoFalke:
    ACK 8ed9002 👛

Tree-SHA512: 7e6ba8e8357a48833c71e9c3942a769acb3d93bdcc6748a8ef2b7c4461a2499419b60896abf1d8b6bf8e88ee2590284cdd5da64220243ac22375300bcb8fe3e8
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Dec 10, 2020
Summary:
```
Replaced the global argsManager gArgs with a locally defined one in
getarg_tests. This is to avoid confusion in arg settings between the
test's ArgsManager and the #18804
```

Backport of core [[bitcoin/bitcoin#18926 | PR18926]].

This overrides the changes from D4462 which achieved the same goal.

Test Plan:
  ninja check

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D8643
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants