Skip to content
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

Remove dead code warnings from test #1963

Merged
merged 1 commit into from
Jan 15, 2020
Merged

Conversation

mfornet
Copy link
Member

@mfornet mfornet commented Jan 15, 2020

Use workaround proposed here to avoid dead code warning.

Copy link
Collaborator

@bowenwang1996 bowenwang1996 left a comment

Choose a reason for hiding this comment

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

Why do we have dead code in the first place?

@codecov
Copy link

codecov bot commented Jan 15, 2020

Codecov Report

Merging #1963 into staging will increase coverage by 0.09%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           staging    #1963      +/-   ##
===========================================
+ Coverage    86.59%   86.69%   +0.09%     
===========================================
  Files          167      167              
  Lines        31693    31653      -40     
===========================================
- Hits         27444    27440       -4     
+ Misses        4249     4213      -36
Impacted Files Coverage Δ
chain/network/tests/churn_attack.rs 94.73% <ø> (ø) ⬆️
chain/network/tests/routing.rs 99.52% <ø> (ø) ⬆️
chain/client/src/view_client.rs 69.01% <0%> (-0.93%) ⬇️
chain/jsonrpc/src/lib.rs 75.72% <0%> (-0.37%) ⬇️
chain/jsonrpc/client/src/lib.rs 84.28% <0%> (-0.23%) ⬇️
chain/chain/src/chain.rs 90.53% <0%> (-0.12%) ⬇️
chain/network/tests/cache.rs 93.33% <0%> (-0.09%) ⬇️
chain/jsonrpc/tests/rpc_query.rs 98.07% <0%> (-0.08%) ⬇️
runtime/runtime/src/state_viewer.rs 92.8% <0%> (-0.06%) ⬇️
chain/client/tests/chunks_management.rs 96.17% <0%> (-0.03%) ⬇️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 014793a...28d591c. Read the comment docs.

@mfornet
Copy link
Member Author

mfornet commented Jan 15, 2020

Why do we have dead code in the first place?

tl;dr: We don't have dead code, but there is a "bug" in cargo.

It is a "bug" in cargo (or bad design).
My use case was the following, I need to make some common tools for test, but didn't want to put them on src/test_utils.rs since it would make network depend on client (which is undesirable).
But adding it as dev-dependency is ok.

From rust book I found this pattern which was exactly what I needed. The problem with this is that every test file (under the tests folder) is seen by cargo as an independent crate, and since some tests don't use this common tools cargo complain about some dead code.

Read more about this issue on rust-lang/rust#46379 (I also found the fix there).

@nearprotocol-bulldozer nearprotocol-bulldozer bot merged commit cd763f3 into staging Jan 15, 2020
@nearprotocol-bulldozer nearprotocol-bulldozer bot deleted the remove_warning branch January 15, 2020 23:27
SkidanovAlex pushed a commit that referenced this pull request Jan 29, 2020
* Remove dead code warnings from test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants