Add job tags (#15555)

# Description

This PR implements job tagging through the usage of a new `job tag`
command and a `--tag` for `job spawn`

Closes #15354

# User-Facing Changes

- New `job tag` command
- Job list may now have an additional `tag` column for the tag of jobs
(rows representing jobs without tags do not have this column filled)
- New `--tag` flag for `job spawn`

# Tests + Formatting

Integration tests are provided to test the newly implemented features

# After Submitting

Possibly document job tagging in the jobs documentation
This commit is contained in:
Renan Ribeiro
2025-04-21 09:08:00 -03:00
committed by GitHub
parent b5b63d2bf9
commit a1497716f1
11 changed files with 200 additions and 14 deletions

View File

@ -215,3 +215,53 @@ fn job_extern_into_pipe_is_not_silent() {
assert_eq!(actual.out, "11");
assert_eq!(actual.err, "");
}
#[test]
fn job_list_returns_no_tag_when_job_is_untagged() {
let actual = nu!(r#"
job spawn { sleep 10sec }
job spawn { sleep 10sec }
job spawn { sleep 10sec }
('tag' in (job list | columns)) | to nuon"#);
assert_eq!(actual.out, "false");
assert_eq!(actual.err, "");
}
#[test]
fn job_list_returns_tag_when_job_is_spawned_with_tag() {
let actual = nu!(r#"
job spawn { sleep 10sec } --tag abc
job list | where id == 1 | get tag.0
"#);
assert_eq!(actual.out, "abc");
assert_eq!(actual.err, "");
}
#[test]
fn job_tag_modifies_untagged_job_tag() {
let actual = nu!(r#"
job spawn { sleep 10sec }
job tag 1 beep
job list | where id == 1 | get tag.0"#);
assert_eq!(actual.out, "beep");
assert_eq!(actual.err, "");
}
#[test]
fn job_tag_modifies_tagged_job_tag() {
let actual = nu!(r#"
job spawn { sleep 10sec } --tag abc
job tag 1 beep
job list | where id == 1 | get tag.0"#);
assert_eq!(actual.out, "beep");
assert_eq!(actual.err, "");
}