tryouts 3.4.0 → 3.5.1

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.
@@ -1,5 +1,7 @@
1
1
  # lib/tryouts/parsers/shared_methods.rb
2
2
 
3
+ require_relative '../parser_warning'
4
+
3
5
  class Tryouts
4
6
  module Parsers
5
7
  module SharedMethods
@@ -205,13 +207,19 @@ class Tryouts
205
207
  test_blocks = classified_blocks.filter { |block| block[:type] == :test }
206
208
  teardown_blocks = classified_blocks.filter { |block| block[:type] == :teardown }
207
209
 
208
- Testrun.new(
210
+ testrun = Testrun.new(
209
211
  setup: build_setup(setup_blocks),
210
212
  test_cases: test_blocks.map { |block| build_test_case(block) },
211
213
  teardown: build_teardown(teardown_blocks),
212
214
  source_file: @source_path,
213
215
  metadata: { parsed_at: @parsed_at, parser: parser_type },
216
+ warnings: warnings
214
217
  )
218
+
219
+ # Validate strict mode after collecting all warnings
220
+ validate_strict_mode(testrun)
221
+
222
+ testrun
215
223
  end
216
224
 
217
225
  def build_setup(setup_blocks)
@@ -354,6 +362,9 @@ class Tryouts
354
362
  start_line: Integer => start_line,
355
363
  end_line: Integer => end_line
356
364
  }
365
+ # Collect warning for unnamed test
366
+ collect_unnamed_test_warning(block)
367
+
357
368
  source_lines = @lines[start_line..end_line]
358
369
  first_expectation_line = exp_tokens.empty? ? start_line : exp_tokens.first[:line]
359
370
 
@@ -411,6 +422,44 @@ class Tryouts
411
422
  :shared
412
423
  end
413
424
 
425
+ # Warning collection methods
426
+ def add_warning(warning)
427
+ @warnings ||= []
428
+ @warnings << warning
429
+ end
430
+
431
+ def warnings
432
+ @warnings ||= []
433
+ end
434
+
435
+ def collect_unnamed_test_warning(block)
436
+ return unless block[:type] == :test && block[:description].empty?
437
+
438
+ line_number = block[:start_line] + 1
439
+ context = @lines[block[:start_line]] || ''
440
+
441
+ add_warning(ParserWarning.unnamed_test(
442
+ line_number: line_number,
443
+ context: context.strip
444
+ ))
445
+ end
446
+
447
+ def validate_strict_mode(testrun)
448
+ return unless @options[:strict]
449
+
450
+ unnamed_test_warnings = warnings.select { |w| w.type == :unnamed_test }
451
+ return if unnamed_test_warnings.empty?
452
+
453
+ # In strict mode, fail with first unnamed test error
454
+ first_warning = unnamed_test_warnings.first
455
+ raise TryoutSyntaxError.new(
456
+ "Strict mode: #{first_warning.message} at line #{first_warning.line_number}. #{first_warning.suggestion}",
457
+ line_number: first_warning.line_number,
458
+ context: first_warning.context,
459
+ source_file: @source_path
460
+ )
461
+ end
462
+
414
463
  end
415
464
  end
416
465
  end
@@ -67,7 +67,7 @@ class Tryouts
67
67
  end
68
68
  end
69
69
 
70
- Testrun = Data.define(:setup, :test_cases, :teardown, :source_file, :metadata) do
70
+ Testrun = Data.define(:setup, :test_cases, :teardown, :source_file, :metadata, :warnings) do
71
71
  def total_tests
72
72
  test_cases.size
73
73
  end
@@ -11,6 +11,7 @@ class Tryouts
11
11
  @output_manager = output_manager
12
12
  @translator = translator
13
13
  @global_tally = global_tally
14
+
14
15
  end
15
16
 
16
17
  def execute
@@ -28,6 +29,7 @@ class Tryouts
28
29
 
29
30
  private
30
31
 
32
+
31
33
  def execute_direct_mode
32
34
  batch = TestBatch.new(
33
35
  @testrun,
@@ -29,6 +29,7 @@ class Tryouts
29
29
  @output_manager = output_manager
30
30
  @translator = initialize_translator
31
31
  @global_tally = initialize_global_tally
32
+ @file_line_specs = options[:file_line_specs] || {}
32
33
  end
33
34
 
34
35
  def run
@@ -37,7 +38,10 @@ class Tryouts
37
38
 
38
39
  result = process_files
39
40
  show_failure_summary
40
- show_grand_total if @global_tally[:aggregator].get_file_counts[:total] > 1
41
+ # Always show grand total for agent mode to ensure output, otherwise only for multiple files
42
+ if @options[:agent] || @global_tally[:aggregator].get_file_counts[:total] > 1
43
+ show_grand_total
44
+ end
41
45
 
42
46
  # For agent critical mode, only count errors as failures
43
47
  if @options[:agent] && (@options[:agent_focus] == :critical || @options[:agent_focus] == 'critical')
@@ -148,10 +152,16 @@ class Tryouts
148
152
  failure_count
149
153
  end
150
154
 
151
- def process_file(file_path)
155
+ def process_file(file)
156
+ # Pass line spec for this file if available
157
+ file_options = @options.dup
158
+ if @file_line_specs && @file_line_specs[file]
159
+ file_options[:line_spec] = @file_line_specs[file]
160
+ end
161
+
152
162
  processor = FileProcessor.new(
153
- file: file_path,
154
- options: @options,
163
+ file: file,
164
+ options: file_options,
155
165
  output_manager: @output_manager,
156
166
  translator: @translator,
157
167
  global_tally: @global_tally,
@@ -160,7 +170,7 @@ class Tryouts
160
170
  rescue StandardError => ex
161
171
  handle_file_error(ex)
162
172
  @global_tally[:aggregator].add_infrastructure_failure(
163
- :file_processing, file_path, ex.message, ex
173
+ :file_processing, file, ex.message, ex
164
174
  )
165
175
  1
166
176
  end
@@ -1,5 +1,5 @@
1
1
  # lib/tryouts/version.rb
2
2
 
3
3
  class Tryouts
4
- VERSION = '3.4.0'
4
+ VERSION = '3.5.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tryouts
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -148,6 +148,7 @@ files:
148
148
  - lib/tryouts/cli/formatters/token_budget.rb
149
149
  - lib/tryouts/cli/formatters/tty_status_display.rb
150
150
  - lib/tryouts/cli/formatters/verbose.rb
151
+ - lib/tryouts/cli/line_spec_parser.rb
151
152
  - lib/tryouts/cli/modes/generate.rb
152
153
  - lib/tryouts/cli/modes/inspect.rb
153
154
  - lib/tryouts/cli/opts.rb
@@ -169,6 +170,7 @@ files:
169
170
  - lib/tryouts/expectation_evaluators/true.rb
170
171
  - lib/tryouts/failure_collector.rb
171
172
  - lib/tryouts/file_processor.rb
173
+ - lib/tryouts/parser_warning.rb
172
174
  - lib/tryouts/parsers/base_parser.rb
173
175
  - lib/tryouts/parsers/enhanced_parser.rb
174
176
  - lib/tryouts/parsers/prism_parser.rb