androidbp: make error handling stricter

Instead of putting errors into the translated Android.mk file where
they are unlikely to be seen and may cause strange build behavior,
make all errors fatal.  Also buffer to a byte buffer and then write
to the output file once we are sure there are no errors.

Change-Id: I247f405dd0a7c1d14c2681f86c7ac626e035ac2c
This commit is contained in:
Colin Cross
2015-06-29 14:18:27 -07:00
parent 26478b7fc5
commit b093124675
3 changed files with 191 additions and 96 deletions

View File

@@ -1,7 +1,6 @@
package main
import (
"bufio"
"bytes"
"strings"
"testing"
@@ -51,7 +50,10 @@ func TestValueToString(t *testing.T) {
t.Errorf("Failed to read blueprint: %q", errs)
}
str := valueToString(blueprint.Defs[0].(*bpparser.Assignment).Value)
str, err := valueToString(blueprint.Defs[0].(*bpparser.Assignment).Value)
if err != nil {
t.Error(err.Error())
}
expect(t, testCase.blueprint, testCase.expected, str)
}
}
@@ -129,12 +131,14 @@ func TestModules(t *testing.T) {
blueprint: blueprint,
path: "",
mapScope: make(map[string][]*bpparser.Property),
Writer: bufio.NewWriter(buf),
Writer: buf,
}
module := blueprint.Defs[0].(*bpparser.Module)
writer.handleModule(module)
writer.Flush()
err := writer.handleModule(module)
if err != nil {
t.Errorf("Unexpected error %s", err.Error())
}
expect(t, testCase.blueprint, testCase.androidmk, buf.String())
}