tldr 0.1.0

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.
@@ -0,0 +1,62 @@
1
+ class TLDR
2
+ TestResult = Struct.new :test, :error, :runtime do
3
+ attr_reader :type, :error_location
4
+
5
+ def initialize(*args)
6
+ super
7
+ @type = determine_type
8
+ @error_location = determine_error_location
9
+ end
10
+
11
+ def passing?
12
+ success? || skip?
13
+ end
14
+
15
+ def failing?
16
+ !passing?
17
+ end
18
+
19
+ def success?
20
+ type == :success
21
+ end
22
+
23
+ def skip?
24
+ type == :skip
25
+ end
26
+
27
+ def failure?
28
+ type == :failure
29
+ end
30
+
31
+ def error?
32
+ type == :error
33
+ end
34
+
35
+ def relevant_location
36
+ error_location || test.location
37
+ end
38
+
39
+ private
40
+
41
+ def determine_type
42
+ if error.nil?
43
+ :success
44
+ elsif error.is_a?(Failure)
45
+ :failure
46
+ elsif error.is_a?(Skip)
47
+ :skip
48
+ else
49
+ :error
50
+ end
51
+ end
52
+
53
+ def determine_error_location
54
+ return if error.nil?
55
+
56
+ raised_at = TLDR.filter_backtrace(error.backtrace).first
57
+ if (raise_matches = raised_at.match(/^(.*):(\d+):in .*$/))
58
+ Location.new(raise_matches[1], raise_matches[2].to_i)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,3 @@
1
+ class TLDR
2
+ WIPTest = Struct.new :test, :start_time
3
+ end
data/lib/tldr/value.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "tldr/value/config"
2
+ require "tldr/value/plan"
3
+ require "tldr/value/test"
4
+ require "tldr/value/wip_test"
5
+ require "tldr/value/test_result"
6
+ require "tldr/value/location"
@@ -0,0 +1,3 @@
1
+ class TLDR
2
+ VERSION = "0.1.0"
3
+ end
data/lib/tldr.rb ADDED
@@ -0,0 +1,41 @@
1
+ require_relative "tldr/version"
2
+ require_relative "tldr/backtrace_filter"
3
+ require_relative "tldr/error"
4
+ require_relative "tldr/value"
5
+ require_relative "tldr/reporters"
6
+ require_relative "tldr/argv_parser"
7
+ require_relative "tldr/planner"
8
+ require_relative "tldr/runner"
9
+ require_relative "tldr/assertions"
10
+ require_relative "tldr/skippable"
11
+ require_relative "tldr/sorbet_compatibility"
12
+
13
+ class TLDR
14
+ include Assertions
15
+ include Skippable
16
+
17
+ module Run
18
+ def self.cli argv
19
+ config = ArgvParser.new.parse argv
20
+ tests config
21
+ end
22
+
23
+ def self.tests config = Config.new
24
+ Runner.new.run config, Planner.new.plan(config)
25
+ end
26
+
27
+ @@at_exit_registered = false
28
+ def self.at_exit! config = Config.new
29
+ # Ignore at_exit when running tldr CLI, since that will run any tests
30
+ return if $PROGRAM_NAME.end_with? "tldr"
31
+ # Ignore at_exit when we've already registered an at_exit hook
32
+ return if @@at_exit_registered
33
+
34
+ Kernel.at_exit do
35
+ Run.tests config
36
+ end
37
+
38
+ @@at_exit_registered = true
39
+ end
40
+ end
41
+ end
data/script/parse ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
3
+
4
+ require "tldr"
5
+
6
+ pp TLDR::ArgvParser.new.parse(ARGV).to_h
data/script/run ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
3
+
4
+ require "tldr"
5
+
6
+ TLDR::Run.cli(ARGV)
data/script/test ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
3
+
4
+ require "tldr"
5
+
6
+ class FunTest < TLDR
7
+ def test_passes
8
+ assert true
9
+ end
10
+
11
+ def test_false
12
+ assert false
13
+ end
14
+
15
+ def test_hello
16
+ raise "💥"
17
+ end
18
+
19
+ def test_slow
20
+ skip
21
+ sleep 2
22
+ end
23
+ end
24
+
25
+ TLDR::Run.run(TLDR::Config.new(paths: []))
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tldr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Justin Searls
8
+ - Aaron Patterson
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2023-09-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: super_diff
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '0.10'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '0.10'
28
+ - !ruby/object:Gem::Dependency
29
+ name: concurrent-ruby
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.2'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.2'
42
+ description:
43
+ email:
44
+ - searls@gmail.com
45
+ - tenderlove@ruby-lang.org
46
+ executables:
47
+ - tldr
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - ".standard.yml"
52
+ - CHANGELOG.md
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - exe/tldr
57
+ - lib/tldr.rb
58
+ - lib/tldr/argv_parser.rb
59
+ - lib/tldr/assertions.rb
60
+ - lib/tldr/assertions/minitest_compatibility.rb
61
+ - lib/tldr/backtrace_filter.rb
62
+ - lib/tldr/error.rb
63
+ - lib/tldr/planner.rb
64
+ - lib/tldr/reporters.rb
65
+ - lib/tldr/reporters/base.rb
66
+ - lib/tldr/reporters/default.rb
67
+ - lib/tldr/reporters/icon_provider.rb
68
+ - lib/tldr/runner.rb
69
+ - lib/tldr/skippable.rb
70
+ - lib/tldr/sorbet_compatibility.rb
71
+ - lib/tldr/value.rb
72
+ - lib/tldr/value/config.rb
73
+ - lib/tldr/value/location.rb
74
+ - lib/tldr/value/plan.rb
75
+ - lib/tldr/value/test.rb
76
+ - lib/tldr/value/test_result.rb
77
+ - lib/tldr/value/wip_test.rb
78
+ - lib/tldr/version.rb
79
+ - script/parse
80
+ - script/run
81
+ - script/test
82
+ homepage: https://github.com/tenderlove/tldr
83
+ licenses:
84
+ - MIT
85
+ metadata:
86
+ homepage_uri: https://github.com/tenderlove/tldr
87
+ source_code_uri: https://github.com/tenderlove/tldr
88
+ changelog_uri: https://github.com/tenderlove/tldr/blob/main/CHANGELOG.md
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: 3.2.0
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubygems_version: 3.4.6
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: TLDR will run your tests, but only for 1.8 seconds.
108
+ test_files: []