gotesplit

package module
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2023 License: MIT Imports: 20 Imported by: 1

README

gotesplit

Test Status MIT License PkgGoDev

gotesplit splits the testng in Go into a subset and run it

Usage

% gotesplit [options] [pkgs...] [-- go-test-arguments...]
Options
-total uint
      total number of test splits (CIRCLE_NODE_TOTAL is used if set) (default 1)
-index uint
      zero-based index number of test splits (CIRCLE_NODE_INDEX is used if set) (default 0)
-junit-dir
       directory to store test result as a JUnit format (optional)
Synopsis
% gotesplit -total=10 -index=0 -- -v -short
go test -v -short -run ^(?:TestAA|TestBB)$

Description

The gotesplit splits the testng in Go into a subset and run it.

It is very useful when you want to run tests in parallel in a CI environment.

Installation

# Install the latest version. (Install it into ./bin/ by default).
% curl -sfL https://raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s

# Specify installation directory ($(go env GOPATH)/bin/) and version.
% curl -sfL https://raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s -- -b $(go env GOPATH)/bin [vX.Y.Z]

# In alpine linux (as it does not come with curl by default)
% wget -O - -q https://raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s [vX.Y.Z]

# go get
% go get github.com/Songmu/gotesplit/cmd/gotesplit

Example

CircleCI

We don't need to specify the -total and -index flag on CircleCI because gotesplit reads the CIRCLE_NODE_TOTAL and CIRCLE_NODE_INDEX environment variables automatically.

    parallelism: 5
    docker:
      - image: circleci/golang:1.15.3
    steps:
      - checkout
      - run:
          command: |
            curl -sfL https://raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s
            bin/gotesplit ./... -- -v
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@v4
      - uses: actions/checkout@v3
      - name: Run tests parallelly
        run: |
          curl -sfL https://raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s
          bin/gotesplit -total ${{ matrix.parallelism }} -index ${{ matrix.index }} ./... -- -v

Author

Songmu

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, argv []string, outStream, errStream io.Writer) error

Run the gotesplit

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL