Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix go tests #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,26 @@ addons:
env:
- TRAVIS_NODE_VERSION="v7.2.1"

cache:
directories:
- sysconfcpus
- protoc

before_install:
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
- ./install_sysconfcpus
- ./install_protobuf

install:
- ./install_protobuf
- export PATH=$PATH:$PWD/protoc/bin
- go get -t -v ./protoc-gen-elm
- protoc --version
- node --version
- npm --version
- npm install -g elm
- npm install -g elm-test
- mv $(npm config get prefix)/bin/elm-make $(npm config get prefix)/bin/elm-make-old
- printf '%s\n\n' '#!/bin/bash' 'echo "Running elm-make with sysconfcpus -n 2"' '$TRAVIS_BUILD_DIR/sysconfcpus/bin/sysconfcpus -n 2 elm-make-old "$@"' > $(npm config get prefix)/bin/elm-make
- chmod +x $(npm config get prefix)/bin/elm-make

script: ./run_tests
8 changes: 5 additions & 3 deletions install_protobuf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ set -ex
#git clone https://github.com/google/protobuf.git
#cd protobuf && ./autogen.sh && ./configure && make && sudo make install

readonly VERSION='3.3.0'
if [ ! -d protoc/include ]; then
readonly VERSION='3.3.0'

wget https://github.com/google/protobuf/releases/download/v${VERSION}/protoc-${VERSION}-linux-x86_64.zip
unzip ./protoc*.zip -d ./protoc
wget https://github.com/google/protobuf/releases/download/v${VERSION}/protoc-${VERSION}-linux-x86_64.zip
unzip ./protoc*.zip -d ./protoc
fi
13 changes: 13 additions & 0 deletions install_sysconfcpus
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -ex

echo "Install libsysconfcpus to compensate for slow elm builds"
# More at: https://github.com/elm/compiler/issues/1473
if [ ! -d sysconfcpus/bin ]; then
git clone https://github.com/obmarg/libsysconfcpus.git
cd libsysconfcpus
./configure --prefix=$TRAVIS_BUILD_DIR/sysconfcpus
make && make install
cd ..
fi
27 changes: 15 additions & 12 deletions protoc-gen-elm/go_tests/main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
Expand All @@ -21,21 +22,23 @@ func TestDiff(t *testing.T) {
continue
}

