[engine] Make ctx.os.exec() start background process

... and return an object representing the started process, with a
`wait()` method that will block until the process completes.

This makes it possible to run multiple subprocesses in parallel, which
can drastically speed up checks that require running one subprocess for
every file.

TODOs:
1. The pattern of iterating over all the processes sequentially and
   `wait()`ing on them is not super efficient - more efficient would be
   to implement an `os.ctx.select()` iterator that returns the first
   subprocess to complete. But that's a small optimization and not
   necessary yet. If and when we do implement that, it will likely
   require making `subprocess` objects hashable so they can be used as
   keys in a dict with filenames as values, to look up which file a
   per-file subprocess corresponds to after it completes.
2. Limit the number of subprocesses that can be running concurrently, to
   NumCPU()+2 or so.

Change-Id: I43395e7481685460c5a92e02fba439fecf006c2b
Reviewed-on: https://fuchsia-review.googlesource.com/c/shac-project/shac/+/867676
Reviewed-by: Marc-Antoine Ruel <maruel@google.com>
Commit-Queue: Oliver Newman <olivernewman@google.com>
29 files changed
tree: 744be1ae6ff03e0ae2c1de05a72c610e4e97dfb3
  1. .github/
  2. doc/
  3. images/
  4. internal/
  5. scripts/
  6. .gitignore
  7. AUTHORS
  8. check_doc.star
  9. codecov.yml
  10. CONTRIBUTING.md
  11. go.mod
  12. go.star
  13. go.sum
  14. LICENSE
  15. licenses.star
  16. main.go
  17. OWNERS
  18. PATENTS
  19. README.md
  20. shac.star
  21. shac.textproto
README.md

shac

Shac (Scalable Hermetic Analysis and Checks) is a unified and ergonomic tool and framework for writing and running static analysis checks.

Shac checks are written in Starlark.

usage demonstration

Usage

go install go.fuchsia.dev/shac-project/shac@latest
shac check
shac doc shac.star | less

Documentation

Contributing

⚠ The source of truth is at https://fuchsia.googlesource.com/shac-project/shac.git and uses Gerrit for code review.

See CONTRIBUTING.md to submit changes.