Skip to content

Commit

Permalink
Test inheritance.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Jul 30, 2023
1 parent 2aa881a commit fc13dc5
Show file tree
Hide file tree
Showing 24 changed files with 250 additions and 271 deletions.
45 changes: 0 additions & 45 deletions crates/core/project-graph/Cargo.toml

This file was deleted.

208 changes: 0 additions & 208 deletions crates/core/project-graph/tests/projects_test.rs

This file was deleted.

14 changes: 14 additions & 0 deletions nextgen/project-expander/src/project_expander.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use crate::expander_context::{ExpanderContext, ExpansionBoundaries};
use crate::tasks_expander::TasksExpander;
use moon_common::color;
use moon_config::DependencyConfig;
use moon_project::Project;
use rustc_hash::FxHashMap;
use std::collections::BTreeMap;
use std::mem;
use tracing::debug;

pub struct ProjectExpander<'graph, 'query> {
context: ExpanderContext<'graph, 'query>,
Expand All @@ -19,6 +21,12 @@ impl<'graph, 'query> ProjectExpander<'graph, 'query> {
// Clone before expanding!
let mut project = self.context.project.to_owned();

debug!(
id = project.id.as_str(),
"Expanding project {}",
color::id(&project.id)
);

self.expand_deps(&mut project)?;
self.expand_tasks(&mut project, boundaries)?;

Expand Down Expand Up @@ -59,6 +67,12 @@ impl<'graph, 'query> ProjectExpander<'graph, 'query> {
let mut expander = TasksExpander::new(&self.context);

for (task_id, mut task) in mem::take(&mut project.tasks) {
debug!(
target = task.target.as_str(),
"Expanding task {}",
color::label(&task.target)
);

// Resolve in this order!
expander.expand_env(&mut task)?;
expander.expand_deps(&mut task)?;
Expand Down
10 changes: 4 additions & 6 deletions nextgen/project-graph/src/project_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ impl ProjectGraph {

/// Return all projects from the graph.
pub fn get_all(&self) -> miette::Result<Vec<Arc<Project>>> {
let mut all = vec![];
let mut boundaries = ExpansionBoundaries::default();
let mut all = vec![];

for id in self.nodes.keys() {
all.push(self.internal_get(id, &mut boundaries)?);
Expand Down Expand Up @@ -185,7 +185,7 @@ impl ProjectGraph {
pub fn query<Q: AsRef<Criteria>>(&self, query: Q) -> miette::Result<Vec<Arc<Project>>> {
let mut projects = vec![];

for id in self.raw_query(query)? {
for id in self.internal_query(query)? {
projects.push(self.get(id)?);
}

Expand Down Expand Up @@ -262,15 +262,13 @@ impl ProjectGraph {

// Otherwise expand the project and cache it with an Arc
{
debug!(id = id.as_str(), "Expanding project {}", color::id(&id));

let query = |input: String| {
let mut results = vec![];

// Don't use get() for expanded projects, since it'll overflow the
// stack trying to recursively expand projects! Using unexpanded
// dependent projects works just fine for the this entire process.
for result_id in self.raw_query(build_query(input)?)? {
for result_id in self.internal_query(build_query(input)?)? {
results.push(self.get_unexpanded(result_id)?);
}

Expand All @@ -291,7 +289,7 @@ impl ProjectGraph {
Ok(Arc::clone(self.read_cache().get(&id).unwrap()))
}

fn raw_query<Q: AsRef<Criteria>>(&self, query: Q) -> miette::Result<&[Id]> {
fn internal_query<Q: AsRef<Criteria>>(&self, query: Q) -> miette::Result<&[Id]> {
let query = query.as_ref();
let query_input = query
.input
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tasks:
no-dupes:
deps:
- '@one:noop'
- 'alias-one:noop'
- '@one:global'
- 'alias-one:global'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tasks:
with-aliases:
deps:
- '@one:noop'
- '@three:noop'
- 'implicit:noop'
- '@one:global'
- '@three:global'
- 'implicit:global'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fileGroups:
sources:
- 'sources/**/*'
tests:
- 'tests/**/*'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fileGroups:
sources:
- 'src/**/*'
configs:
- 'config.*'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
implicitDeps:
- base:local

implicitInputs:
- global.*
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tasks:
local: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tasks:
example:
deps:
- 'other'
inputs:
- 'local.txt'
other: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tasks:
global:
command: global
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tasks:
global-node-library:
command: global-node-library
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tasks:
global-node:
command: global-node
Loading

0 comments on commit fc13dc5

Please sign in to comment.