vimamsa 0.1.26 → 0.1.27

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.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/appimage.yml +93 -0
  3. data/.gitignore +4 -1
  4. data/Dockerfile +7 -4
  5. data/README.md +62 -16
  6. data/custom_example.rb +43 -13
  7. data/doc/TODO.md +461 -0
  8. data/doc/bundling_plan.md +569 -0
  9. data/doc/key_bindings_report_plan.md +168 -0
  10. data/doc/missing_vim_bindings.md +71 -0
  11. data/doc/modules_settings_plan.md +433 -0
  12. data/doc/refactor_dedup_plan.md +117 -0
  13. data/doc/unused_code_plan.md +120 -0
  14. data/doc/vim_compatibility_plan.md +296 -0
  15. data/doc/vimlike_vim_conflicts.md +254 -0
  16. data/doc/vm_snapshots_plan.md +146 -0
  17. data/exe/run_tests.rb +117 -3
  18. data/exe/vimamsa +24 -4
  19. data/fonts/OFL-Oxanium.txt +93 -0
  20. data/fonts/Oxanium[wght].ttf +0 -0
  21. data/icon.png +0 -0
  22. data/img/demo.gif +0 -0
  23. data/lang/hyperplaintext.lang +6 -0
  24. data/lib/vimamsa/ack.rb +11 -1
  25. data/lib/vimamsa/actions.rb +4 -1
  26. data/lib/vimamsa/appimage_env.rb +35 -0
  27. data/lib/vimamsa/audio.rb +2 -5
  28. data/lib/vimamsa/bookmarks.rb +302 -0
  29. data/lib/vimamsa/buffer.rb +593 -82
  30. data/lib/vimamsa/buffer_changetext.rb +102 -42
  31. data/lib/vimamsa/buffer_cursor.rb +7 -0
  32. data/lib/vimamsa/buffer_list.rb +4 -0
  33. data/lib/vimamsa/buffer_manager.rb +4 -1
  34. data/lib/vimamsa/bundled_fonts.rb +32 -0
  35. data/lib/vimamsa/clipboard.rb +3 -0
  36. data/lib/vimamsa/conf.rb +59 -3
  37. data/lib/vimamsa/constants.rb +3 -0
  38. data/lib/vimamsa/crash_handler.rb +149 -0
  39. data/lib/vimamsa/debug.rb +4 -1
  40. data/lib/vimamsa/desktop_install.rb +96 -0
  41. data/lib/vimamsa/diff_buffer.rb +39 -10
  42. data/lib/vimamsa/easy_jump.rb +3 -0
  43. data/lib/vimamsa/editor.rb +263 -57
  44. data/lib/vimamsa/encrypt.rb +78 -29
  45. data/lib/vimamsa/file_finder.rb +4 -19
  46. data/lib/vimamsa/file_history.rb +3 -0
  47. data/lib/vimamsa/file_manager.rb +30 -15
  48. data/lib/vimamsa/fold.rb +226 -0
  49. data/lib/vimamsa/gui.rb +520 -106
  50. data/lib/vimamsa/gui_command_line.rb +208 -0
  51. data/lib/vimamsa/gui_dialog.rb +94 -42
  52. data/lib/vimamsa/gui_file_panel.rb +356 -25
  53. data/lib/vimamsa/gui_form_generator.rb +59 -35
  54. data/lib/vimamsa/gui_func_panel.rb +67 -22
  55. data/lib/vimamsa/gui_image.rb +3 -0
  56. data/lib/vimamsa/gui_keylog_panel.rb +246 -0
  57. data/lib/vimamsa/gui_menu.rb +23 -11
  58. data/lib/vimamsa/gui_select_window.rb +19 -48
  59. data/lib/vimamsa/gui_settings.rb +78 -37
  60. data/lib/vimamsa/gui_sourceview.rb +273 -19
  61. data/lib/vimamsa/gui_sourceview_autocomplete.rb +319 -90
  62. data/lib/vimamsa/gui_text.rb +63 -2
  63. data/lib/vimamsa/gui_theme.rb +606 -0
  64. data/lib/vimamsa/hook.rb +3 -0
  65. data/lib/vimamsa/hyper_plain_text.rb +3 -0
  66. data/lib/vimamsa/key_actions.rb +112 -13
  67. data/lib/vimamsa/key_binding_tree.rb +242 -215
  68. data/lib/vimamsa/key_bindings_notepad.rb +43 -0
  69. data/lib/vimamsa/key_bindings_report.rb +261 -0
  70. data/lib/vimamsa/key_bindings_vim.rb +354 -0
  71. data/lib/vimamsa/key_bindings_vimlike.rb +65 -9
  72. data/lib/vimamsa/langservp.rb +271 -54
  73. data/lib/vimamsa/macro.rb +3 -0
  74. data/lib/vimamsa/main.rb +14 -8
  75. data/lib/vimamsa/rbvma.rb +26 -1
  76. data/lib/vimamsa/search.rb +3 -0
  77. data/lib/vimamsa/search_replace.rb +11 -10
  78. data/lib/vimamsa/string_util.rb +120 -40
  79. data/lib/vimamsa/terminal.rb +3 -0
  80. data/lib/vimamsa/test_framework.rb +28 -2
  81. data/lib/vimamsa/tests.rb +3 -0
  82. data/lib/vimamsa/text_objects.rb +353 -0
  83. data/lib/vimamsa/text_transforms.rb +14 -0
  84. data/lib/vimamsa/util.rb +46 -7
  85. data/lib/vimamsa/version.rb +1 -1
  86. data/lib/vimamsa.rb +0 -1
  87. data/modules/color_highlight/color_highlight.rb +118 -0
  88. data/modules/color_highlight/color_highlight_info.rb +3 -0
  89. data/modules/dictation/dictation.rb +1054 -0
  90. data/modules/dictation/dictation_info.rb +3 -0
  91. data/modules/dictation/whisper_worker.py +273 -0
  92. data/modules/ollama/ollama.rb +107 -0
  93. data/modules/ollama/ollama_info.rb +3 -0
  94. data/modules/tts/tts.rb +119 -0
  95. data/modules/tts/tts_info.rb +3 -0
  96. data/run_e2e_vm.sh +28 -0
  97. data/run_tests_vm.sh +130 -0
  98. data/scripts/appimage/AppRun +54 -0
  99. data/scripts/appimage/Dockerfile +18 -0
  100. data/scripts/appimage/build.sh +19 -0
  101. data/scripts/appimage/build_in_container.sh +192 -0
  102. data/scripts/appimage/smoke_test.sh +27 -0
  103. data/scripts/demo/demo_steps.txt +59 -0
  104. data/scripts/demo/record_demo.rb +177 -0
  105. data/scripts/demo/shapes.rb +28 -0
  106. data/styles/134272-molokai.xml +3 -0
  107. data/styles/molokai_cyber.xml +48 -0
  108. data/styles/molokai_edit.xml +1 -0
  109. data/tests/support/virtual_keyboard.rb +254 -0
  110. data/tests/support/virtual_mic.rb +67 -0
  111. data/tests/test_ack.rb +22 -0
  112. data/tests/test_auto_format.rb +122 -0
  113. data/tests/test_autocomplete.rb +211 -0
  114. data/tests/test_autosave.rb +145 -0
  115. data/tests/test_basic_editing.rb +33 -3
  116. data/tests/test_bookmarks.rb +206 -0
  117. data/tests/test_bracket_match.rb +85 -0
  118. data/tests/test_bundling.rb +92 -0
  119. data/tests/test_color_highlight.rb +92 -0
  120. data/tests/test_command_line.rb +79 -0
  121. data/tests/test_command_line_file.rb +27 -0
  122. data/tests/test_context_menu_file.rb +129 -0
  123. data/tests/test_copy_paste.rb +80 -0
  124. data/tests/test_crash_handler.rb +39 -0
  125. data/tests/test_custom_two_phase.rb +92 -0
  126. data/tests/test_dialog_callback_errors.rb +44 -0
  127. data/tests/test_dictation.rb +294 -0
  128. data/tests/test_diff_buffer_name.rb +51 -0
  129. data/tests/test_double_click.rb +41 -0
  130. data/tests/test_drag_selection.rb +125 -0
  131. data/tests/test_e2e_cmdline.rb +116 -0
  132. data/tests/test_e2e_dictation.rb +98 -0
  133. data/tests/test_e2e_replace_char.rb +58 -0
  134. data/tests/test_extract_file_links.rb +55 -0
  135. data/tests/test_file_format.rb +217 -0
  136. data/tests/test_file_manager.rb +72 -0
  137. data/tests/test_file_panel.rb +269 -0
  138. data/tests/test_flash.rb +78 -0
  139. data/tests/test_fold.rb +111 -0
  140. data/tests/test_font_refresh.rb +56 -0
  141. data/tests/test_func_panel.rb +68 -0
  142. data/tests/test_grep_apply.rb +46 -0
  143. data/tests/test_gtk_sync.rb +126 -0
  144. data/tests/test_hpt_highlight_visible.rb +75 -0
  145. data/tests/test_hpt_link_highlight.rb +82 -0
  146. data/tests/test_jump_to_file.rb +41 -0
  147. data/tests/test_key_bindings.rb +208 -0
  148. data/tests/test_keylog_panel.rb +101 -0
  149. data/tests/test_lsp_clangd.rb +281 -0
  150. data/tests/test_lsp_jump.rb +87 -0
  151. data/tests/test_lsp_position_encoding.rb +49 -0
  152. data/tests/test_lsp_symbols.rb +68 -0
  153. data/tests/test_macro.rb +137 -0
  154. data/tests/test_markdown_highlight.rb +57 -0
  155. data/tests/test_mode_badge.rb +41 -0
  156. data/tests/test_notepad_bindings.rb +67 -0
  157. data/tests/test_popup_queue.rb +51 -0
  158. data/tests/test_random_edit.rb +109 -0
  159. data/tests/test_revert.rb +127 -0
  160. data/tests/test_startup_file.rb +58 -0
  161. data/tests/test_status_area.rb +50 -0
  162. data/tests/test_text_objects.rb +163 -0
  163. data/tests/test_text_transforms.rb +329 -0
  164. data/tests/test_tts.rb +68 -0
  165. data/tests/test_vim_bindings.rb +252 -0
  166. data/tests/test_vim_conflicts.rb +63 -0
  167. data/tests/test_window_layout.rb +219 -0
  168. data/vimamsa.gemspec +3 -1
  169. data/vm_guest_run.sh +109 -0
  170. metadata +112 -10
