Skip to content
This repository has been archived by the owner on Dec 23, 2017. It is now read-only.

Commit

Permalink
added support for Go language
Browse files Browse the repository at this point in the history
  • Loading branch information
JonJagger committed Apr 14, 2012
1 parent 6a43647 commit 54b5df8
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions languages/Go/cyberdojo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go test
9 changes: 9 additions & 0 deletions languages/Go/manifest.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

{
:visible_filenames => %w( untitled.go untitled_test.go cyberdojo.sh ),

:unit_test_framework => 'go_testing',

:tab_size => 4
}

5 changes: 5 additions & 0 deletions languages/Go/untitled.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package untitled

func hhg() int {
return 42
}
9 changes: 9 additions & 0 deletions languages/Go/untitled_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package untitled

import ("testing")

func Test_hhg(t *testing.T) {
if (hhg() != 54) {
t.Error("hhg() != 54 as expected.")
}
}
15 changes: 15 additions & 0 deletions lib/CodeOutputParser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,20 @@ def self.parse_googletest(output)
end
end

def self.parse_go_testing(output)
didnt_build_pattern = /\[build failed\]/
failed_pattern = /FAIL/
passed_pattern = /PASS/
if didnt_build_pattern.match(output)
:amber
elsif failed_pattern.match(output)
:red
elsif passed_pattern.match(output)
:green
else
:amber
end
end

end

12 changes: 12 additions & 0 deletions test/lib/code_output_parser_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,17 @@ class CodeOutputParserTests < ActionController::TestCase
assert_equal :amber, CodeOutputParser::parse_catch(amber_output)
end

test "go build failed is amber" do
assert_equal :amber, CodeOutputParser::parse_go_testing("[build failed]")
end
test "go ran but failed is green" do
assert_equal :red, CodeOutputParser::parse_go_testing("FAIL")
end
test "go ran and passed is red" do
assert_equal :green, CodeOutputParser::parse_go_testing("PASS")
end
test "go anything else is amber" do
assert_equal :amber, CodeOutputParser::parse_go_testing("anything else")
end
end

0 comments on commit 54b5df8

Please sign in to comment.