compiler_test.go 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. // Copyright (C) 2018 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. package main
  7. import "testing"
  8. func TestCompilerRe(t *testing.T) {
  9. tests := [][3]string{
  10. {`syncthing v0.11.0 (xgcc (Ubuntu 4.9.3-0ubuntu4) 4.9.3 linux-amd64 default) niklas@Niklas-Netbook 2015-04-26 13:15:08 UTC`, "xgcc (Ubuntu 4.9.3-0ubuntu4) 4.9.3", "niklas@Niklas-Netbook"},
  11. {`syncthing v0.12.0-rc5 "Beryllium Bedbug" (go1.4.2 linux-arm android) unknown-user@Felix-T420 2015-10-22 18:32:15 UTC`, "go1.4.2", "unknown-user@Felix-T420"},
  12. {`syncthing v0.13.0-beta.0+39-ge267bf3 "Copper Cockroach" (go1.4.2 linux-amd64) [email protected] 2016-01-20 08:41:52 UTC`, "go1.4.2", "[email protected]"},
  13. }
  14. for _, tc := range tests {
  15. m := compilerRe.FindStringSubmatch(tc[0])
  16. if len(m) != 3 {
  17. t.Errorf("Regexp didn't match %q", tc[0])
  18. continue
  19. }
  20. if m[1] != tc[1] {
  21. t.Errorf("Compiler %q != %q", m[1], tc[1])
  22. }
  23. if m[2] != tc[2] {
  24. t.Errorf("Builder %q != %q", m[2], tc[2])
  25. }
  26. }
  27. }