Skip to content

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Nov 14, 2025

Summary

This PR adds an e2e test that validates the behavior of mise task edit foo:bar:baz and verifies that the created task can be run with mise run foo:bar:baz.

Issue

The test currently exposes a bug where task names with colons (e.g., foo:bar:baz) create files with colons in the filename rather than creating the proper directory structure (foo/bar/baz). This causes the task to not be found when attempting to run it.

Root Cause

The name_from_path function in src/task/mod.rs:888 converts colons to underscores in path components and joins them with colons to create task names from file paths:

  • File path: mise-tasks/foo/bar/baz → Task name: foo:bar:baz

However, the edit command in src/cli/tasks/edit.rs:27 doesn't perform the reverse conversion when creating the file path from the task name:

let path = Task::task_dir().await.join(&self.task);

This means when you run mise task edit foo:bar:baz, it creates mise-tasks/foo:bar:baz (with colons in the filename) instead of mise-tasks/foo/bar/baz (directory structure).

Test Plan

Run the test to see it fail (exposing the bug):

mise run test:e2e test_task_edit_nested_names

The test validates:

  1. Creating a task with nested colons using mise task edit foo:bar:baz
  2. Running the task with mise run foo:bar:baz
  3. Verifying the task appears correctly in mise tasks ls
  4. Testing deeply nested task names like deploy:prod:backend:api

🤖 Generated with Claude Code


Note

Maps colon-separated task names to nested file paths in tasks edit and adds e2e tests validating creation, execution, and listing of nested tasks.

  • CLI
    • Update src/cli/tasks/edit.rs to convert : in task names to path separators (MAIN_SEPARATOR_STR) when creating paths: foo:bar:bazfoo/bar/baz.
    • Ensure parent directories are created before writing the task file (file::create_dir_all).
  • Tests
    • Add e2e test e2e/tasks/test_task_edit_nested_names covering:
      • Creating/editing nested tasks via mise task edit foo:bar:baz --path.
      • Executing nested tasks (mise run foo:bar:baz, deploy:prod:backend:api).
      • Verifying tasks appear in mise tasks ls and paths are stable across edits.

Written by Cursor Bugbot for commit 1a363f4. This will update automatically on new commits. Configure here.

This test validates the behavior of `mise task edit foo:bar:baz` and
verifies that the created task can be run with `mise run foo:bar:baz`.

The test currently exposes a bug where task names with colons (e.g.,
foo:bar:baz) create files with colons in the filename rather than
creating the proper directory structure (foo/bar/baz). This causes
the task to not be found when attempting to run it.

The name_from_path function in src/task/mod.rs:888 converts colons
to underscores in path components and joins them with colons, but
the edit command in src/cli/tasks/edit.rs:27 doesn't perform the
reverse conversion when creating the file path from the task name.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Copilot AI review requested due to automatic review settings November 14, 2025 20:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds an end-to-end test to validate the handling of task names containing nested colons (e.g., foo:bar:baz). The test intentionally exposes a bug where the mise task edit command creates files with colons in the filename instead of creating the proper nested directory structure, causing tasks to become unfindable.

Key Changes:

  • Adds comprehensive e2e test for task edit/run operations with colon-separated task names
  • Validates task creation, execution, and listing for both shallow and deeply nested task names
  • Uses a fake editor script to automate the task editing process without user interaction

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# and can be run with `mise run foo:bar:baz`

# Create a temporary editor script that just writes a simple task
export EDITOR="$PWD/fake-editor"
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

Using $PWD/fake-editor creates a dependency on the current working directory. Consider using an absolute path or ensure the script is always run from a known location to prevent failures if the working directory changes during test execution.

Copilot uses AI. Check for mistakes.

# Test 1: Create a task with nested colons using task edit
echo "Running: mise task edit foo:bar:baz --path"
mise task edit foo:bar:baz --path 2>&1 | tee /tmp/task_path.txt
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

Using hardcoded /tmp paths can cause issues in environments where /tmp is not available or when running tests in parallel. Consider using a test-specific temporary directory (e.g., via mktemp -d) to avoid conflicts and ensure cleanup.

Copilot uses AI. Check for mistakes.
assert_contains "mise tasks ls" "foo:bar:baz"

