Add a tool to run the tests of dependencies #26
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#1 のためのツールを作りました。 「テストを一々書かなくてもdependencyの元々のテストを使えばいいのでは?」という考えです。
cargo
(bin
の方)には元々dependencyに含まれているtargetを直接実行する機能があります。$ cargo test -p maplit -p num
しかしこれには致命的な制限があり、dev-dependencyが1つでもあると駄目です。 現在のdependency graph上で解決可能であってもです。
というよりCargo.lock
にはdev-dependenciesのすべてが含まれているはずですが。今回作ったツール、
dep-tests
は以下の動作をします。atcoder-rust-base
自身を除く)-d 1
を指定するとatcoder-rust-base
の[dependencies]
だけになる。$TMPDIR/atcoder-rust-base-dep-tests/
かどこかにそのpackageの為のworkspaceをN個作成する。 具体的には$CARGO_HOME/registry
からコピーしたものにatcoder-rust-base
のCargo.lock
を突っ込む。Cargo.lock
はrootがどことかは書かれていないのでそのままのバージョンで動く。 (source
が異なってくるはずだが何故かCargo.lock
はupdateされない。) N個のworkspaceに分離する理由はfeaturesの状態を極力保存するため。cargo test
する。この際current workspace member (= 元のdependencyの一つ)のみ元のfeaturesを再現する。現状問題のある点としてN個のビルドキャッシュを作るので時間とディスク容量によろしくないことと、いくつかのpackageがよくわからない理由でテスト(のビルド)に失敗してそれに
jemallocator
やpetgraph
が含まれていることですね。 (./dep-tests.toml
参照。)また
dep-tests
はcargo で npm-scripts 的なことをするで紹介された方法で起動します。 依存関係を独立させる方の方法なのでcwdがatcoder-lang-ja
である必要があります。