golang.org/x/build@v0.0.0-20240506185731-218518f32b70/internal/installer/windowsmsi/windowsmsi_test.go (about) 1 // Copyright 2023 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package windowsmsi 6 7 import ( 8 "context" 9 "flag" 10 "os" 11 "path/filepath" 12 "testing" 13 ) 14 15 var ( 16 inFlag = flag.String("in", "", "Path to the .tar.gz archive containing a built Go toolchain.") 17 outFlag = flag.String("out", filepath.Join(os.TempDir(), "out.msi"), "Path where to write out the result.") 18 ) 19 20 func TestConstructInstaller(t *testing.T) { 21 if *inFlag == "" || *outFlag == "" { 22 t.Skip("skipping manual test since -in/-out flags are not set") 23 } 24 25 out, err := ConstructInstaller(context.Background(), t.TempDir(), *inFlag, InstallerOptions{ 26 GOARCH: "amd64", 27 }) 28 if err != nil { 29 t.Fatal("ConstructInstaller:", err) 30 } 31 if err := os.Rename(out, *outFlag); err != nil { 32 t.Fatal("moving result to output location failed:", err) 33 } 34 t.Log("constructed installer at:", *outFlag) 35 } 36 37 func TestSplitVersion(t *testing.T) { 38 // Test splitVersion. 39 for _, tc := range [...]struct { 40 v string 41 major, minor int 42 }{ 43 {"go1.34.0", 34, 0}, 44 {"go1.34.7", 34, 7}, 45 {"go1.35rc1", 35, 0}, 46 } { 47 major, minor, err := splitVersion(tc.v) 48 if err != nil { 49 t.Errorf("splitVersion(%q) returned error %v; want nil", tc.v, err) 50 continue 51 } 52 if major != tc.major || minor != tc.minor { 53 t.Errorf("splitVersion(%q) = %v, %v; want %v, %v", tc.v, major, minor, tc.major, tc.minor) 54 } 55 } 56 }