github.com/bazelbuild/bazel-watcher@v0.25.2/internal/e2e/error/error_test.go (about) 1 package error 2 3 import ( 4 "testing" 5 6 "github.com/bazelbuild/bazel-watcher/internal/e2e" 7 "github.com/bazelbuild/bazel-watcher/internal/e2e/example_client" 8 ) 9 10 func TestMain(m *testing.M) { 11 example_client.TestMain(m) 12 } 13 14 func TestSimpleBuildWithoutSourceFiles(t *testing.T) { 15 e2e.MustWriteFile(t, "BUILD", ` 16 # Invalid rule due to a missing input file 17 sh_binary( 18 name = "test", 19 srcs = ["test.sh"], 20 ) 21 `) 22 23 ibazel := e2e.SetUp(t) 24 ibazel.Build("//:test") 25 defer ibazel.Kill() 26 27 ibazel.ExpectError("//:test: missing input file '//:test.sh'") 28 } 29 30 func TestSimpleBuildWithQueryFailure(t *testing.T) { 31 e2e.MustWriteFile(t, "BUILD", ` 32 # Invalid rule due to a typo 33 shh_binary( 34 name = "test", 35 srcs = ["test.sh"], 36 ) 37 `) 38 39 ibazel := e2e.SetUp(t) 40 ibazel.Build("//:test") 41 defer ibazel.Kill() 42 43 ibazel.ExpectError("name 'shh_binary' is not defined") 44 } 45 46 func TestExampleClientWhoDies(t *testing.T) { 47 e2e.MustWriteFile(t, "BUILD", ` 48 sh_binary( 49 name = "live_reload", 50 srcs = ["test.sh"], 51 tags = ["ibazel_live_reload"], 52 )`) 53 e2e.MustWriteFile(t, "test.sh", ` 54 echo "hello moto"`) 55 56 ibazel := e2e.SetUp(t) 57 defer ibazel.Kill() 58 ibazel.Run([]string{}, "//:live_reload") 59 60 ibazel.ExpectOutput("hello moto") 61 out := ibazel.GetOutput() 62 t.Logf("Output: '%s'", out) 63 64 if out == "" { 65 t.Fatal("Output was empty. Expected at least some output") 66 } 67 68 e2e.MustWriteFile(t, "test.sh", ` 69 echo "moto hello"`) 70 ibazel.ExpectOutput("moto hello") 71 out = ibazel.GetOutput() 72 t.Logf("Output: '%s'", out) 73 74 if out == "" { 75 t.Fatal("Output was empty. Expected at least some output") 76 } 77 }