git_test 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Your test results...distributed
4
4
 
5
5
  git\_test runs your tests and stores them in git. Use git_test to track
6
- tests over multiple branches, runs, and teammates. Run git\_test when you pull and push
6
+ tests over multiple branches, runs, and teammates. Run git\_test when you fetch and push
7
7
  and you'll always know the state of your project!
8
8
 
9
9
  ## Install
@@ -16,9 +16,9 @@ Before you push your code to a central repo run your tests
16
16
 
17
17
  $ git_test push
18
18
 
19
- After you pull new code down run your tests
19
+ After you fetch new code down run your tests
20
20
 
21
- $ git_test pull
21
+ $ git_test fetch
22
22
 
23
23
  Whenever you feel like it, run your tests
24
24
 
@@ -66,7 +66,7 @@ Git test works by making a temp directory, cloning your repository into that dir
66
66
 
67
67
  ## CI Isn't Enough
68
68
 
69
- On most projects everyone should run tests locally. The goal of git_test is to make running local tests as easy as possible and also to make them more useful. We do that by storing the result so you can compare branches and find out if another team-members pull request is ATP without having to ask.
69
+ On most projects everyone should run tests locally. The goal of git_test is to make running local tests as easy as possible and also to make them more useful. We do that by storing the result so you can compare branches and find out if another team-members fetch request is ATP without having to ask.
70
70
 
71
71
  Even better have your CI save its results in git_test.
72
72
 
data/bin/git_test CHANGED
@@ -26,7 +26,7 @@ include GLI
26
26
 
27
27
 
28
28
  program_desc %Q{ git_test runs your tests and stores them in git. Use git_test to track
29
- tests over multiple branches, runs, and teammates. Run git_test when you pull and push
29
+ tests over multiple branches, runs, and teammates. Run git_test when you fetch and push
30
30
  and you'll always know the state of your project!}
31
31
 
32
32
  version GitTest::VERSION
@@ -59,13 +59,13 @@ end
59
59
 
60
60
 
61
61
 
62
- desc "pulls from origin then runs tests"
63
- command :pull do |c|
62
+ desc "fetchs from origin then runs tests"
63
+ command :fetch do |c|
64
64
  c.action do |global_options,options,args|
65
65
  begin
66
66
  global_options.merge! options
67
67
  runner = GitTest::Runner.new(global_options)
68
- runner.pull!
68
+ runner.fetch!
69
69
  runner.test!
70
70
  runner.write_report!
71
71
  runner.notify.write("to view test report run `git_test show last`", :green)
@@ -101,7 +101,7 @@ command :push do |c|
101
101
  begin
102
102
  global_options.merge! options
103
103
  runner = GitTest::Runner.new(global_options)
104
- runner.pull!
104
+ runner.fetch!
105
105
  runner.push! unless options[:push_after_test]
106
106
  runner.test!
107
107
  runner.write_report!
@@ -3,44 +3,50 @@ require 'time'
3
3
  module GitTest
4
4
  # orchestrates everything
5
5
  class Runner
6
- attr_accessor :notify, :options, :proj, :test_proj, :test, :writer, :test_dir
6
+ attr_accessor :notify, :options, :proj, :test_proj, :test, :writer, :test_dir, :proj_branch
7
7
 
8
8
  def initialize(options ={} , notify = Notify.new)
9
- self.options = options
10
- self.notify = notify
11
- self.proj = GitTest::Proj.new(options)
12
- self.test = GitTest::Test.new(options)
13
- self.test_dir = Dir.mktmpdir(".git_test_#{proj.current_branch}_#{Time.now.to_i}")
9
+ self.options = options
10
+ self.notify = notify
11
+ self.proj = GitTest::Proj.new(options)
12
+ self.test = GitTest::Test.new(options)
13
+ self.proj_branch = proj.current_branch
14
+ self.test_dir = Dir.mktmpdir(".git_test_#{proj_branch}_#{Time.now.to_i}")
15
+ prepare_proj_for_test!
14
16
  clone_to_test!
15
17
  end
16
18
 
19
+ def prepare_proj_for_test!
20
+ proj.check_repo_status!
21
+ proj.branch(report_branch) unless proj.is_branch? report_branch
22
+ end
23
+
17
24
  # runs the test command provided
18
25
  def test!
19
26
  in_test_dir do
20
- proj.check_repo_status!
21
- notify.start("Running tests on: #{proj.current_branch}")
27
+ notify.start("Running tests on: #{proj_branch}")
22
28
  test.run!
23
29
  notify.done("Test finished: #{test.status}", test.passed?)
24
30
  end
25
31
  end
26
32
 
27
33
  # will open the specified or last report
28
- def show_report(file_name = nil, branch = current_branch)
34
+ def show_report(file_name = nil, branch = proj_branch)
29
35
  file_name ||= last_report_file_name(branch)
30
36
  report = proj.show(report_branch, File.join(report_path(branch), file_name))
31
37
  report_file = Tempfile.new([report_name, report_extension])
32
38
  report_file.write(report)
33
- exec "open #{report_file.path}"
34
- sleep 300
39
+ `open #{report_file.path}`
40
+ sleep 3
35
41
  end
36
42
 
37
43
  # gives last report file name
38
- def last_report_file_name(branch = current_branch)
44
+ def last_report_file_name(branch = proj_branch)
39
45
  ls_report_dir(branch).first
40
46
  end
41
47
 
42
48
  # outputs the files in the test directory for a given branch
43
- def ls_report_dir(branch = current_branch)
49
+ def ls_report_dir(branch = proj_branch)
44
50
  files = proj.show(report_branch, report_path(branch)).split("\n")
45
51
  files.shift(2)
46
52
  files
@@ -55,14 +61,14 @@ module GitTest
55
61
  # pushes to origin on the current branch and report branch
56
62
  def push!
57
63
  notify.write("Pushing to origin")
58
- proj.push('origin', proj.current_branch)
59
- proj.push('origin', report_branch) if proj.is_branch? report_branch
64
+ proj.push('origin', proj_branch)
65
+ proj.push('origin', report_branch)
60
66
  end
61
67
 
62
68
  # pulls from origin on the current branch and report branch
63
- def pull!
69
+ def fetch!
64
70
  notify.write("Pulling from origin")
65
- proj.pull('origin', proj.current_branch)
71
+ proj.fetch(proj_branch)
66
72
  end
67
73
 
68
74
  # writes the result of the test command to disk
@@ -81,10 +87,10 @@ module GitTest
81
87
 
82
88
  # commits contents of test branch and pushes back to local repo
83
89
  def commit_to_test_proj!
84
- test_proj.add full_report_path
85
- result = test_proj.commit("#{proj.current_branch} #{report_name}")
90
+ test_proj.add(full_report_path)
91
+ result = test_proj.commit("#{proj_branch} #{report_name}")
86
92
  notify.write("Pushing back to local repo")
87
- test_proj.real_pull('origin', report_branch) if proj.is_branch? report_branch
93
+ test_proj.real_pull('origin', report_branch)
88
94
  test_proj.push('origin', report_branch)
89
95
  end
90
96
 
@@ -98,20 +104,16 @@ module GitTest
98
104
  "git_test_reports"
99
105
  end
100
106
 
101
- def report_path(branch = proj.current_branch)
107
+ def report_path(branch = proj_branch)
102
108
  "git_test_reports/#{branch}"
103
109
  end
104
110
 
105
111
  def report_name
106
112
  name = "#{ test.created_at.utc.iso8601 }_"
107
- name << "#{ proj.username }_"
113
+ name << "#{ test_proj.username }_"
108
114
  name << "#{ test.status }#{ report_extension }"
109
115
  end
110
116
 
111
- def current_branch
112
- proj.current_branch
113
- end
114
-
115
117
 
116
118
 
117
119
  def report_extension
@@ -136,7 +138,6 @@ module GitTest
136
138
  branch.checkout
137
139
  test_proj.checkout(branch)
138
140
  yield
139
- test_proj.checkout(proj.current_branch)
140
141
  end
141
142
  end
142
143
  end
@@ -1,3 +1,3 @@
1
1
  module GitTest
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_test
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 9
10
+ version: 0.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Richard Schneeman
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-27 00:00:00 Z
18
+ date: 2011-10-28 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rake