github.com/hugelgupf/u-root@v0.0.0-20191023214958-4807c632154c/pkg/uroot/builder/bb_test.go (about) 1 // Copyright 2018 the u-root 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 // +build !race 6 7 package builder 8 9 import ( 10 "io/ioutil" 11 "os" 12 "testing" 13 14 "github.com/u-root/u-root/pkg/golang" 15 "github.com/u-root/u-root/pkg/uroot/initramfs" 16 ) 17 18 func TestBBBuild(t *testing.T) { 19 dir, err := ioutil.TempDir("", "u-root") 20 if err != nil { 21 t.Fatal(err) 22 } 23 defer os.RemoveAll(dir) 24 25 opts := Opts{ 26 Env: golang.Default(), 27 Packages: []string{ 28 "github.com/u-root/u-root/pkg/uroot/test/foo", 29 "github.com/u-root/u-root/cmds/core/elvish", 30 }, 31 TempDir: dir, 32 BinaryDir: "bbin", 33 } 34 af := initramfs.NewFiles() 35 var bbb BBBuilder 36 if err := bbb.Build(af, opts); err != nil { 37 t.Error(err) 38 } 39 40 var mustContain = []string{ 41 "bbin/elvish", 42 "bbin/foo", 43 } 44 for _, name := range mustContain { 45 if !af.Contains(name) { 46 t.Errorf("expected files to include %q; archive: %v", name, af) 47 } 48 } 49 50 }