gloo-test 1.4 → 1.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: 4dfc0f6425cf939267eda29265a6145d1f30db09ea0fdc7494e85d920bd17399
4
- data.tar.gz: ec80b8ccd8149243c0d3f6f458196ecd54b8dab0705082cc1328004ba3efa1ca
3
+ metadata.gz: d45d64ceab771a794397686837c89cdc210d6445ea1a5ad571a8adf206c03151
4
+ data.tar.gz: 12e63b19f0fc5b879154fd0342ec0b71713f7b39b0aa2223dfd378ed095911fc
5
5
  SHA512:
6
- metadata.gz: 83092cf5af2264484ca3d1fcee69e93746e01d4e7ba307e4e4d85db471fae053d92e0b385c96d4f65c1d59d8f9491874478507fb2976cff1d2bb0f901ad055e7
7
- data.tar.gz: f3e4e1688f1390b1056e07006cbf1b98ba261dcf3557ca14491701ef0b827fd737739c96e92111c4851c372f3ca9db8e0caecddbc931b52778e0a49cda2cbe47
6
+ metadata.gz: f9f68a81433842cc62addbaeb7e8ce0e397e6381bf302c3540b9a3d4adb92678c95c32cfbad099fe8bcc44cbe99b9a14120d8d4dcd463e9ccc164c843b845a5c
7
+ data.tar.gz: 1bb732dd212399291ed6bba31bcb9dabaf9872b783a36589bcc6e484d4510abee7e755915d7bb5fb4fce592d8215946b6cf858f0494428696cec3c2889cc4b4c
data/lib/result.rb CHANGED
@@ -7,8 +7,8 @@ class Result
7
7
  EXPECTED_FAIL_MSG = 'expected this test to fail, but no assertion failed'.freeze
8
8
 
9
9
  attr_accessor :passed, :assert_count, :refute_count,
10
- :error_count, :warning_count, :expect_errors
11
- attr_reader :pn
10
+ :error_count, :warning_count, :expect_errors, :skipped
11
+ attr_reader :pn, :test_desc
12
12
 
13
13
  #
14
14
  # Set up the result for the given test.
@@ -29,6 +29,8 @@ class Result
29
29
  @expect_errors = false
30
30
 
31
31
  @passed = true
32
+ # Set aside with skip: not run, and neither passed nor failed.
33
+ @skipped = false
32
34
  @failure_msg = ''
33
35
  end
34
36
 
@@ -58,7 +60,7 @@ class Result
58
60
  # Show the test result symbol.
59
61
  #
60
62
  def show_result_symbol
61
- print @passed ? '.' : 'x'
63
+ print @skipped ? 's' : ( @passed ? '.' : 'x' )
62
64
  end
63
65
 
64
66
  #
data/lib/results.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  class Results
6
6
 
7
7
  attr_accessor :file_count, :test_count,
8
- :pass_count, :fail_count, :assert_count
8
+ :pass_count, :fail_count, :assert_count, :skip_count
9
9
 
10
10
  #
11
11
  # Set up the results collection.
@@ -15,10 +15,12 @@ class Results
15
15
 
16
16
  @all_results = []
17
17
  @failures = []
18
+ @skipped = []
18
19
 
19
20
  @file_count = 0
20
21
  @pass_count = 0
21
22
  @fail_count = 0
23
+ @skip_count = 0
22
24
  @assert_count = 0
23
25
 
24
26
  @engine.log.debug "Results initialized"
@@ -59,6 +61,12 @@ class Results
59
61
  #
60
62
  def add_result( result )
61
63
  @all_results << result
64
+ if result.skipped
65
+ @skipped << result
66
+ @skip_count += 1
67
+ return
68
+ end
69
+
62
70
  @failures << result unless result.passed
63
71
 
64
72
  @pass_count += 1 if result.passed
@@ -112,6 +120,20 @@ class Results
112
120
  end
113
121
  end
114
122
 
123
+ #
124
+ # Show the skipped tests, so they aren't forgotten: each one's path
125
+ # and description. The reason is in a comment above it in the file.
126
+ #
127
+ def show_skipped
128
+ return unless @skip_count.positive?
129
+
130
+ theme = @engine.theme
131
+ puts
132
+ puts theme.warn( "*** Skipped (#{@skip_count}) ***" )
133
+ puts
134
+ @skipped.each { |r| puts "#{r.pn} -> #{r.test_desc}" }
135
+ end
136
+
115
137
  #
116
138
  # Get a textual summary of the results.
117
139
  #
@@ -123,6 +145,8 @@ class Results
123
145
  else
124
146
  str += theme.emphasis( " Failed: #{@fail_count} " )
125
147
  end
148
+ # Only when there are any, so a run without them reads as before.
149
+ str += theme.warn( "• Skipped: #{@skip_count} " ) if @skip_count.positive?
126
150
  str += theme.accent( "\n Assertions: #{@assert_count} • Files: #{@file_count}" )
127
151
  return str
128
152
  end
data/lib/test.rb CHANGED
@@ -8,6 +8,7 @@ class Test < Gloo::Core::Obj
8
8
  ON_TEST_EVENT = 'on_test'.freeze
9
9
  EXPECT_ERRORS = 'expect_errors'.freeze
10
10
  EXPECT_FAIL = 'expect_fail'.freeze
11
+ SKIP = 'skip'.freeze
11
12
 
12
13
 
13
14
  #
@@ -49,6 +50,14 @@ class Test < Gloo::Core::Obj
49
50
  return flag_set?( EXPECT_FAIL )
50
51
  end
51
52
 
53
+ #
54
+ # Is the test set aside, not to be run?
55
+ # Set with an optional skip [bool] child.
56
+ #
57
+ def skip?
58
+ return flag_set?( SKIP )
59
+ end
60
+
52
61
  #
53
62
  # Is the named bool child present and true?
54
63
  #
@@ -95,6 +104,13 @@ class Test < Gloo::Core::Obj
95
104
  #
96
105
  def run_test
97
106
  result = Result.new( @engine, self )
107
+ if skip?
108
+ # Not run: counted and listed as skipped instead.
109
+ result.skipped = true
110
+ result.show_result_symbol
111
+ return result
112
+ end
113
+
98
114
  errors_before = @engine.log.error_count
99
115
  warnings_before = @engine.log.warning_count
100
116
 
@@ -139,7 +155,8 @@ class Test < Gloo::Core::Obj
139
155
  'description (string) — A textual description of the test and desired outcome, used in output if there is an error.',
140
156
  'on_test (script) — The script to run when the test is executed. Note that the normal way to run tests is with gloo --test.',
141
157
  'expect_errors (bool) — Optional. Set to true for a test that triggers errors or warnings on purpose (eg. to check on_error); they are left out of the summary of what was logged during the run.',
142
- 'expect_fail (bool) — Optional. Set to true for a test that is meant to fail: it passes if at least one assertion fails, and fails if none does. It can\'t tell which assertion failed, or why, so keep such a test to the one thing it checks.'
158
+ 'expect_fail (bool) — Optional. Set to true for a test that is meant to fail: it passes if at least one assertion fails, and fails if none does. It can\'t tell which assertion failed, or why, so keep such a test to the one thing it checks.',
159
+ 'skip (bool) — Optional. Set to true to set the test aside: its on_test isn\'t run, it\'s shown as s, and it\'s counted and listed as skipped after the run (a run with skipped tests and no failures still passes). Give the reason in a comment on the line above; text after the : is the value, so a comment there makes the flag not true.'
143
160
  ],
144
161
  :examples => <<~EXAMPLES.strip
145
162
  #
data/lib/test_runner.rb CHANGED
@@ -30,6 +30,7 @@ class TestRunner
30
30
  run_for_files
31
31
  @results.end_timer
32
32
 
33
+ @results.show_skipped
33
34
  @results.show_failures
34
35
  @results.show_results
35
36
  @engine.log.debug "TestRunner is finished"
@@ -63,15 +64,17 @@ class TestRunner
63
64
 
64
65
  #
65
66
  # Run tests for a single file.
66
- # Once done, reset the engine's state.
67
+ # Once done, reset the session: an empty heap, and every library or
68
+ # extension the file loaded unloaded again (except pinned ones, such
69
+ # as gloo-test itself), so the next file starts with only what it
70
+ # loads, whatever order the files run in.
67
71
  #
68
72
  def run_one_file( file )
69
73
  # Run all tests in the file
70
74
  # Add the results to the overall results
71
75
  file.run_tests( @results )
72
76
 
73
- # Reset the engine's state
74
- @engine.reset_state
77
+ @engine.reset_session
75
78
  end
76
79
  end
77
80
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gloo-test
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.4'
4
+ version: '1.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Crane
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '7.0'
18
+ version: '7.3'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: '7.0'
25
+ version: '7.3'
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: bundler
28
28
  requirement: !ruby/object:Gem::Requirement