mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-05 09:14:28 +00:00
d17996f8b0
* Update V3 from V4 * Fix build v3 -> v4 * Update ssz * Update beacon_chain.pb.go * Fix formatter import * Update update-mockgen.sh comment to v4 * Fix conflicts. Pass build and tests * Fix test
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
// Copyright 2020 The Cockroach Authors.
|
|
//
|
|
// Use of this software is governed by the Business Source License
|
|
// included in the file licenses/BSL.txt.
|
|
//
|
|
// As of the Change Date specified in that file, in accordance with
|
|
// the Business Source License, use of this software will be governed
|
|
// by the Apache License, Version 2.0, included in the file
|
|
// licenses/APL.txt.
|
|
|
|
package bazel
|
|
|
|
import (
|
|
"path"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/testing/require"
|
|
)
|
|
|
|
// TestDataPath returns a path to an asset in the testdata directory. It knows
|
|
// to access accesses the right path when executing under bazel.
|
|
//
|
|
// For example, if there is a file testdata/a.txt, you can get a path to that
|
|
// file using TestDataPath(t, "a.txt").
|
|
func TestDataPath(t testing.TB, relative ...string) string {
|
|
relative = append([]string{"testdata"}, relative...)
|
|
// dev notifies the library that the test is running in a subdirectory of the
|
|
// workspace with the environment variable below.
|
|
if BuiltWithBazel() {
|
|
runfiles, err := RunfilesPath()
|
|
require.NoError(t, err)
|
|
return path.Join(runfiles, RelativeTestTargetPath(), path.Join(relative...))
|
|
}
|
|
|
|
// Otherwise we're in the package directory and can just return a relative path.
|
|
ret := path.Join(relative...)
|
|
ret, err := filepath.Abs(ret)
|
|
require.NoError(t, err)
|
|
return ret
|
|
}
|