assert 2.13.0 → 2.14.0

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: cb4aa7ad09c0655c7575c8cd7b65d7477a4074bf
4
- data.tar.gz: 7baa88b16be41c504944626e5d29e1a51d0c7502
3
+ metadata.gz: fa3c97970bacaed419dd9a2986302c8f7381ef8c
4
+ data.tar.gz: 0bf830c19a718be854960e6ddbb6b6bdf30f78fa
5
5
  SHA512:
6
- metadata.gz: 900bfce4dbbda0860cd97d2719be1e9d0e7151fefb93d9f8190c4e3537f65d36fe1359e8df7e829208c69c698b272dfcc5991baa5d097d42d90c6595b2e75746
7
- data.tar.gz: 02c7a331e37799de0e8a74f2885aa935bc9a59a4f0af300f66927ec05d408cfe6e822682d63a6116fdfdfc0e7bc946d32fee10ee3bf721deca257b2b03a3a67a
6
+ metadata.gz: e7dffb68840de736888b0f7aa2c4159677eb820d75a83be49c2568b1ab796ad28135cae9e397eb341b857fb2aa6bbc577d890720094d626c6b4bb3ba3042779c
7
+ data.tar.gz: 772c42c5f472a9973d9d59bbc0d3e61a44886e58a7ed25d9f3cd0d6a1d15bc651da563a06ae1a455b6afd8d232cd64e3222014aaeb8e92e2cf7620b49128d909
data/README.md CHANGED
@@ -297,16 +297,26 @@ Using the CLI:
297
297
  $ assert [-c|--changed-only|--no-changed-only]
298
298
  ```
299
299
 
300
+ You can also optionally send a "reference" value to evaluate changes against. This can be any value and it is passed to the proc that detects changes (see below). Using the default git changed proc, this value would be any commit reference (ie HEAD, master, etc).
301
+
302
+ Using the CLI:
303
+
304
+ ```sh
305
+ $ assert -c [-r|--changed-ref] REF_VALUE
306
+ ```
307
+
308
+ Note: This option has no effect unless used with the `-c` option. One practical use of this is to test changes 1) after they have been staged (`assert -cr HEAD`) or 2) after they have been committed to a branch (`assert -cr master`) (for example).
309
+
300
310
  #### Changed Test File Detection
301
311
 
302
312
  The changed files are detected using two git commands by default:
303
313
 
304
314
  ```sh
305
- git diff --no-ext-diff --name-only # changed files
315
+ git diff --no-ext-diff --name-only {ref} # changed files
306
316
  git ls-files --others --exclude-standard # added files
307
317
  ```
308
318
 
309
- The git cmds have ` -- #{test_paths}` appended to them to scope their results to just the test paths specified by the CLI and are run together using ` && `.
319
+ The git cmds have ` -- #{test_paths}` appended to them to scope their results to just the test paths specified by the CLI and are run together using ` && `. The `{ref}` above is any reference value given using the `-r` CLI opt.
310
320
 
311
321
  This, of course, assumes you are working in a git repository. If you are not or you want to use custom logic to determine the changed files, configure a custom proc. The proc should take two parameters: the config and an array of test paths specified by the CLI.
312
322
 
@@ -27,6 +27,11 @@ module Assert
27
27
  Assert::CLI.bench('Require test helper'){ require h }
28
28
  end
29
29
 
30
+ if self.config.list
31
+ $stdout.puts test_files
32
+ halt
33
+ end
34
+
30
35
  # load the test files
31
36
  self.config.view.fire(:before_load, test_files)
32
37
  Assert::CLI.bench("Require #{test_files.count} test files") do
@@ -43,7 +48,11 @@ module Assert
43
48
  self.config.runner.run(self.config.suite, self.config.view)
44
49
  end
45
50
 
46
- protected
51
+ private
52
+
53
+ def halt
54
+ throw(:halt)
55
+ end
47
56
 
48
57
  def apply_user_settings
49
58
  safe_require("#{ENV['HOME']}/#{USER_SETTINGS_FILE}") if ENV['HOME']
