File: gobuild_test.go

package info (click to toggle)
delve 1.26.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,136 kB
  • sloc: ansic: 111,947; sh: 194; asm: 147; makefile: 43; python: 23
file content (31 lines) | stat: -rw-r--r-- 908 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package gobuild

import (
	"reflect"
	"testing"

	"github.com/go-delve/delve/pkg/config"
)

func TestGoBuildArgsDashC(t *testing.T) {
	testCases := []struct{ in, tgt string }{
		{"-C somedir", "-C somedir -o debug -gcflags 'all=-N -l' pkg"},
		{"-C", "-o debug -gcflags 'all=-N -l' -C pkg"},
		{"-C=somedir", "-C=somedir -o debug -gcflags 'all=-N -l' pkg"},
		{"-C somedir -other -args", "-C somedir -o debug -gcflags 'all=-N -l' -other -args pkg"},
		{"-C=somedir -other -args", "-C=somedir -o debug -gcflags 'all=-N -l' -other -args pkg"},
	}

	for _, tc := range testCases {
		t.Run(tc.in, func(t *testing.T) {
			t.Parallel()

			out := goBuildArgs("debug", []string{"pkg"}, tc.in, false)
			tgt := config.SplitQuotedFields(tc.tgt, '\'')
			t.Logf("%q -> %q", tc.in, out)
			if !reflect.DeepEqual(out, tgt) {
				t.Errorf("output mismatch input %q\noutput %q\ntarget %q", tc.in, out, tgt)
			}
		})
	}
}