makefont_test.go 616 B

1234567891011121314151617181920212223242526
  1. package main
  2. import (
  3. "os/exec"
  4. "strings"
  5. "testing"
  6. )
  7. func TestMakefont(t *testing.T) {
  8. var out []byte
  9. var err error
  10. const expect = "Font definition file successfully generated"
  11. // Make sure makefont utility has been built before generating font definition file
  12. err = exec.Command("go", "build").Run()
  13. if err != nil {
  14. t.Fatal(err)
  15. }
  16. out, err = exec.Command("./makefont", "--dst=../font", "--embed",
  17. "--enc=../font/cp1252.map", "../font/calligra.ttf").CombinedOutput()
  18. if err != nil {
  19. t.Fatal(err)
  20. }
  21. if !strings.Contains(string(out), expect) {
  22. t.Fatalf("Unexpected output from makefont")
  23. }
  24. }