uh-wm 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/lib/uh/wm/actions_handler.rb +9 -0
  3. data/lib/uh/wm/cli.rb +1 -1
  4. data/lib/uh/wm/client.rb +14 -0
  5. data/lib/uh/wm/env.rb +3 -1
  6. data/lib/uh/wm/env_logging.rb +1 -1
  7. data/lib/uh/wm/launcher.rb +73 -0
  8. data/lib/uh/wm/run_control.rb +10 -0
  9. data/lib/uh/wm/runner.rb +26 -5
  10. data/lib/uh/wm/testing/acceptance_helpers.rb +36 -65
  11. data/lib/uh/wm/testing/x_client.rb +63 -0
  12. data/lib/uh/wm/version.rb +1 -1
  13. data/lib/uh/wm/workers/base.rb +1 -1
  14. data/lib/uh/wm/workers/mux.rb +3 -1
  15. data/lib/uh/wm.rb +5 -3
  16. metadata +9 -111
  17. data/.gitignore +0 -3
  18. data/.rspec +0 -1
  19. data/.travis.yml +0 -15
  20. data/Gemfile +0 -5
  21. data/Guardfile +0 -12
  22. data/LICENSE +0 -30
  23. data/Rakefile +0 -40
  24. data/config/cucumber.yaml +0 -1
  25. data/features/actions/execute.feature +0 -9
  26. data/features/actions/layout_delegation.feature +0 -31
  27. data/features/actions/quit.feature +0 -9
  28. data/features/cli/debug.feature +0 -5
  29. data/features/cli/layout.feature +0 -15
  30. data/features/cli/require.feature +0 -5
  31. data/features/cli/run_control.feature +0 -9
  32. data/features/cli/usage.feature +0 -11
  33. data/features/cli/verbose.feature +0 -5
  34. data/features/cli/version.feature +0 -6
  35. data/features/cli/worker.feature +0 -9
  36. data/features/layout/manage.feature +0 -12
  37. data/features/layout/protocol.feature +0 -56
  38. data/features/layout/unmanage.feature +0 -10
  39. data/features/manager/change.feature +0 -7
  40. data/features/manager/check_other_wm.feature +0 -8
  41. data/features/manager/expose.feature +0 -5
  42. data/features/manager/input_events.feature +0 -8
  43. data/features/manager/manage.feature +0 -14
  44. data/features/manager/unmanage.feature +0 -13
  45. data/features/manager/x_errors.feature +0 -17
  46. data/features/run_control/evaluation.feature +0 -18
  47. data/features/run_control/key.feature +0 -33
  48. data/features/run_control/layout.feature +0 -39
  49. data/features/run_control/modifier.feature +0 -10
  50. data/features/run_control/worker.feature +0 -9
  51. data/features/session/connection.feature +0 -5
  52. data/features/session/termination.feature +0 -12
  53. data/features/steps/filesystem_steps.rb +0 -3
  54. data/features/steps/output_steps.rb +0 -55
  55. data/features/steps/run_control_steps.rb +0 -3
  56. data/features/steps/run_steps.rb +0 -41
  57. data/features/steps/x_steps.rb +0 -58
  58. data/features/support/env.rb +0 -33
  59. data/features/workers/block.feature +0 -15
  60. data/features/workers/mux.feature +0 -15
  61. data/spec/spec_helper.rb +0 -30
  62. data/spec/support/exit_helpers.rb +0 -6
  63. data/spec/support/factories.rb +0 -27
  64. data/spec/support/filesystem_helpers.rb +0 -11
  65. data/spec/uh/wm/actions_handler_spec.rb +0 -35
  66. data/spec/uh/wm/cli_spec.rb +0 -214
  67. data/spec/uh/wm/client_spec.rb +0 -148
  68. data/spec/uh/wm/dispatcher_spec.rb +0 -76
  69. data/spec/uh/wm/env_spec.rb +0 -154
  70. data/spec/uh/wm/manager_spec.rb +0 -386
  71. data/spec/uh/wm/run_control_spec.rb +0 -126
  72. data/spec/uh/wm/runner_spec.rb +0 -196
  73. data/uh-wm.gemspec +0 -26
