简体   繁体   中英

How can I dynamically generate a bazel test suite?

I want to dynamically generate Bazel test rules based on the output of a complicated python script (uses imports etc., can't be ported to Starlark unfortunately).

Is it possible to run this script, parsing its output and creating the test rules during Bazel rules parsing time instead of somehow generating a BUILD file that contains these rules pre-written?

Bazel parses WORKSPACE, BUILD, and.bzl files in the loading phase , which comes before analysis and execution phase. If you want to create BUILD files using Bazel (eg with Buildifier ), you will need to have a two-step process where you first update the generated BUILD files and then do something with them.

This can work if you don't need to update very often and commit the generated files to your source repository. If you planned on dynamically executing different things on every single build you will need to find a different way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM