mirror of
https://github.com/imjasonh/testscript-rs
synced 2026-07-08 09:05:34 +00:00
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>
|
||
|---|---|---|
| .. | ||
| advanced_conditions.rs | ||
| builtin_commands.rs | ||
| edge_cases.rs | ||
| error_messages.rs | ||
| integration.rs | ||
| preserve_work.rs | ||
| setup_hook.rs | ||
| specific_files.rs | ||
| update_scripts.rs | ||
| workdir_root.rs | ||