flakey_spec_catcher 0.9.4 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 741a4b99da98b4eed541bd4dc36476c66a3df1efd21e6a79ea00547202b9e30e
4
- data.tar.gz: 48cb6f40ee8cf9f7019639622a8f3d9dc366b3b6691fde3418a1197dd0d0672e
3
+ metadata.gz: 7a44ba459f2157ca33775624edd45ae2f149bbf13c98bf5257976f74e3fc805b
4
+ data.tar.gz: 5dbd5b05eff3f5f06f4be7b18ceb4fab1f1c5710483ea59daf145e258e2f7ae8
5
5
  SHA512:
6
- metadata.gz: e135869d651917524f5abd7015f651a636a3d4c584a99a2d6860e094f3754779e2d0798d81f5b51df3bb9da323743a720c7a8f15ad160cbc7cf228794995f1a7
7
- data.tar.gz: a665e8efe5d67ec47706fde62a3cfc7a087303950e32778819154bacac2da4f7efd5a7135ca2236ab2ab6851e338e519924b06a76d5d73be10a4a7348afd4409
6
+ metadata.gz: b06366aeb33f8e1345a8b36459fa29a367f0dd02e34959587b5783b11ba90033373de37402c77a4f995110abd7cf0760e227854466d0f3ae5a36424e897c3325
7
+ data.tar.gz: 80f9b16ca84952de07e0f597a5d0397803a7060fe6e7959ea53082ba45e2c1a8f4dfa8ecd59dcd3b18ef46c450ec8468f0a402f93bfad13c6e7912f0991d8b64
data/README.md CHANGED
@@ -160,6 +160,7 @@ FSC_USAGE_PATTERNS = '{ spec/ui => bundle exec rspec }, { spec/api => parallel_r
160
160
  --node-index Specify the index this node represents in a split run
161
161
  -d, --dry-run Performs all setup but doesn't run any tests
162
162
  --dry-run-quiet Prints list of tests to be run
163
+ --verbose Send all output from running tests to stdout
163
164
  -v, --version Prints current flakey_spec_catcher_version
164
165
  -h, --help Displays available flakey_spec_catcher cli overrides
165
166
  ```
@@ -8,13 +8,14 @@ module FlakeySpecCatcher
8
8
  # Captures command line arguments for manual re-runs
9
9
  class CliOverride
10
10
  attr_reader :rerun_patterns, :rerun_usage, :repeat_factor, :enable_runs, :excluded_tags, :use_parent, :dry_run
11
- attr_reader :output_file, :split_nodes, :split_index
11
+ attr_reader :output_file, :split_nodes, :split_index, :verbose
12
12
 
13
13
  def initialize
14
14
  @dry_run = false
15
15
  @enable_runs = true
16
16
  @excluded_tags = []
17
17
  @use_parent = false
18
+ @verbose = false
18
19
  parse_command_line_args
19
20
  validate_arguments
20
21
  end
@@ -78,6 +79,10 @@ module FlakeySpecCatcher
78
79
  @dry_run = true
79
80
  end
80
81
 
82
+ opts.on('--verbose', 'Send all output from running tests to stdout') do
83
+ @verbose = true
84
+ end
85
+
81
86
  opts.on('-h', '--help', 'Displays available flakey_spec_catcher cli overrides') do
82
87
  puts opts
83
88
  @enable_runs = false
@@ -24,6 +24,7 @@ module FlakeySpecCatcher
24
24
  @rerun_manager = rerun_manager
25
25
  @rspec_result_manager = result_manager
26
26
  @test_run_count = 0
27
+ @temp_output_file = @user_config.output_file + 'temp' unless @user_config.output_file == File::NULL
27
28
  end
28
29
 
29
30
  # Debug Methods
@@ -38,7 +39,7 @@ module FlakeySpecCatcher
38
39
  puts " Node Total: #{@user_config.split_nodes}" if @user_config.split_nodes
39
40
  puts " Node Index: #{@user_config.split_index}" if @user_config.split_index
40
41
  puts " Changed Specs Detected: #{@git_controller.changed_examples}"
41
- return if @user_config.output_file == '/dev/null'
42
+ return if @user_config.output_file == File::NULL
42
43
 
43
44
  puts " Verbose Output Path: #{@user_config.output_file}"
44
45
  end
@@ -78,6 +79,7 @@ module FlakeySpecCatcher
78
79
  end
79
80
 
80
81
  display_results(status)
82
+ copy_to_user_output unless @user_config.output_file == File::NULL
81
83
 
82
84
  # Always return 0 if silent_mode is enabled
83
85
  @user_config.silent_mode ? 0 : status
@@ -93,16 +95,23 @@ module FlakeySpecCatcher
93
95
  def invoke_rspec_runner(test)
94
96
  configure_listener
95
97
  # Pass in CLI options to suppress normal output, and only run the specified test
96
- rspec_args = ['--out', @user_config.output_file, test]
98
+ rspec_args = ['--format', 'documentation', '--out', @user_config.output_file, test]
99
+ # Rspec output sent to stdout if verbose option is true
100
+ rspec_args << '-fd' if @user_config.verbose
97
101
  return_status = RSpec::Core::Runner.run(rspec_args)
98
102
  RSpec.clear_examples
103
+ copy_output_to_temp_file unless @user_config.output_file == File::NULL
99
104
  return_status
100
105
  end
101
106
 
102
107
  def invoke_custom_rspec_runner(usage, testcase)
103
- custom_usage_output = `#{usage} #{testcase.join(' ')}`
108
+ if @user_config.verbose
109
+ $stdout << custom_usage_output = `#{usage} #{testcase.join(' ')}`
110
+ else
111
+ custom_usage_output = `#{usage} #{testcase.join(' ')}`
112
+ end
104
113
 