@@ -61,8 +70,6 @@ module Assert
61
70
  self.config.runner_seed ENV['ASSERT_RUNNER_SEED'].to_i if ENV['ASSERT_RUNNER_SEED']
62
71
  end
63
72
 
64
- private
65
-
66
73
  def test_files(test_paths)
67
74
  file_paths = if self.config.changed_only
68
75
  changed_test_files(test_paths)
@@ -27,36 +27,46 @@ module Assert
27
27
  def initialize(*args)
28
28
  @args = args
29
29
  @cli = CLIRB.new do
30
- option 'runner_seed', 'Use a given seed to run tests', {
30
+ option 'runner_seed', 'use a given seed to run tests', {
31
31
  :abbrev => 's', :value => Fixnum
32
32
  }
33
- option 'capture_output', 'capture stdout and display in result details', {
34
- :abbrev => 'o'
35
- }
36
- option 'halt_on_fail', 'halt a test when it fails', {
37
- :abbrev => 'h'
38
- }
39
33
  option 'changed_only', 'only run test files with changes', {
40
34
  :abbrev => 'c'
41
35
  }
36
+ option 'changed_ref', 'reference for changes, use with `-c` opt', {
37
+ :abbrev => 'r', :value => ''
38
+ }
42
39
  option 'pp_objects', 'pretty-print objects in fail messages', {
43
40
  :abbrev => 'p'
44
41
  }
42
+ option 'capture_output', 'capture stdout and display in result details', {
43
+ :abbrev => 'o'
44
+ }
45
+ option 'halt_on_fail', 'halt a test when it fails', {
46
+ :abbrev => 'h'
47
+ }
45
48
  option 'profile', 'output test profile info', {
46
49
  :abbrev => 'e'
47
50
  }
48
51
  option 'verbose', 'output verbose runtime test info', {
49
52
  :abbrev => 'v'
50
53
  }
54
+ option 'list', 'list test files on $stdout', {
55
+ :abbrev => 'l'
56
+ }
51
57
  # show loaded test files, cli err backtraces, etc
52
- option 'debug', 'run in debug mode'
58
+ option 'debug', 'run in debug mode', {
59
+ :abbrev => 'd'
60
+ }
53
61
  end
54
62
  end
55
63
 
56
64
  def run
57
65
  begin
58
66
  @cli.parse!(@args)
59
- Assert::AssertRunner.new(Assert.config, @cli.args, @cli.opts).run
67
+ catch(:halt) do
68
+ Assert::AssertRunner.new(Assert.config, @cli.args, @cli.opts).run
69
+ end
60
70
  rescue CLIRB::HelpExit
61
71
  puts help
62
72
  rescue CLIRB::VersionExit
@@ -14,10 +14,10 @@ module Assert
14
14
  end
15
15
 
16
16
  settings :view, :suite, :runner
17
- settings :test_dir, :test_helper, :test_file_suffixes, :runner_seed
17
+ settings :test_dir, :test_helper, :test_file_suffixes
18
18
  settings :changed_proc, :pp_proc, :use_diff_proc, :run_diff_proc
19
- settings :capture_output, :halt_on_fail, :changed_only, :pp_objects
20
- settings :debug, :profile, :verbose
19
+ settings :runner_seed, :changed_only, :changed_ref, :pp_objects
20
+ settings :capture_output, :halt_on_fail, :profile, :verbose, :list, :debug
21
21
 
22
22
  def initialize(settings = nil)
23
23
  @suite = Assert::Suite.new(self)
@@ -27,21 +27,23 @@ module Assert
27
27
  @test_dir = "test"
28
28
  @test_helper = "helper.rb"
29
29
  @test_file_suffixes = ['_tests.rb', '_test.rb']
30
- @runner_seed = begin; srand; srand % 0xFFFF; end.to_i
31
30
 
32
31
  @changed_proc = Assert::U.git_changed_proc
33
32
  @pp_proc = Assert::U.stdlib_pp_proc
34
33
  @use_diff_proc = Assert::U.default_use_diff_proc
35
34
  @run_diff_proc = Assert::U.syscmd_diff_proc
36
35
 
37
- # mode flags
38
- @capture_output = false
39
- @halt_on_fail = true
36
+ # option settings
37
+ @runner_seed = begin; srand; srand % 0xFFFF; end.to_i
40
38
  @changed_only = false
39
+ @changed_ref = ''
41
40
  @pp_objects = false
42
- @debug = false
41
+ @capture_output = false
42
+ @halt_on_fail = true
43
43
  @profile = false
44
44
  @verbose = false
45
+ @list = false
46
+ @debug = false
45
47
 
46
48
  self.apply(settings || {})
47
49
  end
@@ -63,8 +63,8 @@ module Assert
63
63
  Proc.new do |config, test_paths|
64
64
  files = []
65
65
  cmd = [
66
- "git diff --no-ext-diff --name-only", # changed files
67
- "git ls-files --others --exclude-standard" # added files
66
+ "git diff --no-ext-diff --name-only #{config.changed_ref}", # changed files
67
+ "git ls-files --others --exclude-standard" # added files
68
68
  ].map{ |c| "#{c} -- #{test_paths.join(' ')}" }.join(' && ')
69
69
  Assert::CLI.bench('Load only changed files') do
70
70
  files = `#{cmd}`.split("\n")
@@ -1,3 +1,3 @@
1
1
  module Assert
2
- VERSION = "2.13.0"
2
+ VERSION = "2.14.0"
3
3
  end
@@ -11,11 +11,11 @@ class Assert::Config
11
11
  subject{ @config }
12
12
 
13
13
  should have_imeths :suite, :view, :runner
14
- should have_imeths :test_dir, :test_helper, :test_file_suffixes, :runner_seed
14
+ should have_imeths :test_dir, :test_helper, :test_file_suffixes
15
15
  should have_imeths :changed_proc, :pp_proc, :use_diff_proc, :run_diff_proc
16
- should have_imeths :capture_output, :halt_on_fail, :changed_only, :pp_objects
17
- should have_imeths :debug, :profile, :verbose
18
- should have_imeths :apply
16
+ should have_imeths :runner_seed, :changed_only, :changed_ref, :pp_objects
17
+ should have_imeths :capture_output, :halt_on_fail, :profile, :verbose, :list
18
+ should have_imeths :debug, :apply
19
19
 
20
20
  should "default the view, suite, and runner" do
21
21
  assert_kind_of Assert::View::DefaultView, subject.view
@@ -23,11 +23,10 @@ class Assert::Config
23
23
  assert_kind_of Assert::Runner, subject.runner
24
24
  end
25
25
 
26
- should "default the test dir/helper/suffixes/seed" do
26
+ should "default the test dir/helper/suffixes" do
27
27
  assert_equal 'test', subject.test_dir
28
28
  assert_equal 'helper.rb', subject.test_helper
29
29
  assert_equal ['_tests.rb', "_test.rb"], subject.test_file_suffixes
30
- assert_not_nil subject.runner_seed
31
30
  end
32
31
 
33
32
  should "default the procs" do
@@ -37,14 +36,17 @@ class Assert::Config
37
36
  assert_not_nil subject.run_diff_proc
38
37
  end
39
38
 
40
- should "default the mode flags" do
41
- assert_not subject.capture_output
42
- assert subject.halt_on_fail
43
- assert_not subject.changed_only
44
- assert_not subject.pp_objects
45
- assert_not subject.debug
46
- assert_not subject.profile
47
- assert_not subject.verbose
39
+ should "default the option settings" do
40
+ assert_not_nil subject.runner_seed
41
+ assert_not subject.changed_only
42
+ assert_empty subject.changed_ref
43
+ assert_not subject.pp_objects
44
+ assert_not subject.capture_output
45
+ assert subject.halt_on_fail
46
+ assert_not subject.profile
47
+ assert_not subject.verbose
48
+ assert_not subject.list
49
+ assert_not subject.debug
48
50
  end
49
51
 
50
52
  should "apply settings given from a hash" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assert
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.13.0
4
+ version: 2.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-23 00:00:00.000000000 Z
12
+ date: 2015-03-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ansi