google / google/xls

[enhancement] Conditional test skipping based on configured values (e.g. #[skip_if])

Open
#4,967 0 comments 0 reactions 0 assignees View on GitHub
dslx enhancement testing
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

### What's hard to do? (limit 100 words)

There is currently no declarative mechanism to skip `#[test]` functions or `#[test_proc]`s based on compile-time configuration values (`configured_value_or`). When running test suites across different build/parameter configurations, we want to selectively run only the tests relevant to that configuration:

```dslx
pub const COLOR = configured_value_or("color", Color::Red);

#[test_proc]
#[skip_if COLOR != Color::Red]
proc test_red { ... }
```

### Current best alternative workaround (limit 100 words)

Currently, tests must inspect the configured value at runtime within the test body (e.g., within `next` for a proc) and wrap the execution in an `if` condition:

```dslx
next(state: ()) {
if COLOR == Color::Red {
// actual test logic
}
send(tok, terminator, true);
}
```

This harms readability and incurs runtime overhead from spawning, initializing, and stepping vacuous tests across configurations where they have nothing to test.

### Your view of the "best case XLS enhancement" (limit 100 words)

Provide an attribute or attribute argument (e.g., `#[skip_if ]` or `#[test_proc(skip_if = )]`) evaluated during elaboration/typechecking against configured constants.

If the condition evaluates to true, the test runner reports the test as skipped rather than elaborating and simulating a no-op test.

I believe in Rust, this is done through the `#[cfg(...)` attribute.

Contributor guide

Open the contributing guide

Research direction

Start by tracing how DSLX #[test] and #[test_proc] attributes are handled during elaboration and typechecking, then inspect how the test runner reports results. Use configured_value_or and the proposed #[skip_if] condition as the behavioral examples; done means configured tests are skipped before elaboration and simulation while still being reported as skipped.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, testing-qa
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.