The previous commit to this file allowed it to create and upload a
commit when a TEST_MAPPING file changed. But it did not handle the
case where the TEST_MAPPING file did not previously exist. This fixes
that.
Test: Run script.
Change-Id: Id7b9e778c2b084f7ea2e4005a173c1fedeccd6c7
This will make it easier to run it on many crates and upload all of
the changes. It puts the uploaded CLs in a topic to save resources.
If the script does not change a TEST_MAPPING, it does not upload
anything.
Test: Run on a subset of crates.
Change-Id: I47b4756d968c54d7d810c8a19a8a7419aebc6e15
Currently the script can only run on a single crate at a time, and
each time it runs it re-initializes Bazel. By passing multiple crates
we can save time by only initializing Bazel once.
Test: Call with zero, one, and multiple crate arguments.
Change-Id: Ic83c16d87066a8555b736b35bc7971586ee26e16
Env.cwd is misleading as it captures the location of the crate/package
being updated. Move the detection logic to the Package class and rename
the attribute.
There is the expectation that before running soong_ui, cwd is set to
ANDROID_BUILD_TOP; and before running write_mapping, that cwd is set to
the package directory. Add comments to capture this.
Test: update_crate_tests.py in external/rust/crates/libc
Change-Id: I5c4f16afe0b92b7c85173e4149ee17dd39c773c2
Rename the Crate class to Package as this script may also be used to
update TEST_MAPPING for the prebuilts/rust toolchain.
Inline get_tests function as one branch was never used.
Rename `create_test_mapping` to `create` as it is already a method of
TestMapping.
Test: update_crate_tests.py in external/rust/crates/libc
Test: update_crate_tests.py in prebuilts/rust
Change-Id: I06bd6d4f93223bb50fdb898980bd25fa3cea9019
Normalize the object initializations by raising exceptions and catching
them within main.
Test: update_crate_tests.py in external/rust/crates/libc
Change-Id: I6080fa7f22d740f5dd384c15ef74097e61dbb210
We currently seem to emit TEST_MAPPING files in an arbitrary order,
which causes diffs to look confusing even when nothing has changed.
Let's sort them by the test name, which is both stable and easier to
read.
Test: Run cargo2android multiple times and see no TEST_MAPPING diff.
Change-Id: I398aa84a4891380e4292223445bd53959c024421
This test looks like it basically never passed without this.
Test: Run cargo2android.py and see timeout.
Change-Id: Ic7ef5576efb84d78130dd45db67e50ebe41f6d9a
If the TEST_MAPPING cannot be generated, print the reason, but
exit without error. It's not uncommon for the output of cargo2android
to fail to build e.g. if a new depencency is not satisfied, so we can
fall back to the previous TEST_MAPPING, or run update_crate_tests
locally once all dependencies are present.
Bug: 179132533
Test: tools/external_updater/updater.sh update rust/crates/textwrap
Test: tools/external_updater/updater.sh update rust/crates/libc
Change-Id: I4802c77332d1ab1d6604d48c47365f40bdbd1122
Allow this script to accept a path to the crate being updated.
This allows it to be run separately from cargo2android.
Also, fail gracefully on error. TEST_MAPPING update failures should
not block crate updates.
Test: tools/external_updater/updater.sh update rust/crates/libc
Bug: 179132533
Change-Id: I3a4229f479ab3d2793df16b470f0a0632b9ee495
The aidl tests and ChromeOS tests are not intended to be run in
presubmit, so exclude them.
Test: run cargo2android in external/rust/crates/libc.
Change-Id: I1ed92ed6e88886e3fea38612325ce5349db0fb69
This is important because:
1. Some crates do not have their own tests enabled in presubmit.
2. As much as possible, we try to stick with one version of each
crate. This often results in using different versions of
dependencies than a crate has specified in its Cargo.toml.
Ensuring that a crate's tests continue to pass when its dependencies
are upgraded improves our confidence that the update is safe.
The underlying implementation uses the new Bazel queryview
to query modules and reverse dependencies.
Bug: 168167373
Test: Run cargo2android.py on a number of crates including rusqlite,
scopeguard, lock_api.
Change-Id: Id24f2d3267cf8d5e0369ece2442f8971d4ab1343