Skip to content

Commit

Permalink
Build using the go tool instead of Makefiles, upgraded to Go weekly…
Browse files Browse the repository at this point in the history
….2012-02-07
  • Loading branch information
luontola committed Feb 14, 2012
1 parent 3fee6c9 commit 903b32e
Show file tree
Hide file tree
Showing 31 changed files with 50 additions and 177 deletions.
6 changes: 1 addition & 5 deletions .gitignore
@@ -1,5 +1 @@
6.out
*.6
_obj
_test
_testmain.go
/pkg/
46 changes: 20 additions & 26 deletions README.md
Expand Up @@ -17,42 +17,35 @@ First you must have Go installed on your machine, as instructed in [Installing G

### Install and Update

Checkout GoSpec's source code from its Git repository and install it. The `release` branch is checked out by default. The `make install` command will copy the compiled GoSpec library into your `$GOROOT/pkg` directory, so that it can be used from other projects.
Download GoSpec using the `go get` tool:

git clone git://github.com/orfjackal/gospec.git
cd gospec/src
make install
go get "github.com/orfjackal/gospec/src/gospec"

When new versions of GoSpec are released, you can update it by pulling the latest version (from the `release` branch) and then installing it as above.

git pull
make install
See `go help get` for more instructions on using the tool.

See "Version History" for any additional upgrade notes.

(If you want to develop GoSpec and run its tests with `make test`, you must first install GoSpec's bootstrap testing framework, [NanoSpec.go](http://github.com/orfjackal/nanospec.go), but regular users of GoSpec don't need to install it.)


### Sample Project

Make a copy of the [hello-world-template] directory to get started. You can run its tests with the command `make test`. All production files must be listed in `Makefile`, all test files must end with `_test.go` and all specs must be listed in `all_specs_test.go`.
Make a copy of the [hello-world-template] directory to get started. You can run its tests with the `go test` command. All test files must end with `_test.go` and all specs must be listed in `all_specs_test.go`.


### Running Specs

You can use the [gotest command](http://golang.org/cmd/gotest/) to run GoSpec's specs. The integration with gotest requires a couple of lines of boilerplate: you'll need to write a gotest test method, where you list all your specs and call GoSpec. See [all_specs_test.go] in the [examples] directory for an example. Also all your specs must be in files whose names end with `_test.go`.
You can use the `go test` command to run GoSpec's specs. The integration with gotest requires a couple of lines of boilerplate: you'll need to write a gotest test method, where you list all your specs and call GoSpec. See [all_specs_test.go] in the [examples] directory for an example. Also all your specs must be in files whose names end with `_test.go`.

See [gotest's documentation](http://golang.org/doc/code.html#Testing) for instructions on how to use gotest.

GoSpec adds one additional parameter to gotest. Use the `-print-all` parameter to print a list of all specs (either `gotest -print-all` or run the binary generated by gotest: `./6.out -print-all`). By default only the failing specs are printed. The list of all specs can be useful as documentation.
GoSpec adds one additional parameter to gotest. Use the `-print-all` parameter to print a list of all specs: `go test -print-all` Otherwise only the failing specs are printed. The list of all specs can be useful as documentation.


### Writing Specs

The following imports are needed. The first imports the `gospec.Context` interface and the second is needed for using GoSpec's expectation matchers (`Equals`, `IsTrue`, `IsNil`, `Not()`, `Contains` etc.) without having to prefix them with the package name. (In a future GoSpec version the matchers will be moved to their own package.)

import "gospec"
import . "gospec"
import "github.com/orfjackal/gospec/src/gospec"
import . "github.com/orfjackal/gospec/src/gospec"

The specs are written as functions which take `gospec.Context` as a parameter. You can call the methods of `Context` to declare expectations and nested specs.

Expand All @@ -69,23 +62,24 @@ For examples on how to write specs, see the files in the [examples] directory.
<!---
Replace /master/ with /gospec-1.x.x/ before making a release.
-->
[hello-world-template]: http://github.com/orfjackal/gospec/tree/master/hello-world-template/
[examples]: http://github.com/orfjackal/gospec/tree/master/examples/
[all_specs_test.go]: http://github.com/orfjackal/gospec/blob/master/examples/all_specs_test.go
[fib.go]: http://github.com/orfjackal/gospec/blob/master/examples/fib.go
[fib_test.go]: http://github.com/orfjackal/gospec/blob/master/examples/fib_test.go
[stack.go]: http://github.com/orfjackal/gospec/blob/master/examples/stack.go
[stack_test.go]: http://github.com/orfjackal/gospec/blob/master/examples/stack_test.go
[expectation_syntax_test.go]: http://github.com/orfjackal/gospec/blob/master/examples/expectation_syntax_test.go
[execution_model_test.go]: http://github.com/orfjackal/gospec/blob/master/examples/execution_model_test.go
[hello-world-template]: http://github.com/orfjackal/gospec/tree/master/src/hello-world-template/
[examples]: http://github.com/orfjackal/gospec/tree/master/src/examples/
[all_specs_test.go]: http://github.com/orfjackal/gospec/blob/master/src/examples/all_specs_test.go
[fib.go]: http://github.com/orfjackal/gospec/blob/master/src/examples/fib.go
[fib_test.go]: http://github.com/orfjackal/gospec/blob/master/src/examples/fib_test.go
[stack.go]: http://github.com/orfjackal/gospec/blob/master/src/examples/stack.go
[stack_test.go]: http://github.com/orfjackal/gospec/blob/master/src/examples/stack_test.go
[expectation_syntax_test.go]: http://github.com/orfjackal/gospec/blob/master/src/examples/expectation_syntax_test.go
[execution_model_test.go]: http://github.com/orfjackal/gospec/blob/master/src/examples/execution_model_test.go


Version History
---------------

**1.x.x (2011-xx-xx)**

- Upgraded to Go weekly.2012-01-27
- Build using the `go` tool instead of Makefiles
- Upgraded to Go weekly.2012-02-07

**1.3.8 (2011-08-04)**

Expand Down Expand Up @@ -180,6 +174,6 @@ The following are *nice-to-haves*, which make it more pleasant to use the framew
License
-------

Copyright © 2009-2011 Esko Luontola <<http://www.orfjackal.net>>
Copyright © 2009-2012 Esko Luontola <<http://www.orfjackal.net>>
This software is released under the Apache License 2.0.
The license text is at <http://www.apache.org/licenses/LICENSE-2.0>
10 changes: 0 additions & 10 deletions examples/Makefile

This file was deleted.

8 changes: 0 additions & 8 deletions hello-world-template/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion src/Make.deps

This file was deleted.

44 changes: 0 additions & 44 deletions src/Makefile

This file was deleted.

37 changes: 0 additions & 37 deletions src/deps.bash

This file was deleted.

Expand Up @@ -5,7 +5,7 @@
package examples

import (
"gospec"
"github.com/orfjackal/gospec/src/gospec"
"testing"
)

Expand Down
Expand Up @@ -5,8 +5,8 @@
package examples

import (
"gospec"
. "gospec"
"github.com/orfjackal/gospec/src/gospec"
. "github.com/orfjackal/gospec/src/gospec"
"strings"
)

Expand Down
Expand Up @@ -6,8 +6,8 @@ package examples

import (
"container/list"
"gospec" // the "gospec.Context" interface
. "gospec" // the expectation matchers (Equals, IsTrue etc.), will later be renamed to "gospec/matchers"
"github.com/orfjackal/gospec/src/gospec" // the "gospec.Context" interface
. "github.com/orfjackal/gospec/src/gospec" // the expectation matchers (Equals, IsTrue etc.), will later be renamed to "gospec/matchers"
"os"
)

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/fib_test.go → src/examples/fib_test.go
Expand Up @@ -5,8 +5,8 @@
package examples

import (
"gospec"
. "gospec"
"github.com/orfjackal/gospec/src/gospec"
. "github.com/orfjackal/gospec/src/gospec"
)

// The specs should read like a specification. The spec names in this example
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/stack_test.go → src/examples/stack_test.go
Expand Up @@ -5,8 +5,8 @@
package examples

import (
"gospec"
. "gospec"
"github.com/orfjackal/gospec/src/gospec"
. "github.com/orfjackal/gospec/src/gospec"
)

// This is the style that I've found the most useful in organizing tests.
Expand Down
23 changes: 0 additions & 23 deletions src/gospec/Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion src/gospec/all_specs_test.go
Expand Up @@ -5,7 +5,7 @@
package gospec

import (
"nanospec"
"github.com/orfjackal/nanospec.go/src/nanospec"
"testing"
)

Expand Down
2 changes: 1 addition & 1 deletion src/gospec/concurrency_test.go
Expand Up @@ -6,7 +6,7 @@ package gospec

import (
"math"
"nanospec"
"github.com/orfjackal/nanospec.go/src/nanospec"
"time"
)

Expand Down
2 changes: 1 addition & 1 deletion src/gospec/context_test.go
Expand Up @@ -5,7 +5,7 @@
package gospec

import (
"nanospec"
"github.com/orfjackal/nanospec.go/src/nanospec"
)

func ContextSpec(c nanospec.Context) {
Expand Down
2 changes: 1 addition & 1 deletion src/gospec/execution_model_test.go
Expand Up @@ -5,7 +5,7 @@
package gospec

import (
"nanospec"
"github.com/orfjackal/nanospec.go/src/nanospec"
"sort"
)

Expand Down
2 changes: 1 addition & 1 deletion src/gospec/expectations_test.go
Expand Up @@ -5,7 +5,7 @@
package gospec

import (
"nanospec"
"github.com/orfjackal/nanospec.go/src/nanospec"
)

func ExpectationsSpec(c nanospec.Context) {
Expand Down
2 changes: 1 addition & 1 deletion src/gospec/funcname_test.go
Expand Up @@ -5,7 +5,7 @@
package gospec

import (
"nanospec"
"github.com/orfjackal/nanospec.go/src/nanospec"
"strings"
)

Expand Down
2 changes: 1 addition & 1 deletion src/gospec/location_test.go
Expand Up @@ -5,7 +5,7 @@
package gospec

import (
"nanospec"
"github.com/orfjackal/nanospec.go/src/nanospec"
"runtime"
)

Expand Down
2 changes: 1 addition & 1 deletion src/gospec/matchers_test.go
Expand Up @@ -9,7 +9,7 @@ import (
"errors"
"fmt"
"math"
"nanospec"
"github.com/orfjackal/nanospec.go/src/nanospec"
"os"
)

Expand Down
2 changes: 1 addition & 1 deletion src/gospec/printer_test.go
Expand Up @@ -6,7 +6,7 @@ package gospec

import (
"bytes"
"nanospec"
"github.com/orfjackal/nanospec.go/src/nanospec"
"strings"
)

Expand Down
2 changes: 1 addition & 1 deletion src/gospec/recover_test.go
Expand Up @@ -5,7 +5,7 @@
package gospec

import (
"nanospec"
"github.com/orfjackal/nanospec.go/src/nanospec"
)

func boom2() {
Expand Down
2 changes: 1 addition & 1 deletion src/gospec/results_test.go
Expand Up @@ -7,7 +7,7 @@ package gospec
import (
"bytes"
"errors"
"nanospec"
"github.com/orfjackal/nanospec.go/src/nanospec"
"strings"
)

Expand Down
6 changes: 6 additions & 0 deletions src/gospec/test.sh
@@ -0,0 +1,6 @@
#!/bin/sh
set -e

# Must disable inlining, or tests will fail because of stack traces
# not containing the innermost method call.
GCFLAGS="-l" go test
@@ -1,7 +1,7 @@
package hello

import (
"gospec"
"github.com/orfjackal/gospec/src/gospec"
"testing"
)

Expand Down
File renamed without changes.

0 comments on commit 903b32e

Please sign in to comment.