Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions .github/skills/jit-regression-test/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
---
name: jit-regression-test
description: Extract a standalone JIT regression test case from a given GitHub issue and save it under the JitBlue folder. Use this when asked to create or extract a JIT regression test from an issue.
description: >
Extract a standalone JIT regression test case from a given GitHub issue and
save it under the JitBlue folder. USE FOR: creating JIT regression tests,
extracting repro code from dotnet/runtime issues, "write a test for this JIT
bug", "create a regression test for issue #NNNNN", converting issue repro to
xunit test. DO NOT USE FOR: non-JIT tests (use standard test patterns),
debugging JIT issues without a known repro, performance benchmarks (use
performance-benchmark skill).
---

# JIT Regression Test Extraction

When you need to extract a JIT regression test case from a GitHub issue, follow this process to create a properly structured test under `src/tests/JIT/Regression/JitBlue/`.
> 🚨 **Do NOT create a test when**: the issue has no reproducible code and you cannot compose a minimal repro, the issue is a duplicate of an existing test under `JitBlue/`, or the bug is in libraries/runtime rather than the JIT compiler itself.

Extract a JIT regression test case from a GitHub issue into a properly structured test under `src/tests/JIT/Regression/JitBlue/`.

## Step 1: Gather Information from the GitHub Issue

From the GitHub issue, extract:
1. **Issue number** - Used to name the test folder and files (e.g., issue #99391 → `Runtime_99391`)
2. **Reproduction code** - The C# code that demonstrates the bug. If no code provided, try to compose it yourself.
3. **Environment variables** - Any DOTNET_* environment variables required to reproduce the bug
4. **Expected behavior** - What the correct output/behavior should be
1. **Issue number** → folder/file name (e.g., #99391 → `Runtime_99391`)
2. **Reproduction code** — if none provided, compose a minimal repro yourself
3. **Environment variables** — any `DOTNET_*` vars needed to reproduce
4. **Expected behavior** correct output/behavior

## Step 2: Create the Test Directory

Expand Down Expand Up @@ -52,8 +61,9 @@ public class Runtime_<issue_number>

- **License header**: Always include the standard .NET Foundation license header
- **Class name**: Match the file name exactly (`Runtime_<issue_number>`)
- **Test method**: Use `[Fact]` attribute and name the method `TestEntryPoint()` or `Test()`
- **Assertions**: Use Xunit's helpers or just throw plain exceptions.
- **Test method**: `[Fact]` attribute, named `TestEntryPoint()`
- **Minimize the reproduction**: Strip to the minimal case that triggers the bug
- **Use `[MethodImpl(MethodImplOptions.NoInlining)]`** when preventing inlining is needed to reproduce

### Example: Simple Test (from Runtime_99391)

Expand Down Expand Up @@ -91,6 +101,7 @@ public class Runtime_99391
A custom `.csproj` file is **only required** when:
- Environment variables are needed to reproduce the bug (such as `DOTNET_JitStressModeNames`)
- Special compilation settings are required

Otherwise, register the test file in the existing `src/tests/JIT/Regression/Regression_*.csproj` (`Regression_ro_2.csproj` is a good default) file and skip creating a new .csproj.

If a custom .csproj file is needed, it should be located next to the test source file with the following name: `Runtime_<issue_number>.csproj`. Example:
Expand All @@ -111,9 +122,7 @@ If a custom .csproj file is needed, it should be located next to the test source
</Project>
```

## Important Notes
## Tips

- **No .csproj needed for simple tests**: Most tests only need the `.cs` file in a separate `src/tests/JIT/Regression/JitBlue/Runtime_*/` folder and being registered in `Regression_ro_2.csproj`.
- **Look at recent tests**: When in doubt, examine recent tests under `src/tests/JIT/Regression/JitBlue/Runtime_*` for the latest conventions.
- **Use `[MethodImpl(MethodImplOptions.NoInlining)]`**: When you need to prevent inlining to reproduce a JIT bug.
- **Minimize the reproduction**: Strip down the test code to the minimal case that reproduces the issue.
- **No .csproj needed for simple tests** — register the `.cs` file in `Regression_ro_2.csproj` instead.
- **Look at recent tests** under `src/tests/JIT/Regression/JitBlue/Runtime_*` when in doubt about current conventions.