ttytest2 0.9.9 → 0.9.11
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 +4 -4
- data/.bundle/config +2 -0
- data/lib/ttytest/constants.rb +10 -4
- data/lib/ttytest/matchers.rb +14 -0
- data/lib/ttytest/terminal.rb +3 -3
- data/lib/ttytest/tmux/driver.rb +1 -1
- data/lib/ttytest/tmux/session.rb +7 -6
- data/lib/ttytest/version.rb +1 -1
- data/notes.txt +2 -2
- data/ttytest2.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3ee6dc964334b3c1a099faf8a5f4701b8a594fc0e948f02ae11f233d612c55bd
|
|
4
|
+
data.tar.gz: e27455bec4bbb72e73b264ccf4261c3ff75a47a6ae52459cc7d302fcb789c3a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8d15dba3585a6a82a3d6f67749bc90ad58d750ecf6c30971ab3b99df8be56343f03488dba2161c3ee299a4cfc6b9c3362b013e7c6e6b7870cf663defbac90ece
|
|
7
|
+
data.tar.gz: 49d7505801519f03ecd0b6dc2c0dadf8ed0cb7b3c203ddac23b25f1739942e21206a0aed6603443aadfa38e1d8bd86a38c01b64165e6bf0d4900b8a00ad64bf7
|
data/.bundle/config
ADDED
data/lib/ttytest/constants.rb
CHANGED
|
@@ -2,17 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
# some constants that can be used with send_keys, just to help out people creating tests
|
|
4
4
|
module TTYtest
|
|
5
|
+
CTRLA = 1.chr
|
|
6
|
+
CTRLB = 2.chr
|
|
5
7
|
CTRLC = 3.chr
|
|
6
8
|
CTRLD = 4.chr
|
|
7
9
|
CTRLF = 6.chr
|
|
8
10
|
BELL = 7.chr
|
|
9
11
|
BACKSPACE = 8.chr
|
|
10
|
-
TAB = 9.chr
|
|
12
|
+
TAB = 9.chr # \t
|
|
11
13
|
NEWLINE = 10.chr # \n
|
|
12
|
-
VERTICAL_TAB = 11.chr
|
|
13
|
-
FORM_FEED = 12.chr
|
|
14
|
+
VERTICAL_TAB = 11.chr # \v
|
|
15
|
+
FORM_FEED = 12.chr # \f
|
|
16
|
+
CTRLL = 12.chr
|
|
14
17
|
CARRIAGE_RETURN = 13.chr # \r
|
|
15
|
-
|
|
18
|
+
CTRLU = 21.chr
|
|
19
|
+
CTRLW = 23.chr
|
|
20
|
+
ESCAPE = 27.chr # ^[ or /033 or /e
|
|
21
|
+
CTRL_ = 31.chr
|
|
16
22
|
DELETE = 127.chr
|
|
17
23
|
|
|
18
24
|
UP_ARROW = "#{ESCAPE}[A".freeze
|
data/lib/ttytest/matchers.rb
CHANGED
|
@@ -73,6 +73,20 @@ module TTYtest
|
|
|
73
73
|
"expected row #{row_number} to end with #{expected.inspect} and got #{actual.inspect}\nEntire screen:\n#{self}"
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
+
# Asserts the contents of a single row match against the passed in regular expression
|
|
77
|
+
# @param [Integer] row_number the row (starting from 0) to test against
|
|
78
|
+
# @param [String] regexp_str the regular expression as a string that will be used to match with.
|
|
79
|
+
# @raise [MatchError] if the row doesn't match against the regular expression
|
|
80
|
+
def assert_row_regexp(row_number, regexp_str)
|
|
81
|
+
regexp = Regexp.new(regexp_str)
|
|
82
|
+
actual = row(row_number)
|
|
83
|
+
|
|
84
|
+
return if actual.match?(regexp)
|
|
85
|
+
|
|
86
|
+
raise MatchError,
|
|
87
|
+
"expected row #{row_number} to match regexp #{regexp_str} but it did not. Row value #{actual.inspect}\nEntire screen:\n#{self}"
|
|
88
|
+
end
|
|
89
|
+
|
|
76
90
|
# Asserts that the cursor is in the expected position
|
|
77
91
|
# @param [Integer] x cursor x (row) position, starting from 0
|
|
78
92
|
# @param [Integer] y cursor y (column) position, starting from 0
|
data/lib/ttytest/terminal.rb
CHANGED
|
@@ -13,9 +13,9 @@ module TTYtest
|
|
|
13
13
|
|
|
14
14
|
# @api private
|
|
15
15
|
# @see TTYtest.new_terminal
|
|
16
|
-
def initialize(driver_terminal
|
|
16
|
+
def initialize(driver_terminal)
|
|
17
17
|
@driver_terminal = driver_terminal
|
|
18
|
-
@max_wait_time =
|
|
18
|
+
@max_wait_time = TTYtest.default_max_wait_time
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
# @!method send_keys(*keys)
|
|
@@ -116,7 +116,7 @@ module TTYtest
|
|
|
116
116
|
:cursor_x, :cursor_y,
|
|
117
117
|
:cursor_visible?, :cursor_hidden?
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
Matchers::METHODS.each do |matcher_name|
|
|
120
120
|
define_method matcher_name do |*args|
|
|
121
121
|
synchronize do
|
|
122
122
|
capture.public_send(matcher_name, *args)
|
data/lib/ttytest/tmux/driver.rb
CHANGED
|
@@ -45,7 +45,7 @@ module TTYtest
|
|
|
45
45
|
puts "tmux(#{args.inspect[1...-1]})" if debug?
|
|
46
46
|
|
|
47
47
|
stdout, stderr, status = Open3.capture3(@tmux_cmd, '-L', SOCKET_NAME, *args)
|
|
48
|
-
raise TmuxError, "tmux(#{args.inspect[1...-1]}) failed\n#{stderr}" unless status.success?
|
|
48
|
+
raise TmuxError, "tmux(#{args.inspect[1...-1]}) failed\n#{stderr}" unless !status.nil? && status.success?
|
|
49
49
|
|
|
50
50
|
stdout
|
|
51
51
|
end
|
data/lib/ttytest/tmux/session.rb
CHANGED
|
@@ -6,17 +6,18 @@ module TTYtest
|
|
|
6
6
|
class Session
|
|
7
7
|
# @api private
|
|
8
8
|
def initialize(driver, name)
|
|
9
|
+
@id = SecureRandom.uuid
|
|
9
10
|
@driver = driver
|
|
10
11
|
@name = name
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
ObjectSpace.define_finalizer(@id, proc {
|
|
14
|
+
begin
|
|
15
|
+
driver.tmux(*%W[kill-session -t #{name}])
|
|
16
|
+
rescue ThreadError => _e # final session always throws, ThreadError can't alloc new
|
|
17
|
+
end
|
|
18
|
+
})
|
|
13
19
|
end
|
|
14
20
|
|
|
15
|
-
# @api private
|
|
16
|
-
# def self.finalize(driver, name)
|
|
17
|
-
# proc { driver.tmux(*%W[kill-session -t #{name}]) }
|
|
18
|
-
# end
|
|
19
|
-
|
|
20
21
|
def capture
|
|
21
22
|
contents = driver.tmux(*%W[capture-pane -t #{name} -p])
|
|
22
23
|
str = driver.tmux(*%W[display-message -t #{name} -p
|
data/lib/ttytest/version.rb
CHANGED
data/notes.txt
CHANGED
data/ttytest2.gemspec
CHANGED
|
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
|
|
|
26
26
|
|
|
27
27
|
spec.add_development_dependency 'bundler', '~> 2.4'
|
|
28
28
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
|
29
|
+
spec.add_development_dependency 'open3', '~> 0.2'
|
|
29
30
|
spec.add_development_dependency 'rake', '~> 13.0'
|
|
30
31
|
spec.add_development_dependency 'yard', '~> 0.9'
|
|
31
32
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ttytest2
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alex Eski
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-01-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -38,6 +38,20 @@ dependencies:
|
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '5.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: open3
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0.2'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0.2'
|
|
41
55
|
- !ruby/object:Gem::Dependency
|
|
42
56
|
name: rake
|
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -74,6 +88,7 @@ executables: []
|
|
|
74
88
|
extensions: []
|
|
75
89
|
extra_rdoc_files: []
|
|
76
90
|
files:
|
|
91
|
+
- ".bundle/config"
|
|
77
92
|
- ".github/workflows/test.yml"
|
|
78
93
|
- ".gitignore"
|
|
79
94
|
- Gemfile
|