ZigBrains icon indicating copy to clipboard operation
ZigBrains copied to clipboard

Zig Run and Zig Test run actions should be able to utilize build.zig dependencies

Open mobiuscog opened this issue 1 year ago • 5 comments

Similar to https://github.com/FalsePattern/ZigBrains/issues/41, when there are build dependencies, the 'Green Arrows' in the margins to run code/tests will fail, as they rely on the run configuration.

Is there any way to repurpose these to use the build pipeline instead, or is it a limitation of the IDE that means we cannot use the margin-based runners ? (Basically is it possible to optionally replace all usages of 'run' configurations with 'build' configurations ?

mobiuscog avatar May 18 '24 16:05 mobiuscog

You can use the green arrow run button in build.zig if you want to run zig build-based tasks, the arrows in the files are for zig run and zig test respectively.

FalsePattern avatar May 23 '24 01:05 FalsePattern

Thanks.

I realise this, but it means the granularity of running individual tests from the files themselves, which is often useful as part of a development iteration loop, is lost.

Oh well.

mobiuscog avatar May 23 '24 06:05 mobiuscog

I'll look into implementing some sort of custom build runner into zigbrains in a future release that can utilize build.zig dependencies for the in-file run buttons (similarly to what intellij already does with gradle/maven java projects)

FalsePattern avatar May 23 '24 08:05 FalsePattern

As a rough idea/draft of this feature, here's a concept for how dependency discovery would be done for the tests:

  • For each test-type step in build.zig, extract all the individual files/tests being tested by it, and use the specific dependencied bound to that test step for them

  • If a specific file or test is not present in any test steps in build.zig, the plugin can either notify the user to add the file/test to a step, or just let them bypass it by attempting to run the test with the dependencies from the default test task, and if that fails, show an error popup

The ZB build runner would then just create a single-file test step in the background with the discovered dependencies and use that for the test run buttons.

(As an added bonus, a custom build runner would also make zig build test runs debuggable too!)

FalsePattern avatar May 23 '24 08:05 FalsePattern

That all sounds awesome. I appreciate how 'young' all of this is - ZigBrains lets so many people learn and grow with Zig within a familiar environment, and enhancements like this will really help.

mobiuscog avatar May 23 '24 12:05 mobiuscog