Skip to content

Commit

Permalink
cells: Avoid cell aggregator in more tests
Browse files Browse the repository at this point in the history
Summary: Makes changing it hard

Reviewed By: iguridi

Differential Revision: D59758653

fbshipit-source-id: fa60c91ca3b77fd9618c5ca963cb35c516ab5c88
  • Loading branch information
JakobDegen authored and facebook-github-bot committed Jul 18, 2024
1 parent 27f9e8f commit f407038
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
28 changes: 11 additions & 17 deletions app/buck2_build_api_tests/src/analysis/calculation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ use buck2_common::package_listing::listing::PackageListing;
use buck2_configured::configuration::calculation::ExecutionPlatformsKey;
use buck2_core::build_file_path::BuildFilePath;
use buck2_core::bzl::ImportPath;
use buck2_core::cells::alias::NonEmptyCellAlias;
use buck2_core::cells::cell_root_path::CellRootPathBuf;
use buck2_core::cells::name::CellName;
use buck2_core::cells::CellAliasResolver;
use buck2_core::cells::CellsAggregator;
use buck2_core::cells::CellResolver;
use buck2_core::configuration::data::ConfigurationData;
use buck2_core::execution_types::executor_config::CommandExecutorConfig;
use buck2_core::fs::project::ProjectRootTemp;
use buck2_core::fs::project_rel_path::ProjectRelativePathBuf;
use buck2_core::package::PackageLabel;
use buck2_core::provider::id::testing::ProviderIdExt;
use buck2_core::provider::id::ProviderId;
Expand Down Expand Up @@ -63,20 +61,16 @@ use starlark_map::ordered_map::OrderedMap;
#[tokio::test]
async fn test_analysis_calculation() -> anyhow::Result<()> {
let bzlfile = ImportPath::testing_new("cell//pkg:foo.bzl");
let resolver = {
let mut cells = CellsAggregator::new();
cells.add_cell_entry(
CellRootPathBuf::new(ProjectRelativePathBuf::unchecked_new("cell".to_owned())),
NonEmptyCellAlias::new("root".to_owned()).unwrap(),
CellRootPathBuf::new(ProjectRelativePathBuf::unchecked_new("".to_owned())),
)?;
cells.add_cell_entry(
CellRootPathBuf::new(ProjectRelativePathBuf::unchecked_new("cell".to_owned())),
NonEmptyCellAlias::new("cell".to_owned()).unwrap(),
CellRootPathBuf::new(ProjectRelativePathBuf::unchecked_new("cell".to_owned())),
)?;
cells.make_cell_resolver()?
};
let resolver = CellResolver::testing_with_names_and_paths(&[
(
CellName::testing_new("root"),
CellRootPathBuf::testing_new(""),
),
(
CellName::testing_new("cell"),
CellRootPathBuf::testing_new("cell"),
),
]);
let mut interpreter = Tester::with_cells((
CellAliasResolver::new(CellName::testing_new("cell"), HashMap::new())?,
resolver.dupe(),
Expand Down
15 changes: 6 additions & 9 deletions app/buck2_interpreter_for_build/src/interpreter/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ use buck2_common::package_listing::listing::testing::PackageListingExt;
use buck2_common::package_listing::listing::PackageListing;
use buck2_core::build_file_path::BuildFilePath;
use buck2_core::bzl::ImportPath;
use buck2_core::cells::alias::NonEmptyCellAlias;
use buck2_core::cells::build_file_cell::BuildFileCell;
use buck2_core::cells::cell_root_path::CellRootPathBuf;
use buck2_core::cells::name::CellName;
use buck2_core::cells::*;
use buck2_core::fs::project_rel_path::ProjectRelativePathBuf;
use buck2_core::fs::project_rel_path::ProjectRelativePath;
use buck2_core::target::label::interner::ConcurrentTargetLabelInterner;
use buck2_interpreter::extra::InterpreterHostArchitecture;
use buck2_interpreter::extra::InterpreterHostPlatform;
Expand Down Expand Up @@ -72,13 +72,10 @@ pub fn run_simple_starlark_test(content: &str) -> anyhow::Result<()> {
}

pub fn cells(extra_root_config: Option<&str>) -> anyhow::Result<CellsData> {
let mut agg = CellsAggregator::new();
agg.add_cell_entry(
CellRootPathBuf::new(ProjectRelativePathBuf::try_from("".to_owned())?),
NonEmptyCellAlias::new("root".to_owned()).unwrap(),
CellRootPathBuf::new(ProjectRelativePathBuf::try_from("".to_owned())?),
)?;
let resolver = agg.make_cell_resolver()?;
let resolver = CellResolver::testing_with_name_and_path(
CellName::testing_new("root"),
CellRootPathBuf::new(ProjectRelativePath::empty().to_owned()),
);

let config = parse_with_config_args(
&[
Expand Down

0 comments on commit f407038

Please sign in to comment.