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

Crate universe now renders separate BUILD files for each dependency #698

Merged
merged 7 commits into from
Apr 20, 2021
Merged

Crate universe now renders separate BUILD files for each dependency #698

merged 7 commits into from
Apr 20, 2021

Conversation

UebelAndre
Copy link
Collaborator

This change splits all the crate definitions into unique BUILD files. The repository directory is updated from

├── BUILD.bazel
├── WORKSPACE
├── defs.bzl
├── resolver
└── uses_sys_crate_deps.resolver_config.json

to

├── BUILD.bazel
├── BUILD.bzip2-0.3.3.bazel
├── BUILD.bzip2-sys-0.1.10+1.0.8.bazel
├── BUILD.cc-1.0.67.bazel
├── BUILD.libc-0.2.76.bazel
├── BUILD.pkg-config-0.3.19.bazel
├── WORKSPACE
├── defs.bzl
├── resolver
└── uses_sys_crate_deps.resolver_config.json

In my experience working on cargo-raze this makes testing and debugging much easier.

Copy link
Collaborator

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

This generally looks good, but I'm concerned that we're dropping down to zero test coverage for BUILD file rendering. Can you add a test which asserts on the output of renderer, given a single hard-coded RenderablePackage?

This can be nicely reproducible, deterministic, and hard-coded, and I'm ok with deleting integration.rs after that (though we should add some unit tests of resolver at some point), but dropping to 0 coverage feels bad.

crate_universe/src/renderer.rs Outdated Show resolved Hide resolved
Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
@UebelAndre
Copy link
Collaborator Author

I'll see what I can add. I initially tried adding the unit tests but felt that was a pretty decent rabbit hole and thought it would be better to do that in a dedicated PR. The changes can still be functionally tested using the examples so I wouldn't necessarily say there's zero coverage but definitely the state of testing right now is not ideal.

@UebelAndre
Copy link
Collaborator Author

I'm also a bit conflicted because a lot of this logic can be found in cargo-raze so getting deja-vu when looking to add tests.

@UebelAndre
Copy link
Collaborator Author

@illicitonion Is this a sufficient replacement of the tests?

Copy link
Collaborator

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

Thanks!

Comment on lines +607 to +609
# rules_rust crate_universe file format 1
# config hash 598

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should drop these lines from the output, they're only relevant for the lockfile which no longer uses them.

@@ -13,6 +13,7 @@ use crate_universe_resolver::config::{Config, Override, Package};
use crate_universe_resolver::NamedTempFile;

#[test]
#[ignore] // TODO: This test fails because of the way `test` is implemented, see that method for details
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's delete this whole file, no point keeping around a whole file of broken tests :)

@UebelAndre UebelAndre merged commit 65ca194 into bazelbuild:main Apr 20, 2021
illicitonion added a commit to illicitonion/rules_rust that referenced this pull request Apr 21, 2021
* Remove now-obsolete integration tests - we have some unit test
  coverage now, and that coupled with our examples, should be
  sufficient. More unit tests will come over time.
* Remove file format and config hash comment from generated output - the
  hash is now factored into the serialised JSON, and the file format is
  not currently relevant, though we may need to introduce a new
  equivalent in the future.
illicitonion added a commit that referenced this pull request Apr 21, 2021
* Remove now-obsolete integration tests - we have some unit test
  coverage now, and that coupled with our examples, should be
  sufficient. More unit tests will come over time.
* Remove file format and config hash comment from generated output - the
  hash is now factored into the serialised JSON, and the file format is
  not currently relevant, though we may need to introduce a new
  equivalent in the future.
yagehu pushed a commit to yagehu/rules_rust that referenced this pull request Apr 23, 2021
* Remove now-obsolete integration tests - we have some unit test
  coverage now, and that coupled with our examples, should be
  sufficient. More unit tests will come over time.
* Remove file format and config hash comment from generated output - the
  hash is now factored into the serialised JSON, and the file format is
  not currently relevant, though we may need to introduce a new
  equivalent in the future.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants