Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Cleaner output #11

Merged
merged 7 commits into from

2 participants

@stewart
Collaborator

@deadprogram
Owner

I'd love to be able to colorize the output from the tests, that gets pushed up to wiki when you run rake gitnesse:push_results

@stewart
Collaborator

How's this? Imgur

@deadprogram
Owner

Awesome!

@deadprogram deadprogram merged commit 65dee91 into master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 17, 2012
  1. @stewart
  2. @stewart

    Colorize gitnesse output

    stewart authored
  3. @stewart

    Make tests pass

    stewart authored
  4. @stewart

    Finishing touches

    stewart authored
Commits on Dec 18, 2012
  1. @stewart

    Prepend image to wiki results

    stewart authored
  2. @stewart
  3. @stewart

    Fix strip_results_test

    stewart authored
This page is out of date. Refresh to see the latest.
View
22 lib/gitnesse.rb
@@ -1,6 +1,7 @@
require 'bundler/setup'
require 'gollum'
require 'fileutils'
+require 'pathname'
require 'tmpdir'
require 'gitnesse/configuration'
require 'gitnesse/git_config'
@@ -31,7 +32,7 @@ def self.configure
def run
if pull
Hooks.create
- puts "Now going to run cucumber..."
+ puts "\n Now going to run Cucumber."
exec("cucumber #{Gitnesse.configuration.target_directory}/*.feature")
end
end
@@ -39,7 +40,7 @@ def run
def push_results
if push
Hooks.create
- puts "Now going to run cucumber..."
+ puts "\n Now going to run Cucumber."
exec("cucumber #{Gitnesse.configuration.target_directory}/*.feature")
end
end
@@ -48,7 +49,9 @@ def push_results
def pull
Dependencies.check
- puts "Pulling features into #{Gitnesse.configuration.target_directory} from #{Gitnesse.configuration.repository_url}..."
+ relative_path = Pathname.new(Gitnesse.configuration.target_directory).relative_path_from(Pathname.new(Dir.pwd))
+
+ puts " Pulling features into ./#{relative_path} from #{Gitnesse.configuration.repository_url}."
Dir.mktmpdir do |tmp_dir|
if clone_feature_repo(tmp_dir)
FileUtils.mkdir(Gitnesse.configuration.target_directory) unless File.exists?(Gitnesse.configuration.target_directory)
@@ -62,7 +65,7 @@ def pull
end
end
end
- puts " Done pulling features."
+ puts " \e[32mDone pulling features.\e[0m"
true
end
@@ -71,7 +74,9 @@ def push
Dependencies.check
generate_commit_info
- puts "Pushing features from #{Gitnesse.configuration.target_directory} to #{Gitnesse.configuration.repository_url}..."
+ relative_path = Pathname.new(Gitnesse.configuration.target_directory).relative_path_from(Pathname.new(Dir.pwd))
+
+ puts " Pushing features from ./#{relative_path} to #{Gitnesse.configuration.repository_url}."
Dir.mktmpdir do |tmp_dir|
if clone_feature_repo(tmp_dir)
feature_files = Dir.glob("#{Gitnesse.configuration.target_directory}/*.feature")
@@ -79,17 +84,16 @@ def push
# push the changes to the remote git
Dir.chdir(tmp_dir) do
- puts `git push origin master`
+ `git push origin master &> /dev/null`
end
end
end
- puts " Done pushing features."
+ puts " \e[32mDone pushing features.\e[0m"
true
end
def clone_feature_repo(dir)
- output = `git clone #{Gitnesse.configuration.repository_url} #{dir} 2>&1`
- puts output
+ output = `git clone #{Gitnesse.configuration.repository_url} #{dir} &> /dev/null`
$?.success?
end
View
4 lib/gitnesse/dependencies.rb
@@ -17,11 +17,11 @@ def self.check
protected
def self.check_git
- raise NoGitError, "git not found or not working." unless Kernel.system("git --version")
+ raise NoGitError, "git not found or not working." unless Kernel.system("git --version &> /dev/null")
end
def self.check_cucumber
- raise NoCucumberError, "cucumber not found or not working." unless Kernel.system("cucumber --version")
+ raise NoCucumberError, "cucumber not found or not working." unless Kernel.system("cucumber --version &> /dev/null")
end
def self.check_repository_url
View
4 lib/gitnesse/features.rb
@@ -25,11 +25,11 @@ def self.gather(page_features)
features = ''
name, content = page_features.shift
- puts " # Pulling Feature: #{name}"
+ puts " \e[32m\e[1mPulling Feature: \e[0m#{name}"
features += content
page_features.each do |name, feature|
- puts " # WARNING! Discarding Feature: #{name}"
+ puts " \e[33m\e[1mDiscarding Feature: \e[0m#{name}"
end
features
View
6 lib/gitnesse/hooks.rb
@@ -9,7 +9,7 @@ def self.setup
Gitnesse::Configuration.load_using_search
FileUtils.rm_rf(@dir) if File.directory?(@dir)
Dir.mkdir(@dir)
- `git clone #{Gitnesse.configuration.repository_url} #{@dir}`
+ `git clone #{Gitnesse.configuration.repository_url} #{@dir} &> /dev/null`
Wiki.new(@dir).remove_past_results
end
@@ -17,12 +17,14 @@ def self.setup
#
# Returns nothing
def self.teardown
+ puts " Pushing Cucumber results to wiki."
Dir.chdir(@dir) do
- `git push origin master`
+ `git push origin master &> /dev/null`
end
FileUtils.rm_rf(@dir)
FileUtils.rm(File.absolute_path("#{Gitnesse.configuration.target_directory}/support/gitnesse_hooks.rb"))
+ puts " Done."
end
# Public: Adds hooks into Cucumber
View
19 lib/gitnesse/wiki.rb
@@ -108,7 +108,7 @@ def remove_past_results
def strip_results(content)
if content.match(/\u0060{3}gherkin.*\u0060{3}(.*)/m)[1]
[ "FAILED", "PASSED", "PENDING", "UNDEFINED" ].each do |type|
- content.gsub!(/\n*\`Last result was #{type}: .*\n*/, '')
+ content.gsub!(/\n*\!\[\]\(.*\) \`Last result was #{type}: .*\n*/, '')
end
end
content
@@ -127,7 +127,16 @@ def append_results(scenario)
if page.name == filename || page.name == "#{filename}.feature"
if page.text_data.include? scenario.name
content = page.raw_data
- string = "\n\`Last result was #{scenario.status.to_s.upcase}: #{scenario.name} (#{Time.now.to_s} - #{Gitnesse.configuration.info})\`\n"
+
+ case scenario.status
+ when :undefined then image = "![](https://s3.amazonaws.com/gitnesse/github/undefined.png)"
+ when :passed then image = "![](https://s3.amazonaws.com/gitnesse/github/passing.png)"
+ when :failed then image = "![](https://s3.amazonaws.com/gitnesse/github/failing.png)"
+ when :pending then image = "![](https://s3.amazonaws.com/gitnesse/github/pending.png)"
+ else image = "![](https://s3.amazonaws.com/gitnesse/github/undefined.png)"
+ end
+
+ string = "\n#{image} \`Last result was #{scenario.status.to_s.upcase}: #{scenario.name} (#{Time.now.to_s} - #{Gitnesse.configuration.info})\`\n"
content.gsub(string, '')
content << string
@wiki.update_page(page, page.name, :markdown, content, @commit_info)
@@ -148,7 +157,7 @@ def append_results(scenario)
def create_wiki_page(name, content)
new_page_content = build_page_content(content)
@wiki.write_page(name, :markdown, new_page_content, @commit_info)
- puts " # Created Page: #{name}"
+ puts " \e[32mCreated page \e[0m#{name}."
end
# Private: Updates a wiki page with the provided name and content
@@ -163,10 +172,10 @@ def update_wiki_page(wiki_page, page_name, feature_content)
new_page_content = build_page_content(feature_content, wiki_page_content)
if new_page_content == wiki_page_content
- puts " # Page #{page_name} didn't change"
+ puts " \e[32mPage \e[0m#{page_name} \e[32mdidn't change\e[0m."
else
@wiki.update_page(wiki_page, page_name, :markdown, new_page_content, @commit_info)
- puts " # Updated Page: #{page_name}"
+ puts " \e[33mUpdated page \e[0m#{page_name}."
end
end
end
View
8 test/lib/gitnesse/dependencies_check_test.rb
@@ -32,12 +32,12 @@
let(:method) { lambda { Gitnesse::Dependencies.check_git } }
describe "when git is not installed" do
- before { Kernel.expects(:system).with("git --version").returns(false) }
+ before { Kernel.expects(:system).with("git --version &> /dev/null").returns(false) }
it { method.must_raise(Gitnesse::Dependencies::NoGitError) }
end
describe "when git is installed" do
- before { Kernel.expects(:system).with("git --version").returns(true) }
+ before { Kernel.expects(:system).with("git --version &> /dev/null").returns(true) }
it { method.call.must_be_nil }
end
end
@@ -46,12 +46,12 @@
let(:method) { lambda { Gitnesse::Dependencies.check_cucumber } }
describe "when cucumber is not installed" do
- before { Kernel.expects(:system).with("cucumber --version").returns(false) }
+ before { Kernel.expects(:system).with("cucumber --version &> /dev/null").returns(false) }
it { method.must_raise(Gitnesse::Dependencies::NoCucumberError) }
end
describe "when cucumber is installed" do
- before { Kernel.expects(:system).with("cucumber --version").returns(true) }
+ before { Kernel.expects(:system).with("cucumber --version &> /dev/null").returns(true) }
it { method.call.must_be_nil }
end
end
View
8 test/lib/gitnesse/strip_results_test.rb
@@ -16,13 +16,13 @@
When I divide
Then the result should be 3
```
-`Last result was UNDEFINED: Divide two numbers`
+![](http://path-to-image) `Last result was UNDEFINED: Divide two numbers`
-`Last result was PENDING: Divide two numbers`
+![](http://path-to-image) `Last result was PENDING: Divide two numbers`
-`Last result was FAILED: Divide two numbers`
+![](http://path-to-image) `Last result was FAILED: Divide two numbers`
-`Last result was PASSED: Divide two numbers`
+![](http://path-to-image) `Last result was PASSED: Divide two numbers`
EOS
end
Something went wrong with that request. Please try again.