
テストの会社から来ました

https://www.launchableinc.com/
ただし、このままだと単にフルテストがそれぞれのジョブで走るだけ。
% gotesplit [options] [pkgs...] [-- go-test-arguments...]
% gotesplit -junit-dir=~/junit -total=5 -index=0 ./... -- -v
-- の後に任意の go test のオプションも指定可能% go install github.com/Songmu/gotesplit/cmd/gotesplit@latest
% curl -sfL raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s
version: 2.1
jobs:
test:
parallelism: 5
docker:
- image: golang:1.17.8
steps:
- checkout
- run:
command: |
curl -sfL raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s
bin/gotesplit -junit-dir=~/junit ./... -- -v
- store_test_results:
path: ~/junit
-total や -index 引数は不要。(CIRCLE_NODE_TOTAL 及び CIRCLE_NODE_INDEX を見ている)name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
parallelism: [5]
index: [0,1,2,3,4]
steps:
- uses: actions/setup-go@v2
- uses: actions/checkout@v2
- name: Run tests parallelly
run: |
curl -sfL raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s
bin/gotesplit -total ${{ matrix.parallelism }} -index ${{ matrix.index }} ./... -- -v
go test -list . $pkg でテストケース(関数) 一覧を抽出go test -run に指定する正規表現を組み立てる
^(?:TestAAA|TestBBB|TestCCC)$go test を実行
go test -run '^(?:TestAAA|TestBBB|TestCCC)$'go test には正規表現指定で一部のテストを実行する機能が標準で存在hoge_test.go を複数羅列指定する方法もあるが、好ましくないTestMain や init を動かしてくれない
t.Parallel ではダメなの?t.Parallel 対応は無駄に複雑になる可能性もos.Chdir などは t.Parallel 時に上手く動かない(当たり前)t.Parallel 対応をしなくても単純にテストを分割・分散実行できるとも言える単純なツールとしては完成されている。