dir := filepath.Join(td, fi.Name())
actualOutputDir := filepath.Join(dir, "actual_output")
t.Run(fmt.Sprintf("generating in directory %s", fi.Name()), func (t *testing.T) {
dir := filepath.Join(td, fi.Name())
actualOutputDir := filepath.Join(dir, "actual_output")

err := os.RemoveAll(actualOutputDir)
if err != nil {
t.Fatal(err)
}
err := os.RemoveAll(actualOutputDir)
if err != nil {
t.Fatal(err)
}

err = os.MkdirAll(actualOutputDir, 0777)
if err != nil {
t.Fatal(err)
}
err = os.MkdirAll(actualOutputDir, 0777)
if err != nil {
t.Fatal(err)
}

runProto(t, dir)
runDiff(t, dir)
runProto(t, dir)
runDiff(t, dir)
})
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ firstOneofDecoder : JD.Decoder FirstOneof
firstOneofDecoder =
JD.lazy <| \_ -> JD.oneOf
[ JD.map StringField (JD.field "stringField" JD.string)
, JD.map IntField (JD.field "intField" JD.int)
, JD.map IntField (JD.field "intField" intDecoder)
, JD.succeed FirstOneofUnspecified
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type alias SubMessage =
subMessageDecoder : JD.Decoder SubMessage
subMessageDecoder =
JD.lazy <| \_ -> decode SubMessage
|> required "int32Field" JD.int 0
|> required "int32Field" intDecoder 0


subMessageEncoder : SubMessage -> JE.Value
Expand Down Expand Up @@ -117,21 +117,21 @@ fooDecoder =
JD.lazy <| \_ -> decode Foo
|> required "doubleField" JD.float 0.0
|> required "floatField" JD.float 0.0
|> required "int32Field" JD.int 0
|> required "int64Field" JD.int 0
|> required "uint32Field" JD.int 0
|> required "uint64Field" JD.int 0
|> required "sint32Field" JD.int 0
|> required "sint64Field" JD.int 0
|> required "fixed32Field" JD.int 0
|> required "fixed64Field" JD.int 0
|> required "sfixed32Field" JD.int 0
|> required "sfixed64Field" JD.int 0
|> required "int32Field" intDecoder 0
|> required "int64Field" intDecoder 0
|> required "uint32Field" intDecoder 0
|> required "uint64Field" intDecoder 0
|> required "sint32Field" intDecoder 0
|> required "sint64Field" intDecoder 0
|> required "fixed32Field" intDecoder 0
|> required "fixed64Field" intDecoder 0
|> required "sfixed32Field" intDecoder 0
|> required "sfixed64Field" intDecoder 0
|> required "boolField" JD.bool False
|> required "stringField" JD.string ""
|> required "enumField" enumDecoder enumDefault
|> optional "subMessage" subMessageDecoder
|> repeated "repeatedInt64Field" JD.int
|> repeated "repeatedInt64Field" intDecoder
|> repeated "repeatedEnumField" enumDecoder
|> optional "nestedMessageField" foo_NestedMessageDecoder
|> required "nestedEnumField" foo_NestedEnumDecoder foo_NestedEnumDefault
Expand Down Expand Up @@ -161,20 +161,20 @@ fooEncoder v =
[ (requiredFieldEncoder "doubleField" JE.float 0.0 v.doubleField)
, (requiredFieldEncoder "floatField" JE.float 0.0 v.floatField)
, (requiredFieldEncoder "int32Field" JE.int 0 v.int32Field)
, (requiredFieldEncoder "int64Field" JE.int 0 v.int64Field)
, (requiredFieldEncoder "int64Field" numericStringEncoder 0 v.int64Field)
, (requiredFieldEncoder "uint32Field" JE.int 0 v.uint32Field)
, (requiredFieldEncoder "uint64Field" JE.int 0 v.uint64Field)
, (requiredFieldEncoder "uint64Field" numericStringEncoder 0 v.uint64Field)
, (requiredFieldEncoder "sint32Field" JE.int 0 v.sint32Field)
, (requiredFieldEncoder "sint64Field" JE.int 0 v.sint64Field)
, (requiredFieldEncoder "sint64Field" numericStringEncoder 0 v.sint64Field)
, (requiredFieldEncoder "fixed32Field" JE.int 0 v.fixed32Field)
, (requiredFieldEncoder "fixed64Field" JE.int 0 v.fixed64Field)
, (requiredFieldEncoder "fixed64Field" numericStringEncoder 0 v.fixed64Field)
, (requiredFieldEncoder "sfixed32Field" JE.int 0 v.sfixed32Field)
, (requiredFieldEncoder "sfixed64Field" JE.int 0 v.sfixed64Field)
, (requiredFieldEncoder "sfixed64Field" numericStringEncoder 0 v.sfixed64Field)
, (requiredFieldEncoder "boolField" JE.bool False v.boolField)
, (requiredFieldEncoder "stringField" JE.string "" v.stringField)
, (requiredFieldEncoder "enumField" enumEncoder enumDefault v.enumField)
, (optionalEncoder "subMessage" subMessageEncoder v.subMessage)
, (repeatedFieldEncoder "repeatedInt64Field" JE.int v.repeatedInt64Field)
, (repeatedFieldEncoder "repeatedInt64Field" numericStringEncoder v.repeatedInt64Field)
, (repeatedFieldEncoder "repeatedEnumField" enumEncoder v.repeatedEnumField)
, (optionalEncoder "nestedMessageField" foo_NestedMessageEncoder v.nestedMessageField)
, (requiredFieldEncoder "nestedEnumField" foo_NestedEnumEncoder foo_NestedEnumDefault v.nestedEnumField)
Expand All @@ -201,7 +201,7 @@ type alias Foo_NestedMessage =
foo_NestedMessageDecoder : JD.Decoder Foo_NestedMessage
foo_NestedMessageDecoder =
JD.lazy <| \_ -> decode Foo_NestedMessage
|> required "int32Field" JD.int 0
|> required "int32Field" intDecoder 0


foo_NestedMessageEncoder : Foo_NestedMessage -> JE.Value
Expand All @@ -219,7 +219,7 @@ type alias Foo_NestedMessage_NestedNestedMessage =
foo_NestedMessage_NestedNestedMessageDecoder : JD.Decoder Foo_NestedMessage_NestedNestedMessage
foo_NestedMessage_NestedNestedMessageDecoder =
JD.lazy <| \_ -> decode Foo_NestedMessage_NestedNestedMessage
|> required "int32Field" JD.int 0
|> required "int32Field" intDecoder 0


foo_NestedMessage_NestedNestedMessageEncoder : Foo_NestedMessage_NestedNestedMessage -> JE.Value
Expand Down Expand Up @@ -254,16 +254,16 @@ fooRepeatedDecoder =
JD.lazy <| \_ -> decode FooRepeated
|> repeated "doubleField" JD.float
|> repeated "floatField" JD.float
|> repeated "int32Field" JD.int
|> repeated "int64Field" JD.int
|> repeated "uint32Field" JD.int
|> repeated "uint64Field" JD.int
|> repeated "sint32Field" JD.int
|> repeated "sint64Field" JD.int
|> repeated "fixed32Field" JD.int
|> repeated "fixed64Field" JD.int
|> repeated "sfixed32Field" JD.int
|> repeated "sfixed64Field" JD.int
|> repeated "int32Field" intDecoder
|> repeated "int64Field" intDecoder
|> repeated "uint32Field" intDecoder
|> repeated "uint64Field" intDecoder
|> repeated "sint32Field" intDecoder
|> repeated "sint64Field" intDecoder
|> repeated "fixed32Field" intDecoder
|> repeated "fixed64Field" intDecoder
|> repeated "sfixed32Field" intDecoder
|> repeated "sfixed64Field" intDecoder
|> repeated "boolField" JD.bool
|> repeated "stringField" JD.string
|> repeated "enumField" enumDecoder
Expand All @@ -276,15 +276,15 @@ fooRepeatedEncoder v =
[ (repeatedFieldEncoder "doubleField" JE.float v.doubleField)
, (repeatedFieldEncoder "floatField" JE.float v.floatField)
, (repeatedFieldEncoder "int32Field" JE.int v.int32Field)
, (repeatedFieldEncoder "int64Field" JE.int v.int64Field)
, (repeatedFieldEncoder "int64Field" numericStringEncoder v.int64Field)
, (repeatedFieldEncoder "uint32Field" JE.int v.uint32Field)
, (repeatedFieldEncoder "uint64Field" JE.int v.uint64Field)
, (repeatedFieldEncoder "uint64Field" numericStringEncoder v.uint64Field)
, (repeatedFieldEncoder "sint32Field" JE.int v.sint32Field)
, (repeatedFieldEncoder "sint64Field" JE.int v.sint64Field)
, (repeatedFieldEncoder "sint64Field" numericStringEncoder v.sint64Field)
, (repeatedFieldEncoder "fixed32Field" JE.int v.fixed32Field)
, (repeatedFieldEncoder "fixed64Field" JE.int v.fixed64Field)
, (repeatedFieldEncoder "fixed64Field" numericStringEncoder v.fixed64Field)
, (repeatedFieldEncoder "sfixed32Field" JE.int v.sfixed32Field)
, (repeatedFieldEncoder "sfixed64Field" JE.int v.sfixed64Field)
, (repeatedFieldEncoder "sfixed64Field" numericStringEncoder v.sfixed64Field)
, (repeatedFieldEncoder "boolField" JE.bool v.boolField)
, (repeatedFieldEncoder "stringField" JE.string v.stringField)
, (repeatedFieldEncoder "enumField" enumEncoder v.enumField)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Google.Protobuf.Empty exposing (..)

-- DO NOT EDIT
-- AUTOGENERATED BY THE ELM PROTOCOL BUFFER COMPILER
-- https://github.com/tiziano88/elm-protobuf
-- source file: google/protobuf/empty.proto

import Protobuf exposing (..)

import Json.Decode as JD
import Json.Encode as JE


type alias Empty =
{
}


emptyDecoder : JD.Decoder Empty
emptyDecoder =
JD.lazy <| \_ -> decode Empty


emptyEncoder : Empty -> JE.Value
emptyEncoder v =
JE.object <| List.filterMap identity <|
[
]
Loading