trixi-framework / trixi-framework/TrixiTest.jl

Make variables and functions in parent scope available within `@trixi_testset`

Open
#8 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Julia
Stars
2
Forks
0
Avg merge
8h 44m
Merged PRs (30d)
6

Description

This came up while working on #6 .

It would be nice if we could write

f(x) = ...
@trixi_testset "" begin
    #use f
end

as can be done with Test.jl's @testset. This is currently not possible with @trixi_testset because we wrap everything inside a dedicated module TrixiTestModule

Should we add syntax like $EXAMPLES_DIR to look up things in the parent, instead of special casing?

This is how BenchmarkTools does it https://github.com/JuliaCI/BenchmarkTools.jl/blob/cddd794ba336763be6831cfa076d27df96ef893c/src/execution.jl#L361-L380

Originally posted by @vchuravy in https://github.com/trixi-framework/TrixiTest.jl/pull/6#discussion_r2175686527

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the @trixi_testset macro and its TrixiTestModule wrapping, then compare the scope-handling approach in BenchmarkTools' src/execution.jl referenced by the issue. The change is complete when functions and variables defined in the parent scope, such as f in the example, are available inside @trixi_testset without requiring special syntax.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.