1
0
Fork 0
mirror of https://github.com/imjasonh/testscript-rs synced 2026-07-08 09:05:34 +00:00
testscript-rs/tests
Copilot fd479ece24
Add support for running specific test files (#32)
Adds a new `.files()` method to the Builder API that allows running
specific test files instead of discovering all `.txt` files in a
directory. This mirrors the functionality of Go's testscript `Files`
parameter.

## New API

```rust
// Run only specific test files
testscript::run("testdata")
    .files(["hello.txt", "exists.txt"])
    .execute()
    .unwrap();

// Combine with other features
testscript::run("testdata")
    .files(["hello.txt", "exists.txt"])
    .setup(|env| { /* setup code */ Ok(()) })
    .condition("custom", true)
    .preserve_work_on_failure(true)
    .execute()
    .unwrap();
```

## Benefits

- **Selective testing**: Run only specific test scenarios during
development
- **Faster CI**: Run subsets of tests in parallel jobs
- **Go compatibility**: Matches `testscript.Run(t,
testscript.Params{Files: []string{...}})`
- **Flexible paths**: Supports relative paths, absolute paths, and
filenames

## Implementation Details

- Adds optional `files` field to `RunParams` 
- Enhances internal `run()` function to handle file lists vs glob
discovery
- Preserves execution order as specified by user
- Comprehensive error handling for missing files and invalid paths
- Full backward compatibility - existing code unchanged

## Path Support

```rust
testscript::run("testdata")
    .files([
        "hello.txt",              // filename in testdata dir
        "subdir/nested.txt",      // relative path  
        "/abs/path/to/test.txt"   // absolute path
    ])
    .execute()
    .unwrap();
```

The feature includes focused test coverage with 7 test cases covering
essential scenarios including error conditions and path types. Based on
feedback, redundant tests were removed to maintain a clean and
meaningful test suite.

Fixes imjasonh/testscript-rs#7

<!-- START COPILOT CODING AGENT SUFFIX -->



<details>

<summary>Original prompt</summary>

> 
> ----
> 
> *This section details on the original issue you should resolve*
> 
> <issue_title>Add support for running specific test files</issue_title>
> <issue_description>## Feature Request: Run Specific Test Files
> 
> Go's testscript supports running specific files via the `Files`
parameter:
> 
> ```go
> testscript.Run(t, testscript.Params{
>     Files: []string{"specific_test.txt", "another_test.txt"},
> })
> ```
> 
> ## Proposed API
> 
> ```rust
> testscript::run("testdata")
>     .files(&["hello.txt", "exists.txt"])
>     .execute()
>     .unwrap();
> ```
> 
> ## Benefits
> 
> - **Selective testing**: Run only specific test scenarios
> - **Faster development**: Skip unrelated tests during development
> - **CI optimization**: Run subsets of tests in different jobs
> - **Go compatibility**: Match Go testscript functionality
> 
> ## Implementation
> 
> - Extend the Builder API with a `.files()` method
> - Create a separate `run_files()` entry point
> - Support both absolute and relative paths
> - Validate that specified files exist</issue_description>
> 
> ## Comments on the Issue (you are @copilot in this section)
> 
> <comments>
> </comments>
> 


</details>
Fixes imjasonh/testscript-rs#7

<!-- START COPILOT CODING AGENT TIPS -->
---

 Let Copilot coding agent [set things up for
you](https://github.com/imjasonh/testscript-rs/issues/new?title=+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: imjasonh <210737+imjasonh@users.noreply.github.com>
2025-09-30 03:36:07 -04:00
..
advanced_conditions.rs Add network and advanced condition support with automatic detection and CI optimization (#21) 2025-09-27 17:00:36 +00:00
builtin_commands.rs Fix symlink command implementation and add comprehensive tests (#22) 2025-09-27 03:41:07 +00:00
edge_cases.rs Refactor run module into modular structure (#18) 2025-09-27 01:17:45 +00:00
error_messages.rs improve error messages with context (#13) 2025-09-26 23:55:13 +00:00
integration.rs add GHA workflow (#1) 2025-09-26 19:08:48 -04:00
preserve_work.rs Add TestWork functionality to preserve working directories on failure (#24) 2025-09-27 19:03:10 +00:00
setup_hook.rs add GHA workflow (#1) 2025-09-26 19:08:48 -04:00
specific_files.rs Add support for running specific test files (#32) 2025-09-30 03:36:07 -04:00
update_scripts.rs Add UpdateScripts functionality for test maintenance (#20) 2025-09-26 21:47:09 -04:00
workdir_root.rs Add WorkdirRoot configuration for custom work directories (#27) 2025-09-30 06:57:10 +00:00