From b30e0090cb2af3d6039232bef6fc73dfdfd43b1b Mon Sep 17 00:00:00 2001 From: Anthony HAMON Date: Tue, 4 Sep 2018 19:31:36 +0200 Subject: [PATCH 1/2] ghokin/transformer : add missing extra new line when formatting --- cmd/fmt_replace_test.go | 6 ++++-- cmd/fmt_stdout.go | 2 +- ghokin/file_manager_test.go | 23 +++++++++++++++-------- ghokin/transformer.go | 2 +- ghokin/transformer_test.go | 8 ++++---- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/cmd/fmt_replace_test.go b/cmd/fmt_replace_test.go index 4c12a07..ad5ff01 100644 --- a/cmd/fmt_replace_test.go +++ b/cmd/fmt_replace_test.go @@ -64,7 +64,8 @@ func TestFormatAndReplace(t *testing.T) { b1Expected := `Feature: Test Test Scenario: Scenario1 - Given a test` + Given a test +` assert.EqualValues(t, b1Expected, string(b1)) @@ -75,7 +76,8 @@ func TestFormatAndReplace(t *testing.T) { b2Expected := `Feature: Test Test Scenario: Scenario2 - Given a test` + Given a test +` assert.EqualValues(t, b2Expected, string(b2)) } diff --git a/cmd/fmt_stdout.go b/cmd/fmt_stdout.go index a298817..089ea3a 100644 --- a/cmd/fmt_stdout.go +++ b/cmd/fmt_stdout.go @@ -21,7 +21,7 @@ func formatOnStdout(msgHandler messageHandler, cmd *cobra.Command, args []string msgHandler.errorFatal(err) } - msgHandler.print("%s\n", output.String()) + msgHandler.print("%s", output.String()) } func init() { diff --git a/ghokin/file_manager_test.go b/ghokin/file_manager_test.go index 26454e7..5024c9b 100644 --- a/ghokin/file_manager_test.go +++ b/ghokin/file_manager_test.go @@ -23,7 +23,7 @@ func TestFileManagerTransform(t *testing.T) { b, e := ioutil.ReadFile("fixtures/file1.feature") assert.NoError(t, e) - assert.EqualValues(t, string(b[:len(b)-1]), buf.String()) + assert.EqualValues(t, string(b), buf.String()) }, }, { @@ -84,7 +84,8 @@ hello world Then whatever """ hello world - """` + """ +` b, e := ioutil.ReadFile("/tmp/ghokin/file1.feature") @@ -104,7 +105,8 @@ Scenario: scenario%d Then whatever """ hello world -"""`) +""" +`) assert.NoError(t, os.RemoveAll("/tmp/ghokin")) assert.NoError(t, os.MkdirAll("/tmp/ghokin", 0777)) @@ -133,7 +135,8 @@ hello world Then whatever """ hello world - """` + """ +` for i, f := range []string{ "/tmp/ghokin/file1.feature", @@ -162,7 +165,8 @@ Scenario: scenario Then whatever """ hello world -"""`) +""" +`) assert.NoError(t, os.RemoveAll("/tmp/ghokin")) assert.NoError(t, os.MkdirAll("/tmp/ghokin", 0777)) @@ -210,7 +214,8 @@ Scenario: scenario Then whatever """ hello world -"""`) +""" +`) assert.NoError(t, os.RemoveAll("/tmp/ghokin")) assert.NoError(t, os.MkdirAll("/tmp/ghokin", 0777)) @@ -230,7 +235,8 @@ hello world Then whatever """ hello world - """` + """ +` contentUnformatted := `Feature: test test @@ -240,7 +246,8 @@ Scenario: scenario Then whatever """ hello world -"""` +""" +` for _, s := range []struct { filename string diff --git a/ghokin/transformer.go b/ghokin/transformer.go index 1c01670..73001b5 100644 --- a/ghokin/transformer.go +++ b/ghokin/transformer.go @@ -118,7 +118,7 @@ func transform(section *section, indentConf indent, aliases aliases) (bytes.Buff func buildBuffer(document []string) (bytes.Buffer, error) { var buf bytes.Buffer - if _, err := buf.WriteString(strings.Join(document, "\n")); err != nil { + if _, err := buf.WriteString(strings.Join(document, "\n") + "\n"); err != nil { return bytes.Buffer{}, err } diff --git a/ghokin/transformer_test.go b/ghokin/transformer_test.go index 7250565..94e0e40 100644 --- a/ghokin/transformer_test.go +++ b/ghokin/transformer_test.go @@ -419,7 +419,7 @@ func TestTransform(t *testing.T) { b, e := ioutil.ReadFile("fixtures/file1.feature") assert.NoError(t, e) - assert.EqualValues(t, string(b[:len(b)-1]), buf.String()) + assert.EqualValues(t, string(b), buf.String()) }, }, { @@ -430,7 +430,7 @@ func TestTransform(t *testing.T) { b, e := ioutil.ReadFile("fixtures/cmd.expected.feature") assert.NoError(t, e) - assert.EqualValues(t, string(b[:len(b)-1]), buf.String()) + assert.EqualValues(t, string(b), buf.String()) }, }, { @@ -441,7 +441,7 @@ func TestTransform(t *testing.T) { b, e := ioutil.ReadFile("fixtures/multisize-table.expected.feature") assert.NoError(t, e) - assert.EqualValues(t, string(b[:len(b)-1]), buf.String()) + assert.EqualValues(t, string(b), buf.String()) }, }, { @@ -452,7 +452,7 @@ func TestTransform(t *testing.T) { b, e := ioutil.ReadFile("fixtures/docstring-empty.expected.feature") assert.NoError(t, e) - assert.EqualValues(t, string(b[:len(b)-1]), buf.String()) + assert.EqualValues(t, string(b), buf.String()) }, }, } From bc5112e09b18559ceb3373375acfdaa64ee31b34 Mon Sep 17 00:00:00 2001 From: Anthony HAMON Date: Tue, 4 Sep 2018 19:37:16 +0200 Subject: [PATCH 2/2] root : add missing compile step --- .circleci/config.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c534eb0..541cf30 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,19 +9,14 @@ jobs: steps: - checkout - run: - name: Get doc-hunt binary + name: Install dependencies command: | mkdir /home/circleci/bin wget -O ~/bin/doc-hunt https://github.com/antham/doc-hunt/releases/download/v2.1.1/doc-hunt_linux_amd64 && chmod 777 ~/bin/doc-hunt - - run: - name: Get gommit binary - command: | wget -O ~/bin/gommit https://github.com/antham/gommit/releases/download/v2.1.1/gommit_linux_386 && chmod 777 ~/bin/gommit - - run: - name: Install dep and gometalinter - command: | go get -u github.com/golang/dep/cmd/dep go get github.com/alecthomas/gometalinter + go get -u github.com/mitchellh/gox gometalinter --install --update - run: name: Install vendors @@ -35,6 +30,10 @@ jobs: name: Run tests command: | make run-tests + - run: + name: Compile + command: | + gox -output "build/{{.Dir}}_{{.OS}}_{{.Arch}}" - run: name: Run gommit command: |