Skip to content

go-splittestgen splits test cases into some subsets and print commands to run one of subsets for parallel testing.

License

Notifications You must be signed in to change notification settings

minoritea/go-splittestgen

 
 

Repository files navigation

go-splittestgen

[MIT License][license]

go-splittestgen splits test cases into some subsets and print commands to run one of subsets for parallel testing.

Usage

go-splittestgen is parsing output of go test -list from stdin(in the usual case, it is piped), dividing test cases into some groups by a number, and then printing a command or commands to execute one of the divided test groups indicated by an index number.

if you want to run the generated test commands immediately, just pipe them to a shell.

# print test commands
$ go test ./... -list . | go-splittestgen -total 3 -index 2

# execute tests
$ go test ./... -list . | go-splittestgen -total 3 -index 2 | sh

Options

  -index uint
        index of test processes (default 0, must be less than the total number)
  -total uint
        total number of test processes (default 1)

Installation

# go install
$ go install github.com/minoritea/go-splittestgen/cmd/go-splittestgen
# or just run
$ go test ./... -list . | go run github.com/minoritea/go-splittestgen/cmd/go-splittestgen

Example

GitHub Actions

name: CI
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        parallelism: [3]
        index: [0,1,2]
    steps:
      - uses: actions/setup-go@v2
      - uses: actions/checkout@v2
      # Add github.com/minoritea/go-splittestgen to go.mod before CI.
      - name: Run tests in parallel
        run: |
          go mod download
          go test ./... -list . | \
          go run github.com/minoritea/go-splittestgen/cmd/go-splittestgen \
            -total ${{ matrix.parallelism }} \
            -index ${{ matrix.index }} | \
          sed -e 's/$/ -v -count 1/g' | sh

Author

minoritea

Original Author

Songmu

About

go-splittestgen splits test cases into some subsets and print commands to run one of subsets for parallel testing.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%