data/lib/vimamsa/main.rb CHANGED
@@ -1,11 +1,3 @@
1
- #scriptdir=File.expand_path(File.dirname(__FILE__))
2
- $:.unshift File.dirname(__FILE__) + "/lib"
3
-
4
- #/home/samsam/Drive/code/vimamsa/git/lib/vimamsa/lib/vimamsa/main.rb require 'benchmark/ips'
5
-
6
- # load "vendor/ver/lib/ver/vendor/textpow.rb"
7
- # load "vendor/ver/lib/ver/syntax/detector.rb"
8
- # load "vendor/ver/config/detect.rb"
9
1
 
10
2
  require "differ"
11
3
  module Differ
@@ -16,6 +8,18 @@ module Differ
16
8
  end
17
9
  end
18
10
 
11
+ module Vimamsa
12
+ #scriptdir=File.expand_path(File.dirname(__FILE__))
13
+ $:.unshift File.dirname(__FILE__) + "/lib"
14
+
15
+ #/home/samsam/Drive/code/vimamsa/git/lib/vimamsa/lib/vimamsa/main.rb require 'benchmark/ips'
16
+
17
+ # load "vendor/ver/lib/ver/vendor/textpow.rb"
18
+ # load "vendor/ver/lib/ver/syntax/detector.rb"
19
+ # load "vendor/ver/config/detect.rb"
20
+
21
+
22
+
19
23
  Encoding.default_external = Encoding::UTF_8