105
- File.open(@user_config.output_file, 'a') { |f| f.puts custom_usage_output } if @user_config.output_file != '/dev/null'
114
+ File.open(@user_config.output_file, 'a') { |f| f.puts custom_usage_output } if @user_config.output_file != File::NULL
106
115
 
107
116
  $?.exitstatus # rubocop:disable Style/SpecialGlobalVars
108
117
  end
@@ -134,5 +143,18 @@ module FlakeySpecCatcher
134
143
  :example_failed, :example_passed
135
144
  end
136
145
  end
146
+
147
+ def copy_output_to_temp_file
148
+ # copy contents of output file, it will get overwritten in RSpec::Core::Runner
149
+ File.open(@temp_output_file, 'a') do |f|
150
+ f.puts IO.readlines(@user_config.output_file)
151
+ end
152
+ end
153
+
154
+ def copy_to_user_output
155
+ # copy all appended output to original output file, delete the temp output file
156
+ IO.copy_stream(@temp_output_file, @user_config.output_file) if File.exist?(@temp_output_file)
157
+ File.delete(@temp_output_file) if File.exist?(@temp_output_file)
158
+ end
137
159
  end
138
160
  end
@@ -11,7 +11,7 @@ module FlakeySpecCatcher
11
11
  attr_reader :rerun_file_only, :rspec_usage_patterns, :excluded_tags
12
12
  attr_reader :manual_rerun_patterns, :manual_rerun_usage
13
13
  attr_reader :enable_runs, :output_file, :use_parent, :dry_run
14
- attr_reader :split_nodes, :split_index
14
+ attr_reader :split_nodes, :split_index, :verbose
15
15
 
16
16
  USER_CONFIG_ENV_VARS = %w[FSC_REPEAT_FACTOR FSC_IGNORE_FILES FSC_IGNORE_BRANCHES
17
17
  FSC_SILENT_MODE FSC_RERUN_FILE_ONLY FSC_USAGE_PATTERNS
@@ -54,6 +54,7 @@ module FlakeySpecCatcher
54
54
  @cli_override.excluded_tags
55
55
  end
56
56
  @output_file = set_output_file
57
+ @verbose = @cli_override.verbose
57
58
  end
58
59
  # rubocop:enable Metrics/AbcSize
59
60
 
@@ -68,7 +69,7 @@ module FlakeySpecCatcher
68
69
  if !@cli_override.output_file.nil?
69
70
  @cli_override.output_file
70
71
  elsif @output_file.nil? || @output_file.strip.empty?
71
- '/dev/null'
72
+ File::NULL
72
73
  else
73
74
  @output_file
74
75
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FlakeySpecCatcher
4
- VERSION = '0.9.4'
4
+ VERSION = '0.9.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flakey_spec_catcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Watson
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-02-25 00:00:00.000000000 Z
13
+ date: 2020-03-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec