#!/bin/bash # fail out of the script if anything here fails set -e # set the path to the present working directory export GOPATH=$[pwd] proc git_clone { global path := $1 global branch := $2 global version := $3 if test ! -d "src/$path" { mkdir -p src/$path git clone https://$path.git src/$path } pushd src/$path git checkout $branch git reset --hard $version popd } go get github.com/pelletier/go-buffruneio go get github.com/davecgh/go-spew/spew # get code for BurntSushi TOML validation # pinning all to 'HEAD' for version 0.3.x work (TODO: pin to commit hash when tests stabilize) git_clone github.com/BurntSushi/toml master HEAD git_clone github.com/BurntSushi/toml-test master HEAD #was: 0.2.0 HEAD # build the BurntSushi test application go build -o toml-test github.com/BurntSushi/toml-test # vendorize the current lib for testing # NOTE: this basically mocks an install without having to go back out to github for code mkdir -p src/github.com/pelletier/go-toml/cmd cp *.go *.toml src/github.com/pelletier/go-toml cp -R cmd/* src/github.com/pelletier/go-toml/cmd go build -o test_program_bin src/github.com/pelletier/go-toml/cmd/test_program.go # Run basic unit tests go test github.com/pelletier/go-toml \ github.com/pelletier/go-toml/cmd/tomljson # run the entire BurntSushi test suite if [[ $# -eq 0 ]] { echo "Running all BurntSushi tests" ./toml-test ./test_program_bin | tee test_out } else { # run a specific test global test := $1 global test_path := ''src/github.com/BurntSushi/toml-test/tests'' global valid_test := ""$test_path/valid/$test"" global invalid_test := ""$test_path/invalid/$test"" if test -e "$valid_test.toml" { echo "Valid Test TOML for $test:" echo "====" cat "$valid_test.toml" echo "Valid Test JSON for $test:" echo "====" cat "$valid_test.json" echo "Go-TOML Output for $test:" echo "====" cat "$valid_test.toml" | ./test_program_bin } if test -e "$invalid_test.toml" { echo "Invalid Test TOML for $test:" echo "====" cat "$invalid_test.toml" echo "Go-TOML Output for $test:" echo "====" echo "go-toml Output:" cat "$invalid_test.toml" | ./test_program_bin } } (CommandList children: [ (C {(set)} {(-e)}) (C {(export)} {(Lit_VarLike "GOPATH=") (CommandSubPart command_list: (CommandList children:[(C {(pwd)})]) left_token: spids: [17 19] ) } ) (FuncDef name: git_clone body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:path) op: Equal rhs: {($ VSub_Number "$1")} spids: [31] ) ] spids: [31] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:branch) op: Equal rhs: {($ VSub_Number "$2")} spids: [35] ) ] spids: [35] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:version) op: Equal rhs: {($ VSub_Number "$3")} spids: [39] ) ] spids: [39] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(-d)} {(DQ (src/) ($ VSub_Name "$path"))} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(mkdir)} {(-p)} {(src/) ($ VSub_Name "$path")}) (C {(git)} {(clone)} {(https) (Lit_Other ":") (//) ($ VSub_Name "$path") (.git)} {(src/) ($ VSub_Name "$path")} ) ] spids: [-1 59] ) ] spids: [-1 84] ) (C {(pushd)} {(src/) ($ VSub_Name "$path")}) (C {(git)} {(checkout)} {(DQ ($ VSub_Name "$branch"))}) (C {(git)} {(reset)} {(--hard)} {(DQ ($ VSub_Name "$version"))}) (C {(popd)}) ] spids: [28] ) spids: [22 27] ) (C {(go)} {(get)} {(github.com/pelletier/go-buffruneio)}) (C {(go)} {(get)} {(github.com/davecgh/go-spew/spew)}) (C {(git_clone)} {(github.com/BurntSushi/toml)} {(master)} {(HEAD)}) (C {(git_clone)} {(github.com/BurntSushi/toml-test)} {(master)} {(HEAD)}) (C {(go)} {(build)} {(-o)} {(toml-test)} {(github.com/BurntSushi/toml-test)}) (C {(mkdir)} {(-p)} {(src/github.com/pelletier/go-toml/cmd)}) (C {(cp)} {(Lit_Other "*") (.go)} {(Lit_Other "*") (.toml)} {(src/github.com/pelletier/go-toml)}) (C {(cp)} {(-R)} {(cmd/) (Lit_Other "*")} {(src/github.com/pelletier/go-toml/cmd)}) (C {(go)} {(build)} {(-o)} {(test_program_bin)} {(src/github.com/pelletier/go-toml/cmd/test_program.go)} ) (C {(go)} {(test)} {(github.com/pelletier/go-toml)} {(github.com/pelletier/go-toml/cmd/tomljson)}) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id:BoolBinary_eq left:{($ VSub_Pound "$#")} right:{(0)}) ) terminator: ) ] action: [ (C {(echo)} {(DQ ("Running all BurntSushi tests"))}) (Pipeline children: [(C {(./toml-test)} {(./test_program_bin)}) (C {(tee)} {(test_out)})] negated: False ) ] spids: [-1 244] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test) op: Equal rhs: {($ VSub_Number "$1")} spids: [271] ) ] spids: [271] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_path) op: Equal rhs: {(SQ )} spids: [275] ) ] spids: [275] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:valid_test) op: Equal rhs: {(DQ ($ VSub_Name "$test_path") (/valid/) ($ VSub_Name "$test"))} spids: [281] ) ] spids: [281] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:invalid_test) op: Equal rhs: {(DQ ($ VSub_Name "$test_path") (/invalid/) ($ VSub_Name "$test"))} spids: [289] ) ] spids: [289] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-e)} {(DQ ($ VSub_Name "$valid_test") (.toml))} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} {(DQ ("Valid Test TOML for ") ($ VSub_Name "$test") (":"))}) (C {(echo)} {(DQ ("===="))}) (C {(cat)} {(DQ ($ VSub_Name "$valid_test") (.toml))}) (C {(echo)} {(DQ ("Valid Test JSON for ") ($ VSub_Name "$test") (":"))}) (C {(echo)} {(DQ ("===="))}) (C {(cat)} {(DQ ($ VSub_Name "$valid_test") (.json))}) (C {(echo)} {(DQ ("Go-TOML Output for ") ($ VSub_Name "$test") (":"))}) (C {(echo)} {(DQ ("===="))}) (Pipeline children: [ (C {(cat)} {(DQ ($ VSub_Name "$valid_test") (.toml))}) (C {(./test_program_bin)}) ] negated: False ) ] spids: [-1 312] ) ] spids: [-1 393] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-e)} {(DQ ($ VSub_Name "$invalid_test") (.toml))} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} {(DQ ("Invalid Test TOML for ") ($ VSub_Name "$test") (":"))}) (C {(echo)} {(DQ ("===="))}) (C {(cat)} {(DQ ($ VSub_Name "$invalid_test") (.toml))}) (C {(echo)} {(DQ ("Go-TOML Output for ") ($ VSub_Name "$test") (":"))}) (C {(echo)} {(DQ ("===="))}) (C {(echo)} {(DQ ("go-toml Output:"))}) (Pipeline children: [ (C {(cat)} {(DQ ($ VSub_Name "$invalid_test") (.toml))}) (C {(./test_program_bin)}) ] negated: False ) ] spids: [-1 411] ) ] spids: [-1 474] ) ] spids: [264 476] ) ] )