20
24
  Encoding.default_internal = Encoding::UTF_8
21
25
 
@@ -48,6 +52,7 @@ require "vimamsa/editor.rb"
48
52
  require "vimamsa/diff_buffer"
49
53
 
50
54
  $vma = Editor.new
55
+ # @return [Editor]
51
56
  def vma()
52
57
  return $vma
53
58
  end
@@ -58,3 +63,4 @@ end
58
63
 
59
64
 
60
65
 
66
+ end # module Vimamsa
data/lib/vimamsa/rbvma.rb CHANGED
@@ -1,4 +1,14 @@
1
1
 
2
+ module Vimamsa
3
+ extend self
4
+
5
+ # Make all Vimamsa methods callable as bare method calls from any class.
6
+ # Must run before any Vimamsa sub-files are required so that ConfId/Conf
7
+ # can resolve set/get as instance methods at load time.
8
+ class Object
9
+ include Vimamsa
10
+ end
11
+
2
12
  # require "bundler/setup"
3
13
  require "date"
4
14
  require "fileutils"
@@ -17,23 +27,33 @@ require "uri"
17
27
  require "vimamsa/conf"
18
28
  require "vimamsa/util"
19
29
  require "vimamsa/string_util"
30
+ # Clipboard must load before main: main.rb runs Editor.new at load time,
31
+ # and Editor#initialize creates a Clipboard.
32
+ require "vimamsa/clipboard"
20
33
  # exit!
21
34
  require "vimamsa/main"
22
35
  require "vimamsa/terminal"
23
36
 
24
37
  require "vimamsa/key_binding_tree"
38
+ require "vimamsa/key_bindings_report"
25
39
 
26
- require "vimamsa/clipboard"
40
+ require "vimamsa/desktop_install"
41
+ require "vimamsa/appimage_env"
27
42
 
28
43
  # Graphical stuff:
44
+ require "vimamsa/bundled_fonts"
45
+ Vimamsa::BundledFonts.setup! # install bundled Oxanium before the GUI renders
29
46
  require "vimamsa/gui"
30
47
  require "vimamsa/gui_form_generator"
31
48
  require "vimamsa/gui_text"
32
49
  require "vimamsa/gui_menu"
33
50
  require "vimamsa/gui_dialog"
51
+ require "vimamsa/gui_command_line"
34
52
  require "vimamsa/gui_settings"
53
+ require "vimamsa/gui_theme"
35
54
  require "vimamsa/gui_file_panel"
36
55
  require "vimamsa/gui_func_panel"
56
+ require "vimamsa/gui_keylog_panel"
37
57
  require "vimamsa/gui_select_window"
38
58
  require "vimamsa/gui_sourceview"
39
59
  require "vimamsa/gui_sourceview_autocomplete"
@@ -44,11 +64,15 @@ require "vimamsa/ack"
44
64
  require "vimamsa/buffer"
45
65
  require "vimamsa/buffer_cursor"
46
66
  require "vimamsa/buffer_changetext"
67
+ require "vimamsa/text_objects"
68
+ require "vimamsa/fold"
47
69
  # require "vimamsa/buffer_list"
48
70
  require "vimamsa/buffer_list"
49
71
  require "vimamsa/buffer_manager"
72
+ require "vimamsa/bookmarks"
50
73
  require "vimamsa/constants"
51
74
  require "vimamsa/debug"
75
+ require "vimamsa/crash_handler"
52
76
  require "vimamsa/tests"
53
77
  require "vimamsa/test_framework"
54
78
  require "vimamsa/easy_jump"
@@ -71,3 +95,4 @@ cnf.debug = false
71
95
  $update_cursor = false
72
96
 
73
97
 
98
+ end # module Vimamsa
@@ -1,4 +1,6 @@
1
1
 
2
+ module Vimamsa
3
+
2
4
  def execute_search(input_str)
3
5
  $search = Search.new
4
6
  eval_str="execute_search(#{input_str.dump})"
@@ -95,3 +97,4 @@ class Search
95
97
  end
96
98
 
97
99
 
100
+ end # module Vimamsa
@@ -1,4 +1,6 @@
1
1
 
2
+ module Vimamsa
3
+
2
4
  class FileSelector
3
5
  def initialize()
4
6
  @buf = nil
@@ -67,16 +69,6 @@ class Grep
67
69
  def self.init()
68
70
  vma.kbd.add_minor_mode("grep", :grep, :command)
69
71
 
70
- if cnf.experimental?
71
- bindkey "grep shift!", [:grep_apply_changes, proc {
72
- if vma.buf.module.class == Grep
73
- vma.buf.module.apply_changes
74
- else
75
- debug vma.buf.module, 2
76
- message("ERROR")
77
- end
78
- }, "Write changes edited in grep buffer to the underlying file"]
79
- end
80
72
  vma.kbd.add_minor_mode("bmgr", :buf_mgr, :command)
81
73
  reg_act(:grep_buffer, proc { Grep.new.run }, "Grep current buffer")
82
74
  reg_act(:grep_refresh, proc {
@@ -89,6 +81,14 @@ class Grep
89
81
  bindkey "grep ctrl-r", :grep_refresh
90
82
  end
91
83
 
84
+ # Called by Buffer#save. Saving a grep buffer writes the edited lines back to
85
+ # the original buffer. Returns false to fall back to a normal save.
86
+ def on_save()
87
+ return false if !cnf.experimental?
88
+ apply_changes
89
+ return true
90
+ end
91
+
92
92
  def apply_changes()
93
93
  b = @orig_buf
94
94
  gb = vma.buf
@@ -233,3 +233,4 @@ def buf_replace_string(instr)
233
233
  end
234
234
  buf_replace(a[0], a[1])
235
235
  end
236
+ end # module Vimamsa
@@ -1,56 +1,136 @@
1
- def flip_true_false(str)
2
- str.gsub(/\b(true|false)\b/i) do |match|
3
- if match.match?(/\Atrue\z/i)
4
- replacement = "false"
5
- else
6
- replacement = "true"
1
+ module Vimamsa
2
+ def flip_term(str)
3
+ y = str.downcase
4
+ replacements = [
5
+ %w[true false],
6
+ %w[left right],
7
+ %w[begin end],
8
+ %w[spring summer autumn winter],
9
+ ("a".."z").to_a,
10
+ %w[january february march april may june july august september october november december],
11
+ %w[jan feb mar apr may jun jul aug sep oct nov dec],
12
+ %w[monday tuesday wednesday thursday friday saturday sunday],
13
+ %w[mon tue wed thu fri sat sun],
14
+ %w[zero one two three four five six seven eight nine ten],
15
+ %w[north east south west],
16
+ %w[am pm],
17
+ %w[todo doing done],
18
+ %w[yes no],
19
+ %w[on off],
20
+ %w[enabled disabled],
21
+ %w[enable disable],
22
+ %w[active inactive],
23
+ %w[open closed],
24
+ %w[public private],
25
+ %w[visible hidden],
26
+ %w[show hide],
27
+ %w[up down],
28
+ %w[top bottom],
29
+ %w[first last],
30
+ %w[next previous],
31
+ %w[before after],
32
+ %w[min max],
33
+ %w[minimum maximum],
34
+ %w[increase decrease],
35
+ %w[push pop],
36
+ %w[add remove],
37
+ %w[include exclude],
38
+ %w[read write],
39
+ %w[input output],
40
+ %w[source target],
41
+ %w[start stop],
42
+ # %w[start finish],
43
+ %w[create destroy],
44
+ %w[connect disconnect],
45
+ %w[attach detach],
46
+ %w[lock unlock],
47
+ %w[valid invalid],
48
+ %w[success failure],
49
+ %w[pass fail],
50
+ %w[positive negative],
51
+ %w[gain loss],
52
+ %w[ascending descending],
53
+ %w[horizontal vertical],
54
+ %w[portrait landscape],
55
+ %w[absolute relative],
56
+ %w[local remote],
57
+ %w[client server],
58
+ %w[request response],
59
+ %w[parent child],
60
+ %w[head tail],
61
+ %w[prefix suffix],
62
+ %w[foreground background],
63
+ %w[light dark],
64
+ %w[black white],
65
+ ]
66
+
67
+ rep = nil
68
+ for x in replacements
69
+ i = x.find_index(y)
70
+ if i
71
+ i = (i + 1) % x.size
72
+ rep = x[i]
73
+ rep = preserve_case(str, rep)
74
+ return rep
75
+ end
7
76
  end
77
+ flip_numbered_term(str)
78
+ end
79
+
80
+ def flip_numbered_term(str)
81
+ return nil unless str =~ /\A(.*?)(\d+)\z/
82
+
83
+ prefix = Regexp.last_match(1)
84
+ number = Regexp.last_match(2)
85
+
86
+ next_number = number.to_i + 1
87
+
88
+ # Preserve zero padding: item001 -> item002
89
+ "#{prefix}#{next_number.to_s.rjust(number.length, "0")}"
90
+ end
8
91
 
9
- # preserve casing style
10
- if match == match.upcase
92
+ def preserve_case(original, replacement)
93
+ if original == original.upcase
11
94
  replacement.upcase
12
- elsif match[0] == match[0].upcase
95
+ elsif original[0] == original[0]&.upcase
13
96
  replacement.capitalize
14
97
  else
15
98
  replacement.downcase
16
99
  end
17
100
  end
18
- end
19
101
 
20
- def to_camel_case(str)
21
- words = str.split(/\W+/) # Split the input string into words
22
- camel_case_words = words.map.with_index do |word, index|
23
- index == 0 ? word.downcase : word.capitalize
102
+ def to_camel_case(str)
103
+ words = str.split(/\W+/) # Split the input string into words
104
+ camel_case_words = words.map.with_index do |word, index|
105
+ index == 0 ? word.downcase : word.capitalize
106
+ end
107
+ camel_case_words.join
24
108
  end
25
- camel_case_words.join
26
- end
27
-
28
- # Get all indexes for start of matching regexp
29
- def scan_indexes(txt, regex)
30
- # indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) + 1 }
31
- indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) }
32
- return indexes
33
- end
34
109
 
35
- def is_path(s)
36
- m = s.match(/(~[a-z]*)?\/.*\//)
37
- if m != nil
38
- return true
110
+ # Get all indexes for start of matching regexp
111
+ def scan_indexes(txt, regex)
112
+ # indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) + 1 }
113
+ indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) }
114
+ return indexes
39
115
  end
40
- return false
41
- end
42
116
 
43
-
44
- def sanitize_input(str)
45
- if str.encoding != Encoding::UTF_8
46
- str = text.encode(Encoding::UTF_8)
117
+ def is_path(s)
118
+ m = s.match(/(~[a-z]*)?\/.*\//)
119
+ if m != nil
120
+ return true
121
+ end
122
+ return false
47
123
  end
48
- str.gsub!(/\r\n/, "\n")
49
- return str
50
- end
51
-
52
- def is_url(s)
53
- return s.match(/(https?|file):\/\/.*/) != nil
54
- end
55
124
 
125
+ def sanitize_input(str)
126
+ if str.encoding != Encoding::UTF_8
127
+ str = text.encode(Encoding::UTF_8)
128
+ end
129
+ str.gsub!(/\r\n/, "\n")
130
+ return str
131
+ end
56
132
 
133
+ def is_url(s)
134
+ return s.match(/(https?|file):\/\/.*/) != nil
135
+ end
136
+ end # module Vimamsa
@@ -1,4 +1,6 @@
1
1
 
2
+ module Vimamsa
3
+
2
4
  def exec_in_terminal(cmd, autoclose = false)
3
5
  # debug "CMD:#{cmd}"
4
6
 
@@ -32,3 +34,4 @@ def command_to_buf
32
34
  callback = method("command_to_buf_callback")
33
35
  gui_one_input_action("Execute command in shell, output to buffer", "Command:", "Execute", callback)
34
36
  end
37
+ end # module Vimamsa
@@ -1,3 +1,5 @@
1
+
2
+ module Vimamsa
1
3
  # VmaTest — integration test base class
2
4
  #
3
5
  # Tests run inside the live GTK app (headless or normal) after vma.start.
@@ -15,15 +17,17 @@
15
17
  # Run one class: run_vma_tests(MyTests)
16
18
 
17
19
  class VmaTestFailure < StandardError; end
20
+ class VmaTestSkip < StandardError; end
18
21
 
19
22
  class VmaTest
20
- attr_reader :failures, :passes
23
+ attr_reader :failures, :passes, :skips
21
24
 
22
25
  # Subclasses define test_* methods.
23
26
  # Each receives a fresh buffer and the kbd in :command mode.
24
27
  def run_all
25
28
  @passes = 0
26
29
  @failures = []
30
+ @skips = []
27
31
  test_methods = self.class.instance_methods(false)
28
32
  .select { |m| m.to_s.start_with?("test_") }
29
33
  .sort
@@ -34,6 +38,9 @@ class VmaTest
34
38
  send(m)
35
39
  @passes += 1
36
40
  puts " PASS #{self.class}##{m}"
41
+ rescue VmaTestSkip => e
42
+ @skips << "#{self.class}##{m}: #{e.message}"
43
+ puts " SKIP #{self.class}##{m}: #{e.message}"
37
44
  rescue VmaTestFailure => e
38
45
  @failures << "#{self.class}##{m}: #{e.message}"
39
46
  puts " FAIL #{self.class}##{m}: #{e.message}"
@@ -53,6 +60,13 @@ class VmaTest
53
60
  drain_idle
54
61
  end
55
62
 
63
+ # Execute one action without draining the GLib main loop.
64
+ # Use in tight loops; call drain_idle manually at a suitable interval.
65
+ def act_fast(action)
66
+ exec_action(action)
67
+ drain_idle
68
+ end
69
+
56
70
  # Simulate a space-separated key sequence in the current mode.
57
71
  # E.g.: keys("i h e l l o esc")
58
72
  # Special tokens: ctrl-x, alt-x, shift-X, esc, enter, backspace, tab, space
@@ -95,6 +109,13 @@ class VmaTest
95
109
  raise VmaTestFailure, msg unless cond
96
110
  end
97
111
 
112
+ # Skip the current test (reported as SKIP, not a failure). Use for tests
113
+ # that are unreliable in the current environment (e.g. clipboard/idle timing
114
+ # under headless GTK).
115
+ def skip(msg = "")
116
+ raise VmaTestSkip, msg
117
+ end
118
+
98
119
  private
99
120
 
100
121
  def _setup_test
@@ -119,6 +140,7 @@ def run_vma_tests(*classes)
119
140
 
120
141
  total_pass = 0
121
142
  total_fail = []
143
+ total_skip = []
122
144
 
123
145
  classes.each do |klass|
124
146
  puts "\n#{klass}"
@@ -126,12 +148,16 @@ def run_vma_tests(*classes)
126
148
  t.run_all
127
149
  total_pass += t.passes
128
150
  total_fail.concat(t.failures)
151
+ total_skip.concat(t.skips || [])
129
152
  end
130
153
 
131
154
  puts "\n#{"=" * 50}"
132
- puts "Results: #{total_pass} passed, #{total_fail.size} failed"
155
+ skip_note = total_skip.empty? ? "" : ", #{total_skip.size} skipped"
156
+ puts "Results: #{total_pass} passed, #{total_fail.size} failed#{skip_note}"
133
157
  total_fail.each { |f| puts " FAIL: #{f}" }
158
+ total_skip.each { |s| puts " SKIP: #{s}" }
134
159
  puts "=" * 50
135
160
 
136
161
  total_fail.empty?
137
162
  end
163
+ end # module Vimamsa
data/lib/vimamsa/tests.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require "digest"
2
2
 
3
+ module Vimamsa
4
+
3
5
  def run_tests()
4
6
  # DelayExecutioner.exec(id: :run_tests, wait: 0.7, callable: proc { run_tests_0 })
5
7
 
@@ -196,3 +198,4 @@ O frabjous day! Callooh! Callay!”
196
198
  All mimsy were the borogoves,
197
199
  And the mome raths outgrabe.
198
200
  "
201
+ end # module Vimamsa