@@ -1,39 +0,0 @@
1
- Feature: `layout' run control keyword
2
-
3
- Background:
4
- Given a file named my_layout.rb with:
5
- """
6
- class MyLayout
7
- def initialize **options
8
- puts "testing_rc_layout_#{options.inspect}" if options.any?
9
- end
10
-
11
- def register *_, **options
12
- puts "testing_rc_layout_register"
13
- end
14
- end
15
- """
16
-
17
- Scenario: configures a layout class
18
- Given a run control file with:
19
- """
20
- layout MyLayout
21
- """
22
- When I run uhwm with options -r./my_layout
23
- Then the output must contain "testing_rc_layout_register"
24
-
25
- Scenario: configures a layout class with options
26
- Given a run control file with:
27
- """
28
- layout MyLayout, foo: :bar
29
- """
30
- When I run uhwm with options -r./my_layout
31
- Then the output must contain "testing_rc_layout_{:foo=>:bar}"
32
-
33
- Scenario: configures a layout instance
34
- Given a run control file with:
35
- """
36
- layout MyLayout.new
37
- """
38
- When I run uhwm with options -r./my_layout
39
- Then the output must contain "testing_rc_layout_register"
@@ -1,10 +0,0 @@
1
- Feature: `modifier' run control keyword
2
-
3
- Scenario: configures the modifier key
4
- Given a run control file with:
5
- """
6
- modifier :ctrl
7
- """
8
- And uhwm is running
9
- When I press the ctrl+shift+q keys
10
- Then uhwm must terminate successfully
@@ -1,9 +0,0 @@
1
- Feature: `worker' run control keyword
2
-
3
- Scenario: configures the modifier key
4
- Given a run control file with:
5
- """
6
- worker :mux
7
- """
8
- And I start uhwm
9
- Then the output must match /work.+event.+mux/i
@@ -1,5 +0,0 @@
1
- Feature: connection to X server
2
-
3
- Scenario: connects to X server
4
- When I start uhwm
5
- Then it must connect to X display
@@ -1,12 +0,0 @@
1
- Feature: program termination
2
-
3
- Background:
4
- Given uhwm is running
5
-
6
- Scenario: terminates on quit request
7
- When I tell uhwm to quit
8
- Then uhwm must terminate successfully
9
-
10
- Scenario: logs about termination
11
- When I tell uhwm to quit
12
- Then the output must match /terminat/i
@@ -1,3 +0,0 @@
1
- Given /^a file named ([^ ]+) with:$/ do |path, content|
2
- write_file path, content
3
- end
@@ -1,55 +0,0 @@
1
- Then /^the output must contain exactly the usage$/ do
2
- assert_exact_output <<-eoh, all_output
3
- Usage: uhwm [options]
4
-
5
- options:
6
- -v, --verbose enable verbose mode
7
- -d, --debug enable debug mode
8
- -f, --run-control PATH specify alternate run control file
9
- -r, --require PATH require ruby feature
10
- -l, --layout LAYOUT specify layout
11
- -w, --worker WORKER specify worker
12
-
13
- -h, --help print this message
14
- -V, --version print version
15
- eoh
16
- end
17
-
18
- Then /^the output must contain exactly the version$/ do
19
- assert_exact_output "%s\n" % Uh::WM::VERSION, all_output
20
- end
21
-
22
- Then /^the output must match \/([^\/]+)\/([a-z]*)$/ do |pattern, options|
23
- uhwm_wait_output Regexp.new(pattern, options)
24
- end
25
-
26
- Then /^the output must not match \/([^\/]+)\/([a-z]*)$/ do |pattern, options|
27
- expect(all_output).not_to match Regexp.new(pattern, options)
28
- end
29
-
30
- Then /^the output must match \/([^\/]+)\/([a-z]*) at least (\d+) times$/ do
31
- |pattern, options, times|
32
- uhwm_wait_output Regexp.new(pattern, options), times.to_i
33
- end
34
-
35
- Then /^the output must match \/([^\/]+)\/([a-z]*) exactly (\d+) times$/ do
36
- |pattern, options, times|
37
- scans = uhwm_wait_output Regexp.new(pattern, options)
38
- expect(scans.size).to eq times.to_i
39
- end
40
-
41
- Then /^the output must contain:$/ do |content|
42
- uhwm_wait_output content.to_s
43
- end
44
-
45
- Then /^the output must contain "([^"]+)"$/ do |content|
46
- uhwm_wait_output content.to_s
47
- end
48
-
49
- Then /^the output must contain current display$/ do
50
- uhwm_wait_output ENV['DISPLAY']
51
- end
52
-
53
- Then /^the output must contain the window name$/ do
54
- uhwm_wait_output x_window_name
55
- end
@@ -1,3 +0,0 @@
1
- Given /^a run control file with:$/ do |content|
2
- write_file '.uhwmrc.rb', content
3
- end
@@ -1,41 +0,0 @@
1
- Given /^another window manager is running$/ do
2
- expect(other_wm).to be_alive
3
- end
4
-
5
- Given /^uhwm is running$/ do
6
- uhwm_run_wait_ready
7
- end
8
-
9
- Given /^uhwm is running with options? (-.+)$/ do |options|
10
- uhwm_run_wait_ready options
11
- end
12
-
13
- Given /^uhwm is running with this run control file:$/ do |rc|
14
- write_file '.uhwmrc.rb', rc
15
- uhwm_run_wait_ready
16
- end
17
-
18
- When /^I start uhwm$/ do
19
- uhwm_run
20
- end
21
-
22
- When /^I run uhwm with options? (-.+)$/ do |options|
23
- uhwm_run options
24
- end
25
-
26
- When /^I tell uhwm to quit$/ do
27
- uhwm_request_quit
28
- end
29
-
30
- When /^I quit uhwm$/ do
31
- uhwm_request_quit
32
- assert_exit_status 0
33
- end
34
-
35
- Then /^the exit status must be (\d+)$/ do |exit_status|
36
- assert_exit_status exit_status.to_i
37
- end
38
-
39
- Then /^uhwm must terminate successfully$/ do
40
- assert_exit_status 0
41
- end
@@ -1,58 +0,0 @@
1
- Given /^a(?:\s(\w+))? window is mapped$/ do |ident|
2
- x_client(ident).map.sync
3
- timeout_until 'window not mapped after %d seconds' do
4
- x_window_map_state(x_client(ident).window_id) == 'IsViewable'
5
- end
6
- end
7
-
8
- When /^I press the ([^ ]+) keys?$/ do |keys|
9
- x_key keys
10
- end
11
-
12
- When /^I press the ([^ ]+) keys? (\d+) times$/ do |keys, times|
13
- times.to_i.times { x_key keys }
14
- end
15
-
16
- When /^a window requests to be mapped$/ do
17
- x_client.map.sync
18
- end
19
-
20
- When /^a window requests to be mapped (\d+) times$/ do |times|
21
- x_client.map times: times.to_i
22
- end
23
-
24
- When /^the(?:\s(\w+))? window is unmapped$/ do |ident|
25
- x_client(ident).unmap.sync
26
- timeout_until 'window not unmapped after %d seconds' do
27
- x_window_map_state(x_client(ident).window_id) == 'IsUnMapped'
28
- end
29
- end
30
-
31
- When /^the window is destroyed$/ do
32
- x_client.destroy.sync
33
- end
34
-
35
- When /^the window name changes to "([^"]+)"$/ do |name|
36
- x_client.window_name = name
37
- end
38
-
39
- Then /^it must connect to X display$/ do
40
- uhwm_wait_ready
41
- expect(x_socket_check uhwm.pid).to be true
42
- end
43
-
44
- Then /^the(?:\s(\w+))? window must be mapped$/ do |ident|
45
- timeout_until 'window not mapped after %d seconds' do
46
- x_window_map_state(x_client(ident).window_id) == 'IsViewable'
47
- end
48
- end
49
-
50
- Then /^the window must be focused$/ do
51
- timeout_until 'window not focused after %d seconds' do
52
- x_focused_window_id == x_client.window_id
53
- end
54
- end
55
-
56
- Then /^the input event mask must include (.+)$/ do |mask|
57
- expect(x_input_event_masks).to include mask
58
- end
@@ -1,33 +0,0 @@
1
- require 'aruba/cucumber'
2
- require 'headless'
3
-
4
- require 'uh/wm/testing/acceptance_helpers'
5
-
6
- module Aruba
7
- class SpawnProcess
8
- def pid
9
- @process.pid
10
- end
11
- end
12
- end
13
-
14
- World(Uh::WM::Testing::AcceptanceHelpers)
15
-
16
- Headless.new.start
17
-
18
- Before do
19
- set_env 'HOME', File.expand_path(current_dir)
20
- end
21
-
22
- After do
23
- uhwm_ensure_stop
24
- x_clients_ensure_stop
25
- end
26
-
27
- Around '@other_wm_running' do |_, block|
28
- with_other_wm { block.call }
29
- end
30
-
31
- if ENV.key? 'TRAVIS'
32
- ENV['UHWMTEST_TIMEOUT'] = 8.to_s
33
- end
@@ -1,15 +0,0 @@
1
- Feature: blocking worker
2
-
3
- Scenario: processes initial events
4
- Given uhwm is running with options -d -w block
5
- Then the output must match /xevent/i at least 2 times
6
-
7
- Scenario: processes generated events
8
- Given a run control file with:
9
- """
10
- key(:f) { puts 'testing_worker_read' }
11
- """
12
- And uhwm is running with options -d -w block
13
- When I press the alt+f key 3 times
14
- And I quit uhwm
15
- Then the output must match /(testing_worker_read)/ exactly 3 times
@@ -1,15 +0,0 @@
1
- Feature: multiplexing worker
2
-
3
- Scenario: processes initial events
4
- Given uhwm is running with options -d -w mux
5
- Then the output must match /xevent/i at least 2 times
6
-
7
- Scenario: processes generated events
8
- Given a run control file with:
9
- """
10
- key(:f) { puts 'testing_worker_read' }
11
- """
12
- And uhwm is running with options -d -w mux
13
- When I press the alt+f key 3 times
14
- And I quit uhwm
15
- Then the output must match /(testing_worker_read)/ exactly 3 times
data/spec/spec_helper.rb DELETED
@@ -1,30 +0,0 @@
1
- require 'headless'
2
-
3
- require 'uh/wm'
4
-
5
- Dir['spec/support/**/*.rb'].map { |e| require e.gsub 'spec/', '' }
6
-
7
- RSpec.configure do |config|
8
- config.include Factories
9
-
10
- config.expect_with :rspec do |expectations|
11
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
12
- end
13
-
14
- config.mock_with :rspec do |mocks|
15
- mocks.verify_partial_doubles = true
16
- end
17
-
18
- config.disable_monkey_patching!
19
-
20
- config.before :all do
21
- # Ensure current X display is not available from rspec test suite.
22
- ENV.delete 'DISPLAY'
23
- end
24
-
25
- config.around :example, :xvfb do |example|
26
- Headless.ly do
27
- example.run
28
- end
29
- end
30
- end
@@ -1,6 +0,0 @@
1
- module ExitHelpers
2
- def trap_exit
3
- yield
4
- rescue SystemExit
5
- end
6
- end
@@ -1,27 +0,0 @@
1
- module Factories
2
- def build_geo x = 0, y = 0, width = 640, height = 480
3
- Uh::Geo.new(x, y, width, height)
4
- end
5
-
6
- def build_client window = mock_window
7
- Uh::WM::Client.new(window)
8
- end
9
-
10
- def mock_event type = :xany, **options
11
- double 'event', type: type, **options
12
- end
13
-
14
- def mock_event_key_press key, modifier_mask
15
- mock_event :key_press,
16
- key: 'f',
17
- modifier_mask: modifier_mask
18
- end
19
-
20
- def mock_window override_redirect: false
21
- instance_spy Uh::Window, 'window',
22
- to_s: 'wid',
23
- name: 'wname',
24
- wclass: 'wclass',
25
- override_redirect?: override_redirect
26
- end
27
- end
@@ -1,11 +0,0 @@
1
- require 'tempfile'
2
-
3
- module FileSystemHelpers
4
- def with_file content
5
- Tempfile.create('uhwm_rspec') do |f|
6
- f.write content
7
- f.rewind
8
- yield f
9
- end
10
- end
11
- end
@@ -1,35 +0,0 @@
1
- module Uh
2
- module WM
3
- RSpec.describe ActionsHandler do
4
- let(:env) { Env.new(StringIO.new) }
5
- let(:events) { Dispatcher.new }
6
- subject(:actions) { described_class.new env, events }
7
-
8
- describe '#evaluate' do
9
- it 'evaluates code given as Proc argument' do
10
- expect { actions.evaluate proc { throw :action_code } }
11
- .to throw_symbol :action_code
12
- end
13
-
14
- it 'evaluates code given as block' do
15
- expect { actions.evaluate { throw :action_code } }
16
- .to throw_symbol :action_code
17
- end
18
- end
19
-
20
- describe '#quit' do
21
- it 'emits the quit event' do
22
- expect(events).to receive(:emit).with :quit
23
- actions.quit
24
- end
25
- end
26
-
27
- describe '#layout_*' do
28
- it 'delegates messages to the layout with handle_ prefix' do
29
- expect(env.layout).to receive :handle_screen_sel
30
- actions.layout_screen_sel :succ
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,214 +0,0 @@
1
- require 'support/exit_helpers'
2
-
3
- module Uh
4
- module WM
5
- RSpec.describe CLI do
6
- include ExitHelpers
7
-
8
- let(:stdout) { StringIO.new }
9
- let(:stderr) { StringIO.new }
10
- let(:arguments) { [] }
11
- subject(:cli) { described_class.new arguments, stdout: stdout }
12
-
13
- describe '.run' do
14
- subject(:run) do
15
- described_class.run arguments, stdout: stdout, stderr: stderr
16
- end
17
-
18
- # Prevent Runner from connecting a Manager and blocking.
19
- before { allow(Runner).to receive :run }
20
-
21
- it 'builds a new CLI with given arguments' do
22
- expect(described_class)
23
- .to receive(:new).with(arguments, stdout: stdout).and_call_original
24
- run
25
- end
26
-
27
- it 'parses new CLI arguments' do
28
- cli
29
- allow(described_class).to receive(:new) { cli }
30
- expect(cli).to receive :parse_arguments!
31
- run
32
- end
33
-
34
- it 'runs new CLI' do
35
- cli
36
- allow(described_class).to receive(:new) { cli }
37
- expect(cli).to receive :run
38
- run
39
- end
40
-
41
- context 'with invalid arguments' do
42
- let(:arguments) { %w[--unknown-option] }
43
-
44
- it 'prints the usage on standard error stream' do
45
- trap_exit { run }
46
- expect(stderr.string).to match /\AUsage: .+/
47
- end
48
-
49
- it 'exits with a return status of 64' do
50
- expect { run }.to raise_error(SystemExit) do |e|
51
- expect(e.status).to eq 64
52
- end
53
- end
54
- end
55
-
56
- context 'when the new CLI raises a runtime error' do
57
- before do
58
- allow(cli).to receive(:run) { fail RuntimeError, 'some error' }
59
- allow(described_class).to receive(:new) { cli }
60
- end
61
-
62
- it 'exits with a return status of 70' do
63
- expect { run }.to raise_error(SystemExit) do |e|
64
- expect(e.status).to eq 70
65
- end
66
- end
67
-
68
- it 'formats the error' do
69
- trap_exit { run }
70
- expect(stderr.string)
71
- .to match /\AUh::WM::RuntimeError: some error\n/
72
- end
73
-
74
- it 'does not output a backtrace' do
75
- trap_exit { run }
76
- expect(stderr.string).not_to include __FILE__
77
- end
78
-
79
- context 'when debug mode is enabled' do
80
- let(:arguments) { %w[-d] }
81
-
82
- it 'outputs a backtrace' do
83
- trap_exit { run }
84
- expect(stderr.string).to include __FILE__
85
- end
86
- end
87
- end
88
- end
89
-
90
- describe '#initialize' do
91
- it 'builds an env with given stdout' do
92
- expect(cli.env.output).to be stdout
93
- end
94
-
95
- it 'syncs the output' do
96
- expect(stdout).to receive(:sync=).with(true)
97
- cli
98
- end
99
- end
100
-
101
- describe '#run' do
102
- it 'runs a runner with the env' do
103
- expect(Runner).to receive(:run).with(cli.env)
104
- cli.run
105
- end
106
- end
107
-
108
- describe '#parse_arguments!' do
109
- context 'with verbose option' do
110
- let(:arguments) { %w[-v] }
111
-
112
- it 'sets the env as verbose' do
113
- cli.parse_arguments!
114
- expect(cli.env).to be_verbose
115
- end
116
-
117
- it 'tells the env to log its logger level' do
118
- expect(cli.env).to receive :log_logger_level
119
- cli.parse_arguments!
120
- end
121
- end
122
-
123
- context 'with debug option' do
124
- let(:arguments) { %w[-d] }
125
-
126
- it 'sets the env as debug' do
127
- cli.parse_arguments!
128
- expect(cli.env).to be_debug
129
- end
130
-
131
- it 'tells the env to log its logger level' do
132
- expect(cli.env).to receive :log_logger_level
133
- cli.parse_arguments!
134
- end
135
- end
136
-
137
- context 'with run control option' do
138
- let(:arguments) { %w[-f uhwmrc.rb] }
139
-
140
- it 'assigns run control file path in the env' do
141
- cli.parse_arguments!
142
- expect(cli.env.rc_path).to eq 'uhwmrc.rb'
143
- end
144
- end
145
-
146
- context 'with require option' do
147
- let(:arguments) { %w[-r abbrev] }
148
-
149
- it 'requires the given ruby feature' do
150
- expect { cli.parse_arguments! }
151
- .to change { $LOADED_FEATURES.grep(/abbrev/).any? }
152
- .from(false).to(true)
153
- end
154
- end
155
-
156
- context 'with layout option' do
157
- let(:arguments) { %w[-l Object] }
158
-
159
- it 'assigns the layout class in the env' do
160
- cli.parse_arguments!
161
- expect(cli.env.layout_class).to eq Object
162
- end
163
- end
164
-
165
- context 'with worker option' do
166
- let(:arguments) { %w[-w mux] }
167
-
168
- it 'assigns the worker type in the env' do
169
- cli.parse_arguments!
170
- expect(cli.env.worker).to eq :mux
171
- end
172
- end
173
-
174
- context 'with help option' do
175
- let(:arguments) { %w[-h] }
176
-
177
- it 'prints the usage banner on standard output' do
178
- trap_exit { cli.parse_arguments! }
179
- expect(stdout.string).to match /\AUsage: .+/
180
- end
181
-
182
- it 'prints options usage on standard output' do
183
- trap_exit { cli.parse_arguments! }
184
- expect(stdout.string).to match /\n^options:\n\s+-/
185
- end
186
- end
187
-
188
- context 'with version option' do
189
- let(:arguments) { %w[-V] }
190
-
191
- it 'prints the version on standard output' do
192
- trap_exit { cli.parse_arguments! }
193
- expect(stdout.string).to eq "#{::Uh::WM::VERSION}\n"
194
- end
195
-
196
- it 'exits with a return status of 0' do
197
- expect { cli.parse_arguments! }.to raise_error(SystemExit) do |e|
198
- expect(e.status).to eq 0
199
- end
200
- end
201
- end
202
-
203
- context 'with invalid option' do
204
- let(:arguments) { %w[--unknown-option] }
205
-
206
- it 'raises a CLI::ArgumentError' do
207
- expect { cli.parse_arguments! }
208
- .to raise_error CLI::ArgumentError
209
- end
210
- end
211
- end
212
- end
213
- end
214
- end