# Test 3: Try editing an existing nested task (should not create duplicates)
mise task edit foo:bar:baz --path >/tmp/task_path2.txt 2>&1
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

Using hardcoded /tmp paths can cause issues in environments where /tmp is not available or when running tests in parallel. Consider using a test-specific temporary directory (e.g., via mktemp -d) to avoid conflicts and ensure cleanup.

Copilot uses AI. Check for mistakes.
fi

# Test 4: Create a task with multiple levels of nesting
mise task edit deploy:prod:backend:api --path >/tmp/task_path3.txt 2>&1
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

Using hardcoded /tmp paths can cause issues in environments where /tmp is not available or when running tests in parallel. Consider using a test-specific temporary directory (e.g., via mktemp -d) to avoid conflicts and ensure cleanup.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Nov 14, 2025

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.11.4 x -- echo 18.3 ± 0.3 17.9 22.4 1.00 ± 0.02
mise x -- echo 18.3 ± 0.2 17.7 21.1 1.00

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.11.4 env 17.8 ± 0.3 17.4 20.7 1.00
mise env 17.9 ± 0.6 17.2 24.5 1.00 ± 0.04

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.11.4 hook-env 17.9 ± 0.3 17.3 22.4 1.00
mise hook-env 18.0 ± 0.2 17.5 20.0 1.01 ± 0.02

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.11.4 ls 15.4 ± 0.2 15.0 16.2 1.00
mise ls 15.5 ± 0.2 15.0 16.3 1.01 ± 0.02

xtasks/test/perf

Command mise-2025.11.4 mise Variance
install (cached) 104ms 105ms +0%
ls (cached) 63ms 63ms +0%
bin-paths (cached) 69ms 69ms +0%
task-ls (cached) 413ms 415ms +0%

When using `mise task edit foo:bar:baz`, the command now correctly
creates a directory structure (mise-tasks/foo/bar/baz) instead of
creating a file with colons in the filename (mise-tasks/foo:bar:baz).

This fix:
1. Replaces colons with MAIN_SEPARATOR_STR when joining the task name
   to the task directory path (matching the behavior in task add)
2. Creates parent directories if they don't exist using
   file::create_dir_all()

The e2e test now passes, validating that:
- Tasks with nested colons create proper directory structures
- Tasks can be run with their colon-separated names
- Tasks appear correctly in `mise tasks ls`
- Deeply nested task names work correctly

Fixes the issue where task names like "foo:bar:baz" would create
files with colons instead of directories, causing the task to not
be found when running `mise run foo:bar:baz`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@jdx jdx changed the title test(tasks): add e2e test for task edit with nested colons fix(tasks): fix nested colons with mise task edit Nov 14, 2025
@jdx jdx enabled auto-merge (squash) November 14, 2025 21:11
@jdx jdx merged commit bb90d19 into main Nov 14, 2025
29 checks passed
@jdx jdx deleted the test-task-edit-nested-names branch November 14, 2025 21:12
jdx pushed a commit that referenced this pull request Nov 15, 2025
### 🚀 Features

- **(http)** Add 'format' to http backend by @thejcannon in
[#6957](#6957)

### 🐛 Bug Fixes

- **(bootstrap)** wrong directory on first run by @vmeurisse in
[#6971](#6971)
- **(tasks)** fix nested colons with `mise task edit` by @jdx in
[#6978](#6978)
- Use compatible env flags by @thejcannon in
[#6964](#6964)
- Flush vfox download buffer by @blampe in
[#6969](#6969)

### 📚 Documentation

- `arch()` template is `x64` by @thejcannon in
[#6967](#6967)
- update section headers in getting-started.md by @JunichiroKohari in
[#6980](#6980)

### New Contributors

- @JunichiroKohari made their first contribution in
[#6980](#6980)
- @blampe made their first contribution in
[#6969](#6969)
- @thejcannon made their first contribution in
[#6964](#6964)

## 📦 Aqua Registry Updates

#### New Packages (1)

- [`cirruslabs/cirrus-cli`](https://github.com/cirruslabs/cirrus-cli)

#### Updated Packages (1)

- [`axodotdev/cargo-dist`](https://github.com/axodotdev/cargo-dist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants