smart_test 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cd44eb5e122f43dec86a8b4e8a72bf44ac89396
4
- data.tar.gz: e464ac036a680ea3ff5c57c36eb4fe95cd25ccf4
3
+ metadata.gz: 69bdf66db6286e3b173556e9117f850f30e76f7a
4
+ data.tar.gz: 316a0e1ef67b6ca773b94ef0c5746aeb4af74a44
5
5
  SHA512:
6
- metadata.gz: ec3f0b65ef9f6e4bb277af737cc1884d8384993e915d1a15f5e7992b0f557ad602b2d0fef289f2ad1573e19d205c5eedc7b7c1975233a09df1885987bb80a5f9
7
- data.tar.gz: 280f610a96202483656ec09062a07d6b459ecd264f27c92dd64121a271acaeab08c5eedd54e7253cd427cc2a100ad3540465bb9c2fe7ddb1a83c65aa16d08f28
6
+ metadata.gz: 90d63716f9c42f826b15facd7daaaf22d5af693d110f3ab859fa6b07c297b419cbe06262a805ed50c0cb0c1f71af686be9d43c9a7488f04210ab3973f3cdc256
7
+ data.tar.gz: 002abeda2000fb3dbaf0ab08f208c495e1a66974644cf9cd71b9880b381a069c35911ffbd3500c2481897c5bbece351e594b7871be08e3df925de41a63bba8e2
data/README.md CHANGED
@@ -1,26 +1,37 @@
1
1
  # SmartTest
2
2
 
3
- TODO: Write a gem description
3
+ Run tests based on file last modifed at and git diff.
4
+
5
+ Now only rspec is supported!
4
6
 
5
7
  ## Installation
6
8
 
7
- Add this line to your application's Gemfile:
9
+ $ gem install smart_test
8
10
 
9
- ```ruby
10
- gem 'smart_test'
11
- ```
11
+ ## Usage
12
12
 
13
- And then execute:
13
+ Under the root of a project with test files, you can run:
14
14
 
15
- $ bundle
16
15
 
17
- Or install it yourself as:
16
+ Run latest modified test file
18
17
 
19
- $ gem install smart_test
18
+ $ smart_test
20
19
 
21
- ## Usage
20
+ Run latest modified 3 test files
21
+
22
+ $ smart_test 3
23
+
24
+ Run test files based on git diff, -d can be skipped if it has param
25
+
26
+ $ smart_test -d
27
+ $ smart_test -d master
28
+ $ smart_test HEAD~2
29
+ $ smart_test GIT_HASH
30
+
31
+ Show the test files which will be running
32
+
33
+ $ smart_test -d master -s
22
34
 
23
- TODO: Write usage instructions here
24
35
 
25
36
  ## Contributing
26
37
 
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib]))
3
4
  require "smart_test"
4
5
 
5
6
  SmartTest::CLI.new.parse! ARGV
@@ -10,12 +10,12 @@ module SmartTest
10
10
  opt.banner = <<-EOS
11
11
  Run test smartly
12
12
 
13
- Usage: smart_test -d
14
- smart_test -s
15
- smart_test NUM
13
+ Usage: smart_test -d GIT_DIFF_PARAM
14
+ smart_test [-s|-b]
15
+ smart_test -n NUM
16
16
  EOS
17
17
 
18
- opt.on("--version", "Show version") do
18
+ opt.on("-v", "--version", "Show version") do
19
19
  puts VERSION
20
20
  exit
21
21
  end
@@ -33,14 +33,28 @@ Usage: smart_test -d
33
33
  options[:type] = :diff
34
34
  options[:param] = str
35
35
  end
36
+
37
+ opt.on("-b", "--branch", "Branch test") do
38
+ options[:type] = :diff
39
+ options[:param] = "master"
40
+ end
36
41
  end
37
42
 
38
43
  opts.parse! args
39
44
 
45
+ if options.empty? && args.size > 0
46
+ arg = args.join ' '
47
+ if arg =~ /\d+/
48
+ options = { type: :mtime, param: arg.to_i }
49
+ else
50
+ options= { type: :diff, param: arg }
51
+ end
52
+ end
53
+
40
54
  @runner = SpecRunner.new(Dir.pwd, options)
41
55
 
42
56
  if @runner.files.empty?
43
- puts "Not test files to run!"
57
+ puts "No test files to run!"
44
58
  return
45
59
  end
46
60
 
@@ -17,7 +17,5 @@ module SmartTest
17
17
  raise NotGitRepoError unless project.using_git?
18
18
  `git diff #{str} --name-only`.split("\n").select { |file| project.test_file? file }
19
19
  end
20
-
21
- private
22
20
  end
23
21
  end
@@ -1,3 +1,3 @@
1
1
  module SmartTest
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yu Wang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-04 00:00:00.000000000 Z
11
+ date: 2014-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler