Skip to content

Commit

Permalink
Merge pull request #33 from nlamirault/develop
Browse files Browse the repository at this point in the history
Release 0.10.0
  • Loading branch information
nlamirault committed Jan 25, 2016
2 parents ab0da93 + 4ac1fde commit 57f894e
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 9 deletions.
11 changes: 11 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# gotest.el ChangeLog

# Version 0.10.0 (01/25/2016)

- #32: Can't install package in melpa stable
- Refactoring testing current file
- #30: Tests with only tests or examples

# Version 0.9.0 (12/18/2015)

- #30: Remove extra when no examples in file
- Cleanup removing unused hook

# Version 0.8.0 (11/30/2015)

- #25: use -m flag for suite tests (only use -m when length > 0) (thanks IvanMalison)
Expand Down
23 changes: 16 additions & 7 deletions gotest.el
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

;; Author: Nicolas Lamirault <[email protected]>
;; URL: https://github.com/nlamirault/gotest.el
;; Version: 0.9.0
;; Version: 0.10.0
;; Keywords: languages, go, tests

;; Package-Requires: ((emacs "24.3") (s "1.10.0") (f "0.18.0") (go-mode "1.3.1"))
;; Package-Requires: ((emacs "24.3") (s "1.11.0") (f "0.17.3") (go-mode "1.3.1"))

;; Copyright (C) 2014, 2015 Nicolas Lamirault <[email protected]>

Expand Down Expand Up @@ -321,6 +321,19 @@ For example, if the current buffer is `foo.go', the buffer for
(go-test--get-current-file-data "Example"))


(defun go-test--get-current-file-testing-data ()
"Regex with unit test and|or examples."
(let ((tests (go-test--get-current-file-tests))
(examples (go-test--get-current-file-examples)))
(cond ((and (> (length tests) 0)
(> (length examples) 0))
(s-concat tests "|" examples))
((= (length tests) 0)
examples)
((= (length examples) 0)
tests))))


(defun go-test--arguments (args)
"Make the go test command argurments using `ARGS'."
(let ((opts args))
Expand Down Expand Up @@ -436,11 +449,7 @@ For example, if the current buffer is `foo.go', the buffer for
(defun go-test-current-file ()
"Launch go test on the current buffer file."
(interactive)
(let* ((tests (go-test--get-current-file-tests))
(examples (go-test--get-current-file-examples))
(data (if (> (length examples) 0)
(s-concat tests "|" examples)
tests)))
(let ((data (go-test--get-current-file-testing-data)))
(if (go-test--is-gb-project)
(go-test--gb-start (s-concat "-test.v=true -test.run='" data "'"))
(go-test--go-test (s-concat "-run='" data "'")))))
Expand Down
45 changes: 45 additions & 0 deletions test/bar_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package main

import (
"fmt"
"testing"
)

func TestFoo(t *testing.T) {
t.Log("logFoo")
}

func TestBar(t *testing.T) {
t.Log("logBar")
}

func Test_Baz(t *testing.T) {
t.Log("log_Baz")
}

func ExampleA() {
fmt.Println("Example A")
// Output: Example A
}

func ExampleB() {
fmt.Println("Example B")
// Output: Example B
}

func ExampleC() {
fmt.Println("Example C")
// Output: Example C
}

func BenchmarkHello(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Println("hello")
}
}

func BenchmarkHelloWorld(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Println("hello world")
}
}
33 changes: 33 additions & 0 deletions test/foo_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main

import (
"fmt"
"testing"
)

func ExampleA() {
fmt.Println("Example A")
// Output: Example A
}

func ExampleB() {
fmt.Println("Example B")
// Output: Example B
}

func ExampleC() {
fmt.Println("Example C")
// Output: Example C
}

func BenchmarkHello(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Println("hello")
}
}

func BenchmarkHelloWorld(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Println("hello world")
}
}
33 changes: 32 additions & 1 deletion test/gotest-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
;; (concat testsuite-dir "go_test.go")
;; "File name for testing.")


(require 'f)
(require 's)



(defconst testsuite-buffer-name
(f-join go-test-testsuite-dir "go_test.go")
"File name for testing.")
Expand Down Expand Up @@ -127,7 +133,7 @@

;; when current buffer 'go.go', Test names should be found in 'go_test.go'
(ert-deftest test-go-test-get-current-file-tests-other ()
:tags '(find current)
:tags '(find )
(with-test-sandbox
(with-current-buffer (find-file-noselect (f-join go-test-testsuite-dir "go.go"))
(should (string= "TestFoo|TestBar|Test_Baz"
Expand All @@ -141,6 +147,31 @@
(concat go-test-testsuite-dir "no.go"))
(should-error (go-test--get-current-file-tests)))))


(ert-deftest test-go-test-get-current-file-tests-with-only-tests ()
:tags '(find current)
(with-test-sandbox
(with-current-buffer
(find-file-noselect (concat go-test-testsuite-dir "/go_test.go"))
(should (string= "TestFoo|TestBar|Test_Baz"
(go-test--get-current-file-testing-data))))))

(ert-deftest test-go-test-get-current-file-tests-with-only-examples ()
:tags '(find current)
(with-test-sandbox
(with-current-buffer
(find-file-noselect (concat go-test-testsuite-dir "/foo_test.go"))
(should (string= "ExampleA|ExampleB|ExampleC"
(go-test--get-current-file-testing-data))))))

(ert-deftest test-go-test-get-current-file-tests ()
:tags '(find current)
(with-test-sandbox
(with-current-buffer
(find-file-noselect (concat go-test-testsuite-dir "/bar_test.go"))
(should (string= "TestFoo|TestBar|Test_Baz|ExampleA|ExampleB|ExampleC"
(go-test--get-current-file-testing-data))))))

;; Error Regexp

;; (ert-deftest test-go-test-compilation-error-regexp-matches ()
Expand Down
2 changes: 1 addition & 1 deletion test/gotest-version-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
:expected-result (if (executable-find "cask") :passed :failed)
(let* ((cask-version (car (process-lines "cask" "version"))))
(message "gotest.el Cask version: %s" cask-version)
(should (string= "0.9.0" cask-version))))
(should (string= "0.10.0" cask-version))))


(provide 'gotest-version-test)
Expand Down
30 changes: 30 additions & 0 deletions var/bar_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"fmt"
"testing"
)

func TestA(t *testing.T) {
fmt.Println("test a")
}

func TestB(t *testing.T) {
fmt.Println("test b")
}

func TestAB(t *testing.T) {
fmt.Println("test ab")
}

func BenchmarkHello(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Println("hello")
}
}

func BenchmarkHelloWorld(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Println("hello world")
}
}

0 comments on commit 57f894e

Please sign in to comment.