Skip to content

Commit

Permalink
Test tag deps.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Jul 30, 2023
1 parent fc13dc5 commit a5d685f
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 17 deletions.
2 changes: 1 addition & 1 deletion nextgen/config/src/project/task_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn validate_command_list<D, C>(args: &[String], _task: &D, _ctx: &C) -> Result<(

pub fn validate_deps<D, C>(deps: &[Target], _data: &D, _context: &C) -> Result<(), ValidateError> {
for (i, dep) in deps.iter().enumerate() {
if matches!(dep.scope, TargetScope::All | TargetScope::Tag(_)) {
if matches!(dep.scope, TargetScope::All) {
return Err(ValidateError::with_segment(
"target scope not supported as a task dependency",
PathSegment::Index(i),
Expand Down
8 changes: 0 additions & 8 deletions nextgen/config/tests/inherited_tasks_config_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,6 @@ implicitDeps:
InheritedTasksConfig::load(path.join(FILENAME))
});
}

#[test]
#[should_panic(expected = "target scope not supported as a task dependency")]
fn errors_on_tag_scope() {
test_load_config(FILENAME, "implicitDeps: ['#tag:task']", |path| {
InheritedTasksConfig::load(path.join(FILENAME))
});
}
}

mod implicit_inputs {
Expand Down
6 changes: 0 additions & 6 deletions nextgen/config/tests/task_config_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,6 @@ deps:
fn errors_on_all_scope() {
test_parse_config("deps: [':task']", |code| TaskConfig::parse(code));
}

#[test]
#[should_panic(expected = "target scope not supported as a task dependency")]
fn errors_on_tag_scope() {
test_parse_config("deps: ['#tag:task']", |code| TaskConfig::parse(code));
}
}

mod inputs {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
tags: ['test']

tasks:
test:
command: test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
tags: ['test']

tasks:
test:
command: test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tags: ['test']
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ tasks:
- 'build'
deps:
- '^:build'

test-tags:
command: 'test'
deps:
- '#test:test'
17 changes: 15 additions & 2 deletions nextgen/project-graph/tests/project_graph_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,13 +726,26 @@ mod project_graph {

assert_eq!(task.deps, [Target::parse("project:build").unwrap()]);
}

#[tokio::test]
async fn expands_tag_deps_in_task() {
let graph = generate_project_graph("expansion").await;
let project = graph.get("tasks").unwrap();
let task = project.get_task("test-tags").unwrap();

assert_eq!(
task.deps,
[
Target::parse("tag-three:test").unwrap(),
Target::parse("tag-one:test").unwrap(),
]
);
}
}

mod dependencies {
use super::*;

// TODO #tag deps

#[tokio::test]
async fn lists_ids_of_dependencies() {
let graph = generate_project_graph("dependencies").await;
Expand Down
1 change: 1 addition & 0 deletions website/docs/how-it-works/project-graph.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ integration.
environments, and will sync as a production dependency.
- **Development** - Dependency is required in development and production, _will be_ pruned from
production environments, and will sync as a development-only dependency.
- **Build** - Dependency is required for building only, and will sync as a build dependency.
- **Peer** - Dependency is a peer requirement, with language specific semantics. Will sync as a peer
dependency when applicable.

Expand Down

0 comments on commit a5d685f

Please sign in to comment.