pax_global_header00006660000000000000000000000064146007034550014516gustar00rootroot0000000000000052 comment=5491cb3f50916c194d15e6a128759ea435c7d95d assert-2.7.0/000077500000000000000000000000001460070345500130255ustar00rootroot00000000000000assert-2.7.0/.github/000077500000000000000000000000001460070345500143655ustar00rootroot00000000000000assert-2.7.0/.github/FUNDING.yml000066400000000000000000000000251460070345500161770ustar00rootroot00000000000000github: [alecthomas] assert-2.7.0/.github/workflows/000077500000000000000000000000001460070345500164225ustar00rootroot00000000000000assert-2.7.0/.github/workflows/ci.yml000066400000000000000000000010731460070345500175410ustar00rootroot00000000000000on: push: branches: - master pull_request: name: CI jobs: test: name: Test runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Init Hermit run: ./bin/hermit env -r >> $GITHUB_ENV - name: Test run: go test ./... lint: name: Lint runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Init Hermit run: ./bin/hermit env -r >> $GITHUB_ENV - name: golangci-lint run: golangci-lint run assert-2.7.0/.golangci.yml000066400000000000000000000032101460070345500154050ustar00rootroot00000000000000run: tests: true skip-dirs: - _examples output: print-issued-lines: false linters: enable-all: true disable: - maligned - lll - gocyclo - gochecknoglobals - wsl - whitespace - godox - funlen - gocognit - gomnd - goerr113 - godot - nestif - testpackage - nolintlint - exhaustivestruct - wrapcheck - gci - gofumpt - gocritic - nlreturn - errorlint - nakedret - forbidigo - revive - cyclop - ifshort - paralleltest - interfacer - scopelint - golint - wastedassign - forcetypeassert - gomoddirectives - thelper - varnamelen - depguard - exhaustruct - nonamedreturns - varcheck - structcheck - deadcode - nosnakecase linters-settings: govet: check-shadowing: true gocyclo: min-complexity: 10 dupl: threshold: 100 goconst: min-len: 8 min-occurrences: 3 exhaustive: default-signifies-exhaustive: true issues: max-per-linter: 0 max-same: 0 exclude-use-default: false exclude: # Captured by errcheck. - '^(G104|G204|G307):' # Very commonly not checked. - 'Error return value of .(.*\.Help|.*\.MarkFlagRequired|(os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked' - 'exported method `(.*\.MarshalJSON|.*\.UnmarshalJSON|.*\.EntityURN|.*\.GoString|.*\.Pos)` should have comment or be unexported' - 'composite literal uses unkeyed fields' - 'declaration of "err" shadows declaration' - 'bad syntax for struct tag key' - 'bad syntax for struct tag pair' - '^ST1012' assert-2.7.0/COPYING000066400000000000000000000020371460070345500140620ustar00rootroot00000000000000Copyright (C) 2021 Alec Thomas Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. assert-2.7.0/README.md000066400000000000000000000124651460070345500143140ustar00rootroot00000000000000# A simple assertion library using Go generics [![PkgGoDev](https://pkg.go.dev/badge/github.com/alecthomas/assert/v2)](https://pkg.go.dev/github.com/alecthomas/assert/v2) [![CI](https://github.com/alecthomas/assert/actions/workflows/ci.yml/badge.svg)](https://github.com/alecthomas/assert/actions/workflows/ci.yml) [![Go Report Card](https://goreportcard.com/badge/github.com/alecthomas/assert/v2)](https://goreportcard.com/report/github.com/alecthomas/assert/v2) [![Slack chat](https://img.shields.io/static/v1?logo=slack&style=flat&label=slack&color=green&message=gophers)](https://gophers.slack.com/messages/CN9DS8YF3) This library is inspired by testify/require, but with a significantly reduced API surface based on empirical use of that package. It also provides much nicer diff output, eg. ``` === RUN TestFail assert_test.go:14: Expected values to be equal: assert.Data{ - Str: "foo", + Str: "far", Num: 10, } --- FAIL: TestFail (0.00s) ``` ## API Import then use as `assert`: ```go import "github.com/alecthomas/assert/v2" ``` This library has the following API. For all functions, `msgAndArgs` is used to format error messages using the `fmt` package. ```go // Equal asserts that "expected" and "actual" are equal using google/go-cmp. // // If they are not, a diff of the Go representation of the values will be displayed. func Equal[T comparable](t testing.TB, expected, actual T, msgAndArgs ...interface{}) // NotEqual asserts that "expected" is not equal to "actual" using google/go-cmp. // // If they are equal the expected value will be displayed. func NotEqual[T comparable](t testing.TB, expected, actual T, msgAndArgs ...interface{}) // Zero asserts that a value is its zero value. func Zero[T comparable](t testing.TB, value T, msgAndArgs ...interface{}) // NotZero asserts that a value is not its zero value. func NotZero[T comparable](t testing.TB, value T, msgAndArgs ...interface{}) // Contains asserts that "haystack" contains "needle". func Contains(t testing.TB, haystack string, needle string, msgAndArgs ...interface{}) // NotContains asserts that "haystack" does not contain "needle". func NotContains(t testing.TB, haystack string, needle string, msgAndArgs ...interface{}) // EqualError asserts that either an error is non-nil and that its message is what is expected, // or that error is nil if the expected message is empty. func EqualError(t testing.TB, err error, errString string, msgAndArgs...interface{}) // Error asserts that an error is not nil. func Error(t testing.TB, err error, msgAndArgs ...interface{}) // NoError asserts that an error is nil. func NoError(t testing.TB, err error, msgAndArgs ...interface{}) // IsError asserts than any error in "err"'s tree matches "target". func IsError(t testing.TB, err, target error, msgAndArgs ...interface{}) // NotIsError asserts than no error in "err"'s tree matches "target". func NotIsError(t testing.TB, err, target error, msgAndArgs ...interface{}) // Panics asserts that the given function panics. func Panics(t testing.TB, fn func(), msgAndArgs ...interface{}) // NotPanics asserts that the given function does not panic. func NotPanics(t testing.TB, fn func(), msgAndArgs ...interface{}) // Compare two values for equality and return true or false. func Compare[T any](t testing.TB, x, y T) bool // True asserts that an expression is true. func True(t testing.TB, ok bool, msgAndArgs ...interface{}) // False asserts that an expression is false. func False(t testing.TB, ok bool, msgAndArgs ...interface{}) ``` ## Evaluation process Our empircal data of testify usage comes from a monorepo with around 50K lines of tests. These are the usage counts for all testify functions, normalised to the base (not `Printf()`) non-negative(not `No(t)?`) case for each core function. ```text 2240 Error 1314 Equal 219 True 210 Nil 167 Empty 107 Contains 79 Len 61 False 24 EqualValues 20 EqualError 17 Zero 15 Fail 15 ElementsMatch 9 Panics 7 IsType 6 FileExists 4 JSONEq 3 PanicsWithValue 3 Eventually ``` The decision for each function was: ### Keep - `Error(t, err)` -> frequently used, keep - `Equal(t, expected, actual)` -> frequently used, keep but make type safe - `True(t, expr)` -> frequently used, keep - `False(t, expr)` -> frequently used, keep - `Empty(t, thing)` -> `require.Equal(t, len(thing), 0)` - `Contains(t, haystack string, needle string)` - the only variant used in our codebase, keep as concrete type - `Zero(t, value)` -> make type safe, keep - `Panics(t, f)` -> useful, keep - `EqualError(t, a, b)` -> useful, keep - `Nil(t, value)` -> frequently used, keep ### Not keeping, replace with ... - `ElementsMatch(t, a, b)` - use [peterrk/slices](https://github.com/peterrk/slices) or stdlib sort support once it lands. - `IsType(t, a, b)` -> `require.Equal(t, reflect.TypeOf(a).String(), reflect.TypeOf(b).String())` - `FileExists()` -> very little use, drop - `JSONEq()` -> very little use, drop - `PanicsWithValue()` -> very little use, drop - `Eventually()` -> very little use, drop - `Contains(t, haystack []T, needle T)` - very little use, replace with - `Contains(t, haystack map[K]V, needle K)` - very little use, drop - `Len(t, v, n)` -> cannot be implemented as a single function with generics`Equal(t, len(v), n)` - `EqualValues()` - `Equal(t, TYPE(a), TYPE(b))` - `Fail()` -> `t.Fatal()` assert-2.7.0/assert.go000066400000000000000000000211771460070345500146650ustar00rootroot00000000000000// Package assert provides type-safe assertions with clean error messages. package assert import ( "bytes" "errors" "fmt" "reflect" "strconv" "strings" "testing" "github.com/alecthomas/repr" "github.com/hexops/gotextdiff" "github.com/hexops/gotextdiff/myers" ) // A CompareOption modifies how object comparisons behave. type CompareOption func() []repr.Option // Exclude fields of the given type from comparison. func Exclude[T any]() CompareOption { return func() []repr.Option { return []repr.Option{repr.Hide[T]()} } } // OmitEmpty fields from comparison. func OmitEmpty() CompareOption { return func() []repr.Option { return []repr.Option{repr.OmitEmpty(true)} } } // Compare two values for equality and return true or false. func Compare[T any](t testing.TB, x, y T, options ...CompareOption) bool { return objectsAreEqual(x, y, options...) } func extractCompareOptions(msgAndArgs ...any) ([]any, []CompareOption) { compareOptions := []CompareOption{} out := []any{} for _, arg := range msgAndArgs { if opt, ok := arg.(CompareOption); ok { compareOptions = append(compareOptions, opt) } else { out = append(out, arg) } } return out, compareOptions } // Equal asserts that "expected" and "actual" are equal. // // If they are not, a diff of the Go representation of the values will be displayed. func Equal[T any](t testing.TB, expected, actual T, msgArgsAndCompareOptions ...any) { msgArgsAndCompareOptions, compareOptions := extractCompareOptions(msgArgsAndCompareOptions...) if objectsAreEqual(expected, actual, compareOptions...) { return } t.Helper() msg := formatMsgAndArgs("Expected values to be equal:", msgArgsAndCompareOptions...) t.Fatalf("%s\n%s", msg, diff(expected, actual, compareOptions...)) } // NotEqual asserts that "expected" is not equal to "actual". // // If they are equal the expected value will be displayed. func NotEqual[T any](t testing.TB, expected, actual T, msgArgsAndCompareOptions ...any) { msgArgsAndCompareOptions, compareOptions := extractCompareOptions(msgArgsAndCompareOptions...) if !objectsAreEqual(expected, actual, compareOptions...) { return } t.Helper() msg := formatMsgAndArgs("Expected values to not be equal but both were:", msgArgsAndCompareOptions...) t.Fatalf("%s\n%s", msg, repr.String(expected, repr.Indent(" "))) } // Contains asserts that "haystack" contains "needle". func Contains(t testing.TB, haystack string, needle string, msgAndArgs ...any) { if strings.Contains(haystack, needle) { return } t.Helper() msg := formatMsgAndArgs("Haystack does not contain needle.", msgAndArgs...) t.Fatalf("%s\nNeedle: %q\nHaystack: %q\n", msg, needle, haystack) } // NotContains asserts that "haystack" does not contain "needle". func NotContains(t testing.TB, haystack string, needle string, msgAndArgs ...any) { if !strings.Contains(haystack, needle) { return } t.Helper() msg := formatMsgAndArgs("Haystack should not contain needle.", msgAndArgs...) quotedHaystack, quotedNeedle, positions := needlePosition(haystack, needle) t.Fatalf("%s\nNeedle: %s\nHaystack: %s\n %s\n", msg, quotedNeedle, quotedHaystack, positions) } // Zero asserts that a value is its zero value. func Zero[T any](t testing.TB, value T, msgAndArgs ...any) { var zero T if objectsAreEqual(value, zero) { return } val := reflect.ValueOf(value) if (val.Kind() == reflect.Slice || val.Kind() == reflect.Map || val.Kind() == reflect.Array) && val.Len() == 0 { return } t.Helper() msg := formatMsgAndArgs("Expected a zero value but got:", msgAndArgs...) t.Fatalf("%s\n%s", msg, repr.String(value, repr.Indent(" "))) } // NotZero asserts that a value is not its zero value. func NotZero[T any](t testing.TB, value T, msgAndArgs ...any) { var zero T if !objectsAreEqual(value, zero) { val := reflect.ValueOf(value) if !((val.Kind() == reflect.Slice || val.Kind() == reflect.Map || val.Kind() == reflect.Array) && val.Len() == 0) { return } } t.Helper() msg := formatMsgAndArgs("Did not expect the zero value:", msgAndArgs...) t.Fatalf("%s\n%s", msg, repr.String(value)) } // EqualError asserts that either an error is non-nil and that its message is what is expected, // or that error is nil if the expected message is empty. func EqualError(t testing.TB, err error, errString string, msgAndArgs ...any) { if err == nil && errString == "" { return } t.Helper() if err == nil { t.Fatal(formatMsgAndArgs("Expected an error", msgAndArgs...)) } if err.Error() != errString { msg := formatMsgAndArgs("Error message not as expected:", msgAndArgs...) t.Fatalf("%s\n%s", msg, diff(errString, err.Error())) } } // IsError asserts than any error in "err"'s tree matches "target". func IsError(t testing.TB, err, target error, msgAndArgs ...any) { if errors.Is(err, target) { return } t.Helper() t.Fatal(formatMsgAndArgs(fmt.Sprintf("Error tree %+v should contain error %q", err, target), msgAndArgs...)) } // NotIsError asserts than no error in "err"'s tree matches "target". func NotIsError(t testing.TB, err, target error, msgAndArgs ...any) { if !errors.Is(err, target) { return } t.Helper() t.Fatal(formatMsgAndArgs(fmt.Sprintf("Error tree %+v should NOT contain error %q", err, target), msgAndArgs...)) } // Error asserts that an error is not nil. func Error(t testing.TB, err error, msgAndArgs ...any) { if err != nil { return } t.Helper() t.Fatal(formatMsgAndArgs("Expected an error", msgAndArgs...)) } // NoError asserts that an error is nil. func NoError(t testing.TB, err error, msgAndArgs ...any) { if err == nil { return } t.Helper() msg := formatMsgAndArgs("Did not expect an error but got:", msgAndArgs...) t.Fatalf("%s\n%+v", msg, err) } // True asserts that an expression is true. func True(t testing.TB, ok bool, msgAndArgs ...any) { if ok { return } t.Helper() t.Fatal(formatMsgAndArgs("Expected expression to be true", msgAndArgs...)) } // False asserts that an expression is false. func False(t testing.TB, ok bool, msgAndArgs ...any) { if !ok { return } t.Helper() t.Fatal(formatMsgAndArgs("Expected expression to be false", msgAndArgs...)) } // Panics asserts that the given function panics. func Panics(t testing.TB, fn func(), msgAndArgs ...any) { t.Helper() defer func() { if recover() == nil { msg := formatMsgAndArgs("Expected function to panic", msgAndArgs...) t.Fatal(msg) } }() fn() } // NotPanics asserts that the given function does not panic. func NotPanics(t testing.TB, fn func(), msgAndArgs ...any) { t.Helper() defer func() { if err := recover(); err != nil { msg := formatMsgAndArgs("Expected function not to panic", msgAndArgs...) t.Fatalf("%s\nPanic: %v", msg, err) } }() fn() } func diff[T any](before, after T, compareOptions ...CompareOption) string { var lhss, rhss string // Special case strings so we get nice diffs. if l, ok := any(before).(string); ok { lhss = l rhss = any(after).(string) } else { ropts := expandCompareOptions(compareOptions...) lhss = repr.String(before, ropts...) + "\n" rhss = repr.String(after, ropts...) + "\n" } edits := myers.ComputeEdits("a.txt", lhss, rhss) lines := strings.Split(fmt.Sprint(gotextdiff.ToUnified("expected.txt", "actual.txt", lhss, edits)), "\n") if len(lines) < 3 { return "" } return strings.Join(lines[3:], "\n") } func formatMsgAndArgs(dflt string, msgAndArgs ...any) string { if len(msgAndArgs) == 0 { return dflt } format, ok := msgAndArgs[0].(string) if !ok { panic("message argument to assert function must be a fmt string") } return fmt.Sprintf(format, msgAndArgs[1:]...) } func needlePosition(haystack, needle string) (quotedHaystack, quotedNeedle, positions string) { quotedNeedle = strconv.Quote(needle) quotedNeedle = quotedNeedle[1 : len(quotedNeedle)-1] quotedHaystack = strconv.Quote(haystack) rawPositions := strings.ReplaceAll(quotedHaystack, quotedNeedle, strings.Repeat("^", len(quotedNeedle))) for _, rn := range rawPositions { if rn != '^' { positions += " " } else { positions += "^" } } return } func expandCompareOptions(options ...CompareOption) []repr.Option { ropts := []repr.Option{repr.Indent(" ")} for _, option := range options { ropts = append(ropts, option()...) } return ropts } func objectsAreEqual(expected, actual any, options ...CompareOption) bool { if expected == nil || actual == nil { return expected == actual } if exp, eok := expected.([]byte); eok { if act, aok := actual.([]byte); aok { return bytes.Equal(exp, act) } } if exp, eok := expected.(string); eok { if act, aok := actual.(string); aok { return exp == act } } ropts := expandCompareOptions(options...) expectedStr := repr.String(expected, ropts...) actualStr := repr.String(actual, ropts...) return expectedStr == actualStr } assert-2.7.0/assert_test.go000066400000000000000000000120221460070345500157110ustar00rootroot00000000000000package assert import ( "fmt" "os" "testing" ) type Data struct { Str string Num int64 } func TestEqual(t *testing.T) { assertOk(t, "IdenticalStruct", func(t testing.TB) { Equal(t, Data{"expected", 1234}, Data{"expected", 1234}) }) assertOk(t, "Zero length byte arrays", func(t testing.TB) { Equal(t, []byte(""), []byte(nil)) }) assertOk(t, "Identical byte arrays", func(t testing.TB) { Equal(t, []byte{4, 2}, []byte{4, 2}) }) assertOk(t, "Identical numbers", func(t testing.TB) { Equal(t, 42, 42) }) assertFail(t, "DifferentStruct", func(t testing.TB) { Equal(t, Data{"expected\ntext", 1234}, Data{"actual\ntext", 1234}) }) assertFail(t, "Different bytes arrays", func(t testing.TB) { Equal(t, []byte{2, 4}, []byte{4, 2}) }) assertFail(t, "Different numbers", func(t testing.TB) { Equal(t, 42, 43) }) assertOk(t, "Exclude", func(t testing.TB) { Equal(t, Data{Str: "expected", Num: 1234}, Data{Str: "expected"}, Exclude[int64]()) }) } func TestEqualStrings(t *testing.T) { assertFail(t, "IdenticalStrings", func(t testing.TB) { Equal(t, "hello\nworld", "goodbye\nworld") }) } func TestNotEqual(t *testing.T) { assertOk(t, "DifferentFieldValue", func(t testing.TB) { NotEqual(t, Data{"expected", 1234}, Data{"expected", 1235}) }) assertFail(t, "SameValue", func(t testing.TB) { NotEqual(t, Data{"expected", 1234}, Data{"expected", 1234}) }) assertFail(t, "Exclude", func(t testing.TB) { NotEqual(t, Data{Str: "expected", Num: 1234}, Data{Str: "expected"}, Exclude[int64]()) }) } func TestContains(t *testing.T) { assertOk(t, "Found", func(t testing.TB) { Contains(t, "a haystack with a needle in it", "needle") }) assertFail(t, "NotFound", func(t testing.TB) { Contains(t, "a haystack with a needle in it", "screw") }) } func TestNotContains(t *testing.T) { assertOk(t, "NotFound", func(t testing.TB) { NotContains(t, "a haystack with a needle in it", "screw") }) assertFail(t, "Found", func(t testing.TB) { NotContains(t, "a haystack with a needle in it", "needle") }) } func TestEqualError(t *testing.T) { assertOk(t, "SameMessage", func(t testing.TB) { EqualError(t, fmt.Errorf("hello"), "hello") }) assertOk(t, "Nil", func(t testing.TB) { EqualError(t, nil, "") }) assertFail(t, "MessageMismatch", func(t testing.TB) { EqualError(t, fmt.Errorf("hello"), "goodbye") }) } func TestError(t *testing.T) { assertOk(t, "Error", func(t testing.TB) { Error(t, fmt.Errorf("hello")) }) assertFail(t, "Nil", func(t testing.TB) { Error(t, nil) }) } func TestNoError(t *testing.T) { assertOk(t, "Nil", func(t testing.TB) { NoError(t, nil) }) assertFail(t, "Error", func(t testing.TB) { NoError(t, fmt.Errorf("hello")) }) } func TestZero(t *testing.T) { assertOk(t, "Struct", func(t testing.TB) { Zero(t, Data{}) }) assertOk(t, "NilSlice", func(t testing.TB) { var slice []int Zero(t, slice) }) assertFail(t, "NonEmptyStruct", func(t testing.TB) { Zero(t, Data{Str: "str"}) }) assertFail(t, "NonEmptySlice", func(t testing.TB) { slice := []int{1, 2, 3} Zero(t, slice) }) assertOk(t, "ZeroLenSlice", func(t testing.TB) { slice := []int{} Zero(t, slice) }) } func TestNotZero(t *testing.T) { assertOk(t, "PopulatedStruct", func(t testing.TB) { notZero := Data{Str: "hello"} NotZero(t, notZero) }) assertFail(t, "EmptyStruct", func(t testing.TB) { zero := Data{} NotZero(t, zero) }) assertFail(t, "NilSlice", func(t testing.TB) { var slice []int NotZero(t, slice) }) assertFail(t, "ZeroLenSlice", func(t testing.TB) { slice := []int{} NotZero(t, slice) }) assertOk(t, "Slice", func(t testing.TB) { slice := []int{1, 2, 3} NotZero(t, slice) }) } func TestIsError(t *testing.T) { assertOk(t, "SameError", func(t testing.TB) { IsError(t, fmt.Errorf("os error: %w", os.ErrClosed), os.ErrClosed) }) assertFail(t, "DifferentError", func(t testing.TB) { IsError(t, fmt.Errorf("not an os error"), os.ErrClosed) }) } func TestInvalidFormatMsg(t *testing.T) { Panics(t, func() { NotZero(t, Data{}, 123) }) } func TestNotIsError(t *testing.T) { assertFail(t, "SameError", func(t testing.TB) { NotIsError(t, fmt.Errorf("os error: %w", os.ErrClosed), os.ErrClosed) }) assertOk(t, "DifferentError", func(t testing.TB) { NotIsError(t, fmt.Errorf("not an os error"), os.ErrClosed) }) } type testTester struct { *testing.T failed string } func (t *testTester) Fatalf(message string, args ...interface{}) { t.failed = fmt.Sprintf(message, args...) } func (t *testTester) Fatal(args ...interface{}) { t.failed = fmt.Sprint(args...) } func assertFail(t *testing.T, name string, fn func(t testing.TB)) { t.Helper() t.Run(name, func(t *testing.T) { t.Helper() tester := &testTester{T: t} fn(tester) if tester.failed == "" { t.Fatal("Should have failed") } else { t.Log(tester.failed) } }) } func assertOk(t *testing.T, name string, fn func(t testing.TB)) { t.Helper() t.Run(name, func(t *testing.T) { t.Helper() tester := &testTester{T: t} fn(tester) if tester.failed != "" { t.Fatal("Should not have failed with:\n", tester.failed) } }) } assert-2.7.0/bin/000077500000000000000000000000001460070345500135755ustar00rootroot00000000000000assert-2.7.0/bin/.go-1.20.5.pkg000077700000000000000000000000001460070345500167122hermitustar00rootroot00000000000000assert-2.7.0/bin/.golangci-lint-1.53.2.pkg000077700000000000000000000000001460070345500210372hermitustar00rootroot00000000000000assert-2.7.0/bin/README.hermit.md000066400000000000000000000004161460070345500163440ustar00rootroot00000000000000# Hermit environment This is a [Hermit](https://github.com/cashapp/hermit) bin directory. The symlinks in this directory are managed by Hermit and will automatically download and install Hermit itself as well as packages. These packages are local to this environment. assert-2.7.0/bin/activate-hermit000077500000000000000000000010621460070345500166100ustar00rootroot00000000000000#!/bin/bash # This file must be used with "source bin/activate-hermit" from bash or zsh. # You cannot run it directly if [ "${BASH_SOURCE-}" = "$0" ]; then echo "You must source this script: \$ source $0" >&2 exit 33 fi BIN_DIR="$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}")" if "${BIN_DIR}/hermit" noop > /dev/null; then eval "$("${BIN_DIR}/hermit" activate "${BIN_DIR}/..")" if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ]; then hash -r 2>/dev/null fi echo "Hermit environment $("${HERMIT_ENV}"/bin/hermit env HERMIT_ENV) activated" fi assert-2.7.0/bin/go000077700000000000000000000000001460070345500160272.go-1.20.5.pkgustar00rootroot00000000000000assert-2.7.0/bin/go-main-stubs000077500000000000000000000017431460070345500162150ustar00rootroot00000000000000#!/bin/bash # # # This script generates stub scripts for every Go "main" package in this # repository. These stubs execute the corresponding main package via "go run". # set -euo pipefail usage() { echo "$(basename $0) [-c] -- create or clean Go main stub scripts" exit 1 } bindir="$(dirname $0)" root="$(dirname "${bindir}")" clean() { grep -l "^# go-main-stubs stub script" "${bindir}"/* | grep -v bin/go-main-stubs | xargs rm || true } while getopts ":hc" arg; do case $arg in c) echo "Cleaning old stubs" clean exit 0 ;; h | *) usage exit 0 ;; esac done clean echo "Creating Go main stubs in ${bindir}" echo -n . for main in $(cd "${root}" && go list -f '{{if eq "main" .Name}}{{.ImportPath}}{{end}}' ./...); do stub_script="${bindir}/$(basename $main)" cat << EOF > ${stub_script} #!/bin/bash # go-main-stubs stub script exec "\$(dirname \$0)/go" run $main "\$@" EOF chmod +x "${stub_script}" echo -n . done echo assert-2.7.0/bin/gofmt000077700000000000000000000000001460070345500165362.go-1.20.5.pkgustar00rootroot00000000000000assert-2.7.0/bin/golangci-lint000077700000000000000000000000001460070345500222762.golangci-lint-1.53.2.pkgustar00rootroot00000000000000assert-2.7.0/bin/hermit000077500000000000000000000013611460070345500150140ustar00rootroot00000000000000#!/bin/bash set -eo pipefail if [ -z "${HERMIT_STATE_DIR}" ]; then case "$(uname -s)" in Darwin) export HERMIT_STATE_DIR="${HOME}/Library/Caches/hermit" ;; Linux) export HERMIT_STATE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/hermit" ;; esac fi export HERMIT_DIST_URL="${HERMIT_DIST_URL:-https://github.com/cashapp/hermit/releases/download/stable}" HERMIT_CHANNEL="$(basename "${HERMIT_DIST_URL}")" export HERMIT_CHANNEL export HERMIT_EXE=${HERMIT_EXE:-${HERMIT_STATE_DIR}/pkg/hermit@${HERMIT_CHANNEL}/hermit} if [ ! -x "${HERMIT_EXE}" ]; then echo "Bootstrapping ${HERMIT_EXE} from ${HERMIT_DIST_URL}" 1>&2 curl -fsSL "${HERMIT_DIST_URL}/install.sh" | /bin/bash 1>&2 fi exec "${HERMIT_EXE}" --level=fatal exec "$0" -- "$@" assert-2.7.0/bin/hermit.hcl000066400000000000000000000000001460070345500155430ustar00rootroot00000000000000assert-2.7.0/go.mod000066400000000000000000000002051460070345500141300ustar00rootroot00000000000000module github.com/alecthomas/assert/v2 go 1.18 require ( github.com/alecthomas/repr v0.4.0 github.com/hexops/gotextdiff v1.0.3 ) assert-2.7.0/go.sum000066400000000000000000000005321460070345500141600ustar00rootroot00000000000000github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=