Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Conditionally compile ethcore public test helpers #8743

Merged
merged 3 commits into from
Jun 4, 2018

Conversation

sorpaas
Copy link
Collaborator

@sorpaas sorpaas commented May 31, 2018

Partially address #8424. Related to #8371, rust-lang/cargo#2911, and rust-lang/cargo#1796.

This PR marks most of the specifications used only during test as any(test, feature="test-helpers") so that it won't be built during a normal build against the main binary.

In addition, it marks public test helpers exposed by ethcore to be compiled test only, and when the feature flag test-helpers is enabled, so that it can be used for tests in ethcore-sync and ethcore-private-tx. Because of rust-lang/cargo#1796, when you compile ethcore-sync or ethcore-private-tx only, the dev dependencies features (in our case, test-helpers by ethcore) will actually be leaked to normal builds. However, some testing shows me that when building the main binary, the dev dependency feature won't be enabled. So it's still an improvement compared with now.

$ cd ~/repos/parity2 && cargo build --verbose -j1
   Compiling ethcore v1.12.0 (file:///home/sorpaas/repos/parity2/ethcore)
     Running `rustc --crate-name ethcore ethcore/src/lib.rs --crate-type lib --emit=dep-info,link -C panic=abort -C debuginfo=2 -C metadata=81f88287d3525c4c -C extra-filename=-81f88287d3525c4c --out-dir /home/sorpaas/repos/parity2/target/debug/deps -C incremental=/home/sorpaas/repos/parity2/target/debug/incremental -L dependency=/home/sorpaas/repos/parity2/target/debug/deps --extern bn=/home/sorpaas/repos/parity2/target/debug/deps/libbn-85e95af6ccc19b21.rlib --extern fetch=/home/sorpaas/repos/parity2/target/debug/deps/libfetch-7b48e8658067875a.rlib --extern rlp_compress=/home/sorpaas/repos/parity2/target/debug/deps/librlp_compress-bb3c872bdacf476a.rlib --extern memorydb=/home/sorpaas/repos/parity2/target/debug/deps/libmemorydb-8c833c3ce27f57c4.rlib --extern log=/home/sorpaas/repos/parity2/target/debug/deps/liblog-78119d97edb5cdac.rlib --extern ethcore_crypto=/home/sorpaas/repos/parity2/target/debug/deps/libethcore_crypto-ebf39340b03d04a7.rlib --extern ethcore_logger=/home/sorpaas/repos/parity2/target/debug/deps/libethcore_logger-be5929c568437190.rlib --extern lazy_static=/home/sorpaas/repos/parity2/target/debug/deps/liblazy_static-36380811bb4409b6.rlib --extern ethcore_io=/home/sorpaas/repos/parity2/target/debug/deps/libethcore_io-b076831b92e65b0a.rlib --extern hardware_wallet=/home/sorpaas/repos/parity2/target/debug/deps/libhardware_wallet-d3942cc540ccd481.rlib --extern kvdb=/home/sorpaas/repos/parity2/target/debug/deps/libkvdb-231a78015172962a.rlib --extern ethjson=/home/sorpaas/repos/parity2/target/debug/deps/libethjson-65b37e4f7c59606a.rlib --extern ethkey=/home/sorpaas/repos/parity2/target/debug/deps/libethkey-1c2df86d6936576d.rlib --extern common_types=/home/sorpaas/repos/parity2/target/debug/deps/libcommon_types-47ea5e15cdf72af8.rlib --extern stats=/home/sorpaas/repos/parity2/target/debug/deps/libstats-531bdc5670f53607.rlib --extern unexpected=/home/sorpaas/repos/parity2/target/debug/deps/libunexpected-0402ddbb4faa72cf.rlib --extern journaldb=/home/sorpaas/repos/parity2/target/debug/deps/libjournaldb-9bcc8f03d6244828.rlib --extern lru_cache=/home/sorpaas/repos/parity2/target/debug/deps/liblru_cache-1c546763ebe2c99a.rlib --extern byteorder=/home/sorpaas/repos/parity2/target/debug/deps/libbyteorder-ae57b331f4d74948.rlib --extern util_error=/home/sorpaas/repos/parity2/target/debug/deps/libutil_error-e8501b65b4d8e4e2.rlib --extern rustc_hex=/home/sorpaas/repos/parity2/target/debug/deps/librustc_hex-ed6a0d11f8a2e347.rlib --extern bloomchain=/home/sorpaas/repos/parity2/target/debug/deps/libbloomchain-ec1ebab06e9d9a3c.rlib --extern ethabi_contract=/home/sorpaas/repos/parity2/target/debug/deps/libethabi_contract-d7b3572f20620146.rlib --extern rayon=/home/sorpaas/repos/parity2/target/debug/deps/librayon-0fb2b871f3d6cd68.rlib --extern rand=/home/sorpaas/repos/parity2/target/debug/deps/librand-a388309bd3440f96.rlib --extern ethereum_types=/home/sorpaas/repos/parity2/target/debug/deps/libethereum_types-8ce0c9f46c110dcb.rlib --extern ansi_term=/home/sorpaas/repos/parity2/target/debug/deps/libansi_term-ef21571ef721eeb7.rlib --extern wasm=/home/sorpaas/repos/parity2/target/debug/deps/libwasm-680f5dd5a268364d.rlib --extern memory_cache=/home/sorpaas/repos/parity2/target/debug/deps/libmemory_cache-c98b80a155c33f6d.rlib --extern kvdb_memorydb=/home/sorpaas/repos/parity2/target/debug/deps/libkvdb_memorydb-c6e9347acd24d88c.rlib --extern ethcore_miner=/home/sorpaas/repos/parity2/target/debug/deps/libethcore_miner-342aba83a6db68cc.rlib --extern triehash=/home/sorpaas/repos/parity2/target/debug/deps/libtriehash-0a7f98f5f492a5a5.rlib --extern num_cpus=/home/sorpaas/repos/parity2/target/debug/deps/libnum_cpus-114ad3409a8e899f.rlib --extern heapsize=/home/sorpaas/repos/parity2/target/debug/deps/libheapsize-bca4c3da9e61518d.rlib --extern ethcore_bytes=/home/sorpaas/repos/parity2/target/debug/deps/libethcore_bytes-e355b9a0c740ddd2.rlib --extern trace_time=/home/sorpaas/repos/parity2/target/debug/deps/libtrace_time-d16979767ac7e048.rlib --extern num=/home/sorpaas/repos/parity2/target/debug/deps/libnum-e31cf894b641f166.rlib --extern patricia_trie=/home/sorpaas/repos/parity2/target/debug/deps/libpatricia_trie-0dbd131f919f9407.rlib --extern parity_machine=/home/sorpaas/repos/parity2/target/debug/deps/libparity_machine-d3c41c965278ab9d.rlib --extern itertools=/home/sorpaas/repos/parity2/target/debug/deps/libitertools-237a8a3f79cecf6a.rlib --extern ethabi=/home/sorpaas/repos/parity2/target/debug/deps/libethabi-6a7bd4128ebcb844.rlib --extern ethcore_stratum=/home/sorpaas/repos/parity2/target/debug/deps/libethcore_stratum-707d6d18cdbbc120.rlib --extern using_queue=/home/sorpaas/repos/parity2/target/debug/deps/libusing_queue-5ca3baea74ab1e3d.rlib --extern rlp_derive=/home/sorpaas/repos/parity2/target/debug/deps/librlp_derive-532e0b4c9a27da01.so --extern ethcore_bloom_journal=/home/sorpaas/repos/parity2/target/debug/deps/libethcore_bloom_journal-b36fe74f79f98a20.rlib --extern crossbeam=/home/sorpaas/repos/parity2/target/debug/deps/libcrossbeam-c4ab23f58afc146f.rlib --extern ethcore_transaction=/home/sorpaas/repos/parity2/target/debug/deps/libethcore_transaction-818a8bfb40158762.rlib --extern error_chain=/home/sorpaas/repos/parity2/target/debug/deps/liberror_chain-19c54565d5627e0b.rlib --extern keccak_hash=/home/sorpaas/repos/parity2/target/debug/deps/libkeccak_hash-0584b92665453738.rlib --extern parking_lot=/home/sorpaas/repos/parity2/target/debug/deps/libparking_lot-bc176aeafcd9edd4.rlib --extern ethash=/home/sorpaas/repos/parity2/target/debug/deps/libethash-5e8f21acab8579a5.rlib --extern ethabi_derive=/home/sorpaas/repos/parity2/target/debug/deps/libethabi_derive-f7283388e7612199.so --extern ethstore=/home/sorpaas/repos/parity2/target/debug/deps/libethstore-30b80eec272a504f.rlib --extern rlp=/home/sorpaas/repos/parity2/target/debug/deps/librlp-175ee8b1c900e22b.rlib --extern hashdb=/home/sorpaas/repos/parity2/target/debug/deps/libhashdb-6eb753e0c298e96d.rlib --extern vm=/home/sorpaas/repos/parity2/target/debug/deps/libvm-fad0eba4e85f6fd7.rlib --extern snappy=/home/sorpaas/repos/parity2/target/debug/deps/libsnappy-4acae5bf662d516c.rlib --extern evm=/home/sorpaas/repos/parity2/target/debug/deps/libevm-3f0c43fd80a9f2f1.rlib --extern macros=/home/sorpaas/repos/parity2/target/debug/deps/libmacros-ed03972e81b48975.rlib --extern stop_guard=/home/sorpaas/repos/parity2/target/debug/deps/libstop_guard-0bca57b5b59dfabb.rlib -L native=/home/sorpaas/repos/parity2/target/debug/build/backtrace-sys-d196c22f0de8160f/out/.libs -L native=/home/sorpaas/repos/parity2/target/debug/build/ring-c8ca87b3784e0e14/out -L native=/home/sorpaas/repos/parity2/target/debug/build/rust-crypto-a9eca33dee046047/out -L native=/home/sorpaas/repos/parity2/target/debug/build/eth-secp256k1-507bdfb8bbbebfef/out -L native=/home/sorpaas/repos/parity2/target/debug/build/hidapi-d80d8691d640d77c/out -L native=/home/sorpaas/repos/parity2/target/debug/build/libusb-sys-d35e17ea53581ed2/out -L native=/home/sorpaas/repos/parity2/target/debug/build/snappy-sys-589ffee125bfb7ad/out`

No test features in the above case.

$ cd ~/repos/parity2 && cargo test --all --verbose -j1
   Compiling ethcore v1.12.0 (file:///home/sorpaas/repos/parity2/ethcore)
     Running `rustc --crate-name ethcore ethcore/src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 --cfg 'feature="test-helpers"' -C metadata=5be4de2fc6cad6dc -C extra-filename=-5be4de2fc6cad6dc --out-dir /home/sorpaas/repos/parity2/target/debug/deps -C incremental=/home/sorpaas/repos/parity2/target/debug/incremental -L dependency=/home/sorpaas/repos/parity2/target/debug/deps --extern ethcore_crypto=/home/sorpaas/repos/parity2/target/debug/deps/libethcore_crypto-626bc3630423c7c6.rlib --extern rlp=/home/sorpaas/repos/parity2/target/debug/deps/librlp-98e0d86eaff72f16.rlib --extern rustc_hex=/home/sorpaas/repos/parity2/target/debug/deps/librustc_hex-2ac0217e17795ab5.rlib --extern evm=/home/sorpaas/repos/parity2/target/debug/deps/libevm-a73ea73033ccea1f.rlib --extern num_cpus=/home/sorpaas/repos/parity2/target/debug/deps/libnum_cpus-c10bccbac8c41e40.rlib --extern crossbeam=/home/sorpaas/repos/parity2/target/debug/deps/libcrossbeam-4dedbab495d73130.rlib --extern stop_guard=/home/sorpaas/repos/parity2/target/debug/deps/libstop_guard-03ffafa7ec5dded9.rlib --extern memory_cache=/home/sorpaas/repos/parity2/target/debug/deps/libmemory_cache-2d8f48e0527dc8b7.rlib --extern ethstore=/home/sorpaas/repos/parity2/target/debug/deps/libethstore-d5e55e72b4a27852.rlib --extern ethcore_bytes=/home/sorpaas/repos/parity2/target/debug/deps/libethcore_bytes-9295b7e006eec3ce.rlib --extern bn=/home/sorpaas/repos/parity2/target/debug/deps/libbn-75534769a4d2427d.rlib --extern trace_time=/home/sorpaas/repos/parity2/target/debug/deps/libtrace_time-650456d5d45417b3.rlib --extern using_queue=/home/sorpaas/repos/parity2/target/debug/deps/libusing_queue-f71c80adb8e06cb5.rlib --extern rayon=/home/sorpaas/repos/parity2/target/debug/deps/librayon-c363718a6411ae7e.rlib --extern error_chain=/home/sorpaas/repos/parity2/target/debug/deps/liberror_chain-6de01d6884749002.rlib --extern snappy=/home/sorpaas/repos/parity2/target/debug/deps/libsnappy-097b4cdfe19d0c9a.rlib --extern ethcore_stratum=/home/sorpaas/repos/parity2/target/debug/deps/libethcore_stratum-abd4c9d5b75d1fe7.rlib --extern fetch=/home/sorpaas/repos/parity2/target/debug/deps/libfetch-4d9a0054228b4812.rlib --extern ethash=/home/sorpaas/repos/parity2/target/debug/deps/libethash-07837276a7f14844.rlib --extern triehash=/home/sorpaas/repos/parity2/target/debug/deps/libtriehash-3b117cf6b086330a.rlib --extern ethereum_types=/home/sorpaas/repos/parity2/target/debug/deps/libethereum_types-043699731120696c.rlib --extern stats=/home/sorpaas/repos/parity2/target/debug/deps/libstats-cfcf9fc99b92efef.rlib --extern rlp_derive=/home/sorpaas/repos/parity2/target/debug/deps/librlp_derive-f90f1c41f0406656.so --extern parking_lot=/home/sorpaas/repos/parity2/target/debug/deps/libparking_lot-9cee57f0605c93a3.rlib --extern hashdb=/home/sorpaas/repos/parity2/target/debug/deps/libhashdb-2f9e50522af156f5.rlib --extern bloomchain=/home/sorpaas/repos/parity2/target/debug/deps/libbloomchain-25d2dc87460e05fa.rlib --extern journaldb=/home/sorpaas/repos/parity2/target/debug/deps/libjournaldb-1f82dfc85c10cf74.rlib --extern patricia_trie=/home/sorpaas/repos/parity2/target/debug/deps/libpatricia_trie-66d56fe5e92f2c73.rlib --extern lru_cache=/home/sorpaas/repos/parity2/target/debug/deps/liblru_cache-2f9b81501186ce94.rlib --extern ethjson=/home/sorpaas/repos/parity2/target/debug/deps/libethjson-127d0dfb4e79b808.rlib --extern ethcore_transaction=/home/sorpaas/repos/parity2/target/debug/deps/libethcore_transaction-91e2dd926d04f8c4.rlib --extern vm=/home/sorpaas/repos/parity2/target/debug/deps/libvm-5f240481318be211.rlib --extern ethabi_derive=/home/sorpaas/repos/parity2/target/debug/deps/libethabi_derive-be7f8ef0f85bd9c2.so --extern ansi_term=/home/sorpaas/repos/parity2/target/debug/deps/libansi_term-c54d1f14ac7fe0e9.rlib --extern ethcore_bloom_journal=/home/sorpaas/repos/parity2/target/debug/deps/libethcore_bloom_journal-7e5ae81f6797b02d.rlib --extern wasm=/home/sorpaas/repos/parity2/target/debug/deps/libwasm-ef14268690abb480.rlib --extern parity_machine=/home/sorpaas/repos/parity2/target/debug/deps/libparity_machine-bf8557a6199958a4.rlib --extern num=/home/sorpaas/repos/parity2/target/debug/deps/libnum-b74f707cb63fda72.rlib --extern rlp_compress=/home/sorpaas/repos/parity2/target/debug/deps/librlp_compress-65430642d33c461a.rlib --extern macros=/home/sorpaas/repos/parity2/target/debug/deps/libmacros-887fc9d779f0ae05.rlib --extern ethabi=/home/sorpaas/repos/parity2/target/debug/deps/libethabi-8b8fabd64d46c2ab.rlib --extern byteorder=/home/sorpaas/repos/parity2/target/debug/deps/libbyteorder-50a8b02a10139739.rlib --extern ethcore_miner=/home/sorpaas/repos/parity2/target/debug/deps/libethcore_miner-9b5bc81df37a469e.rlib --extern ethcore_logger=/home/sorpaas/repos/parity2/target/debug/deps/libethcore_logger-fab9abdc533ec30d.rlib --extern keccak_hash=/home/sorpaas/repos/parity2/target/debug/deps/libkeccak_hash-ddb6f034e606b681.rlib --extern unexpected=/home/sorpaas/repos/parity2/target/debug/deps/libunexpected-8c93eed746bfd2d5.rlib --extern memorydb=/home/sorpaas/repos/parity2/target/debug/deps/libmemorydb-fa2a3a9e42b11f18.rlib --extern kvdb=/home/sorpaas/repos/parity2/target/debug/deps/libkvdb-de42dd9265083af0.rlib --extern ethcore_io=/home/sorpaas/repos/parity2/target/debug/deps/libethcore_io-9cfb624108b83a00.rlib --extern kvdb_memorydb=/home/sorpaas/repos/parity2/target/debug/deps/libkvdb_memorydb-db68518cab560f39.rlib --extern lazy_static=/home/sorpaas/repos/parity2/target/debug/deps/liblazy_static-d607ec3120d15dee.rlib --extern util_error=/home/sorpaas/repos/parity2/target/debug/deps/libutil_error-9ebd079083fdce17.rlib --extern hardware_wallet=/home/sorpaas/repos/parity2/target/debug/deps/libhardware_wallet-1c8ba8783a9ea110.rlib --extern log=/home/sorpaas/repos/parity2/target/debug/deps/liblog-705b2d5c50d37a8d.rlib --extern heapsize=/home/sorpaas/repos/parity2/target/debug/deps/libheapsize-8c8e9d024d74705c.rlib --extern itertools=/home/sorpaas/repos/parity2/target/debug/deps/libitertools-d89429423bb397c3.rlib --extern rand=/home/sorpaas/repos/parity2/target/debug/deps/librand-d0f6f520ecfc6ae5.rlib --extern ethkey=/home/sorpaas/repos/parity2/target/debug/deps/libethkey-f82f89c263c49398.rlib --extern ethabi_contract=/home/sorpaas/repos/parity2/target/debug/deps/libethabi_contract-05659b1c6bff1859.rlib --extern common_types=/home/sorpaas/repos/parity2/target/debug/deps/libcommon_types-a3d59d2cfdc95e0a.rlib -L native=/home/sorpaas/repos/parity2/target/debug/build/backtrace-sys-56a3cb0b88878ac9/out/.libs -L native=/home/sorpaas/repos/parity2/target/debug/build/ring-b987f3baf1146938/out -L native=/home/sorpaas/repos/parity2/target/debug/build/rust-crypto-1212c6c91e8568d6/out -L native=/home/sorpaas/repos/parity2/target/debug/build/eth-secp256k1-4ccf4d301778400a/out -L native=/home/sorpaas/repos/parity2/target/debug/build/hidapi-ad4f62fe37af26eb/out -L native=/home/sorpaas/repos/parity2/target/debug/build/libusb-sys-d5bd41c7039a5fea/out -L native=/home/sorpaas/repos/parity2/target/debug/build/snappy-sys-0042e6120fea3000/out`

Have test features in this case.

@sorpaas sorpaas added A0-pleasereview 🤓 Pull request needs code review. F6-refactor 📚 Code needs refactoring. M4-core ⛓ Core client code / Rust. labels May 31, 2018
@sorpaas sorpaas added this to the 1.12 milestone May 31, 2018
@debris debris added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jun 4, 2018
@debris debris requested a review from tomusdrw June 4, 2018 08:22
Copy link
Collaborator

@niklasad1 niklasad1 left a comment

Choose a reason for hiding this comment

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

Looks good, but I would prefer a space to separate the features e.g, #[cfg(feature = "test-helper")] instead of #[cfg(feature="test-helper")]

Although, we are not completly consistent with that

➜  parity git:(na-updater-verification) ✗ gg "feature = " | wc -l
74
➜  parity git:(na-updater-verification) ✗ gg "feature=" | wc -l 
9

@sorpaas
Copy link
Collaborator Author

sorpaas commented Jun 4, 2018

@niklasad1 Let me fix all those whitespace in this PR then.

@5chdn 5chdn merged commit e2a90ce into master Jun 4, 2018
@5chdn 5chdn deleted the ethcore-test-compile-refactors branch June 4, 2018 13:58
ordian added a commit to ordian/parity that referenced this pull request Jun 4, 2018
…rp_sync_on_light_client

* 'master' of https://github.com/paritytech/parity:
  Conditionally compile ethcore public test helpers (openethereum#8743)
dvdplm added a commit that referenced this pull request Jun 7, 2018
…eric

* origin/master:
  ethcore: fix ancient block error msg handling (#8832)
  CI: Fix docker tags (#8822)
  parity: fix indentation in sync logging (#8794)
  Removed obsolete IpcMode enum (#8819)
  Remove UI related settings from CLI (#8783)
  Remove windows tray and installer (#8778)
  docs: add changelogs for 1.10.6 and 1.11.3 (#8810)
  Fix ancient blocks queue deadlock (#8751)
  Disallow unsigned transactions in case EIP-86 is disabled (#8802)
  Fix evmbin compilation (#8795)
  Have space between feature cfg flag (#8791)
  rpc: fix address formatting in TransactionRequest Display (#8786)
  Conditionally compile ethcore public test helpers (#8743)
  Remove Result wrapper from AccountProvider in RPC impls (#8763)
  Update `license header` and `scripts` (#8666)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. F6-refactor 📚 Code needs refactoring. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants