MCPcopy
hub / github.com/kubernetes/test-infra / LoadProfile

Function LoadProfile

gopherage/pkg/util/util.go:51–69  ·  view source on GitHub ↗

LoadProfile loads a profile from the given filename. If the filename is "-", it instead reads from stdin.

(origin string)

Source from the content-addressed store, hash-verified

49// LoadProfile loads a profile from the given filename.
50// If the filename is "-", it instead reads from stdin.
51func LoadProfile(origin string) ([]*cover.Profile, error) {
52 filename := origin
53 if origin == "-" {
54 // Annoyingly, ParseProfiles only accepts a filename, so we have to write the bytes to disk
55 // so it can read them back.
56 // We could probably also just give it /dev/stdin, but that'll break on Windows.
57 tf, err := os.CreateTemp("", "")
58 if err != nil {
59 return nil, fmt.Errorf("failed to create temp file: %w", err)
60 }
61 defer tf.Close()
62 defer os.Remove(tf.Name())
63 if _, err := io.Copy(tf, os.Stdin); err != nil {
64 return nil, fmt.Errorf("failed to copy stdin to temp file: %w", err)
65 }
66 filename = tf.Name()
67 }
68 return cover.ParseProfiles(filename)
69}

Callers 6

runFunction · 0.92
runFunction · 0.92
runFunction · 0.92
runFunction · 0.92
runFunction · 0.92
runFunction · 0.92

Calls 2

CopyMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected