]> Cypherpunks repositories - gostls13.git/commitdiff
doc/codelab/wiki: fixes
authorRuss Cox <rsc@golang.org>
Fri, 28 Jan 2011 14:42:51 +0000 (09:42 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 28 Jan 2011 14:42:51 +0000 (09:42 -0500)
make test.sh runnable as a command.
announce only on 127.0.0.1.
rebuild final-test.bin when final-test.go changes.

R=adg, r
CC=golang-dev
https://golang.org/cl/4030044

doc/codelab/wiki/Makefile
doc/codelab/wiki/get.go
doc/codelab/wiki/test.sh

index eff15cd62d43fe955135e5748c9e8f429baf5a18..0d948ed4b855deb78b751b3843e18a9c6924acef 100644 (file)
@@ -19,6 +19,7 @@ test: get.bin
 
 %.bin: %.$O
        $(LD) -o $@ $<
-%.$O:
+
+%.$O: %.go
        $(GC) $*.go
 
index ff941a34845b8d7d85021f45dc36c4833ff73a66..7c583bda9b5a11b3e741ec0091acc1e471e51bfd 100644 (file)
@@ -13,18 +13,18 @@ import (
 
 var (
        post = flag.String("post", "", "urlencoded form data to POST")
-       port = flag.Bool("port", false, "find open port and print to stdout")
+       addr = flag.Bool("addr", false, "find open address and print to stdout")
 )
 
 func main() {
        flag.Parse()
-       if *port {
+       if *addr {
                l, err := net.Listen("tcp", "127.0.0.1:0")
                if err != nil {
                        log.Exit(err)
                }
                defer l.Close()
-               fmt.Print(l.Addr().(*net.TCPAddr).Port)
+               fmt.Print(l.Addr())
                return
        }
        url := flag.Arg(0)
index fab2b00e7e0d9797c2e9fbf873342098501c78b3..95ff145b9723af196291334430dd072fc33c159e 100755 (executable)
@@ -1,29 +1,27 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
+set -e
 wiki_pid=
-
 cleanup() {
        kill $wiki_pid
        rm -f test_*.out Test.txt final-test.bin final-test.go
-       exit ${1:-1}
 }
-trap cleanup INT
+trap cleanup INT
 
-port=$(./get.bin -port)
-sed s/8080/$port/ < final.go > final-test.go
-gomake final-test.bin || cleanup 1
+gomake get.bin
+addr=$(./get.bin -addr)
+sed s/:8080/$addr/ < final.go > final-test.go
+gomake final-test.bin
 ./final-test.bin &
 wiki_pid=$!
 
 sleep 1
 
-./get.bin http://127.0.0.1:$port/edit/Test > test_edit.out
-diff -u test_edit.out test_edit.good || cleanup 1
-./get.bin -post=body=some%20content http://127.0.0.1:$port/save/Test
-diff -u Test.txt test_Test.txt.good || cleanup 1
-./get.bin http://127.0.0.1:$port/view/Test > test_view.out
-diff -u test_view.out test_view.good || cleanup 1
-
-echo "Passed"
-cleanup 0
+./get.bin http://$addr/edit/Test > test_edit.out
+diff -u test_edit.out test_edit.good
+./get.bin -post=body=some%20content http://$addr/save/Test
+diff -u Test.txt test_Test.txt.good
+./get.bin http://$addr/view/Test > test_view.out
+diff -u test_view.out test_view.good
 
+echo PASS