A lightweight mechanism to provide an *instant kickstart* to a Go web server instance upon changing any Go source files under the project directory (and its subdirectories).

syscall_test.go 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2013 The Go 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. // +build darwin dragonfly freebsd linux netbsd openbsd solaris
  5. package unix_test
  6. import (
  7. "fmt"
  8. "testing"
  9. "golang.org/x/sys/unix"
  10. )
  11. func testSetGetenv(t *testing.T, key, value string) {
  12. err := unix.Setenv(key, value)
  13. if err != nil {
  14. t.Fatalf("Setenv failed to set %q: %v", value, err)
  15. }
  16. newvalue, found := unix.Getenv(key)
  17. if !found {
  18. t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value)
  19. }
  20. if newvalue != value {
  21. t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value)
  22. }
  23. }
  24. func TestEnv(t *testing.T) {
  25. testSetGetenv(t, "TESTENV", "AVALUE")
  26. // make sure TESTENV gets set to "", not deleted
  27. testSetGetenv(t, "TESTENV", "")
  28. }
  29. func TestItoa(t *testing.T) {
  30. // Make most negative integer: 0x8000...
  31. i := 1
  32. for i<<1 != 0 {
  33. i <<= 1
  34. }
  35. if i >= 0 {
  36. t.Fatal("bad math")
  37. }
  38. s := unix.Itoa(i)
  39. f := fmt.Sprint(i)
  40. if s != f {
  41. t.Fatalf("itoa(%d) = %s, want %s", i, s, f)
  42. }
  43. }