cosmos 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/Manifest.txt +6 -0
  3. data/autohotkey/config/tools/handbook_creator/templates/command_packets.html.erb +1 -1
  4. data/autohotkey/config/tools/handbook_creator/templates/footer.html.erb +2 -2
  5. data/autohotkey/config/tools/handbook_creator/templates/header.html.erb +4 -4
  6. data/autohotkey/tools/autohotkey.rb +1 -1
  7. data/autohotkey/tools/cmd_tlm_server.ahk +1 -0
  8. data/autohotkey/tools/packet_viewer.ahk +45 -2
  9. data/data/crc.txt +20 -15
  10. data/demo/Rakefile +16 -0
  11. data/demo/config/data/crc.txt +3 -3
  12. data/demo/config/tools/handbook_creator/templates/footer.html.erb +2 -2
  13. data/demo/config/tools/handbook_creator/templates/header.html.erb +4 -4
  14. data/demo/procedures/example_test.rb +1 -1
  15. data/install/Rakefile +16 -0
  16. data/install/config/data/crc.txt +2 -2
  17. data/install/config/tools/handbook_creator/templates/footer.html.erb +2 -2
  18. data/install/config/tools/handbook_creator/templates/header.html.erb +4 -4
  19. data/lib/cosmos/gui/dialogs/tlm_details_dialog.rb +64 -57
  20. data/lib/cosmos/gui/line_graph/line_graph_scaling.rb +0 -9
  21. data/lib/cosmos/gui/qt.rb +22 -18
  22. data/lib/cosmos/packet_logs/packet_log_writer.rb +6 -2
  23. data/lib/cosmos/script/script.rb +1 -1
  24. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_config.rb +0 -1
  25. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +99 -784
  26. data/lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb +189 -0
  27. data/lib/cosmos/tools/cmd_tlm_server/gui/logging_tab.rb +176 -0
  28. data/lib/cosmos/tools/cmd_tlm_server/gui/packets_tab.rb +144 -0
  29. data/lib/cosmos/tools/cmd_tlm_server/gui/status_tab.rb +240 -0
  30. data/lib/cosmos/tools/cmd_tlm_server/gui/targets_tab.rb +90 -0
  31. data/lib/cosmos/tools/launcher/launcher_config.rb +142 -110
  32. data/lib/cosmos/tools/test_runner/results_writer.rb +1 -1
  33. data/lib/cosmos/tools/test_runner/test_runner.rb +3 -2
  34. data/lib/cosmos/tools/tlm_grapher/data_objects/data_object.rb +18 -2
  35. data/lib/cosmos/tools/tlm_grapher/data_objects/housekeeping_data_object.rb +4 -9
  36. data/lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb +5 -5
  37. data/lib/cosmos/top_level.rb +1 -1
  38. data/lib/cosmos/version.rb +4 -4
  39. data/run_gui_tests.bat +33 -31
  40. data/spec/core_ext/time_spec.rb +51 -0
  41. data/spec/script/script_spec.rb +96 -0
  42. data/spec/tools/cmd_tlm_server/commanding_spec.rb +28 -0
  43. data/spec/tools/cmd_tlm_server/connections_spec.rb +88 -0
  44. data/spec/tools/cmd_tlm_server/router_thread_spec.rb +78 -25
  45. data/spec/tools/launcher/launcher_config_spec.rb +460 -0
  46. data/spec/top_level/top_level_spec.rb +1 -1
  47. metadata +8 -2
@@ -22,16 +22,7 @@ module Cosmos
22
22
  @packet.buffer = "\x01\x02"
23
23
 
24
24
  @interface = Interface.new
25
- @connected_count = 0
26
- allow(@interface).to receive(:connected?) do
27
- if @connected_count == 0
28
- @connected_count += 1
29
- false
30
- else
31
- @connected_count += 1
32
- true
33
- end
34
- end
25
+ # Interface#connected? implemented in each test case
35
26
  allow(@interface).to receive(:connect)
36
27
  allow(@interface).to receive(:disconnect)
37
28
  allow(@interface).to receive(:read) do
@@ -40,24 +31,24 @@ module Cosmos
40
31
  end
41
32
  end
42
33
 
43
- describe "start" do
44
- it "should log the connection" do
45
- commanding = double("commanding")
46
- expect(commanding).to receive(:send_command_to_interface).at_least(1).times
47
- allow(CmdTlmServer).to receive(:commanding).and_return(commanding)
34
+ describe "handle_packet" do
35
+ it "handles disconnectd interfaces" do
36
+ allow(@interface).to receive(:connected?).and_return(false)
48
37
  @interface.interfaces = [@interface]
49
38
  thread = RouterThread.new(@interface)
50
- thread.start
51
- sleep 1
52
- Thread.list.length.should eql(2)
53
- thread.stop
54
- sleep 0.5
55
- Thread.list.length.should eql(1)
39
+ capture_io do |stdout|
40
+ thread.start
41
+ sleep 0.2
42
+ Thread.list.length.should eql(2)
43
+ thread.stop
44
+ sleep 0.5
45
+ Thread.list.length.should eql(1)
46
+ stdout.string.should match "disconnected interface"
47
+ end
56
48
  end
57
- end
58
49
 
59
- describe "handle_packet" do
60
- it "should handle errors when sending packets" do
50
+ it "handles errors when sending packets" do
51
+ allow(@interface).to receive(:connected?).and_return(true)
61
52
  commanding = double("commanding")
62
53
  expect(commanding).to receive(:send_command_to_interface).and_raise(RuntimeError.new("Death")).at_least(1).times
63
54
  allow(CmdTlmServer).to receive(:commanding).and_return(commanding)
@@ -74,10 +65,43 @@ module Cosmos
74
65
  end
75
66
  end
76
67
 
77
- it "should handle identified yet unknown commands" do
68
+ it "handles identified yet unknown commands" do
69
+ allow(@interface).to receive(:connected?).and_return(true)
70
+ commanding = spy("commanding")
71
+ interface2 = double("interface")
72
+ allow(interface2).to receive(:connected?).and_return(true)
73
+ # Setup two interface
74
+ @interface.interfaces = [@interface, interface2]
75
+ # Verify that the command gets sent twice (one for each interface)
76
+ expect(commanding).to receive(:send_command_to_interface).at_least(2).times
77
+ allow(CmdTlmServer).to receive(:commanding).and_return(commanding)
78
+ @packet.target_name = 'BOB'
79
+ @packet.packet_name = 'SMITH'
80
+ thread = RouterThread.new(@interface)
81
+ capture_io do |stdout|
82
+ thread.start
83
+ sleep 0.2
84
+ Thread.list.length.should eql(2)
85
+ thread.stop
86
+ sleep 0.5
87
+ Thread.list.length.should eql(1)
88
+ stdout.string.should match "Received unknown identified command: BOB SMITH"
89
+ end
90
+ end
91
+
92
+ it "handles identified known commands" do
93
+ allow(@interface).to receive(:connected?).and_return(true)
78
94
  commanding = double("commanding")
95
+ # Setup two interface
96
+ interface2 = double("interface")
97
+ allow(interface2).to receive(:connected?).and_return(true)
98
+ @interface.interfaces = [@interface, interface2]
99
+ # Verify that the command gets sent once to the target interface
79
100
  expect(commanding).to receive(:send_command_to_interface).at_least(1).times
80
101
  allow(CmdTlmServer).to receive(:commanding).and_return(commanding)
102
+ target = spy("target")
103
+ allow(target).to receive(:interface).and_return(@interface)
104
+ allow(System).to receive(:targets).and_return({'BOB' => target})
81
105
  @interface.interfaces = [@interface]
82
106
  @packet.target_name = 'BOB'
83
107
  @packet.packet_name = 'SMITH'
@@ -91,6 +115,35 @@ module Cosmos
91
115
  Thread.list.length.should eql(1)
92
116
  stdout.string.should match "Received unknown identified command: BOB SMITH"
93
117
  end
118
+ expect(target).to have_received(:interface).twice #and_return(@interface)
119
+ end
120
+
121
+ it "does not send identified commands with a target and no interface" do
122
+ allow(@interface).to receive(:connected?).and_return(true)
123
+ commanding = double("commanding")
124
+ # Setup two interface
125
+ interface2 = double("interface")
126
+ allow(interface2).to receive(:connected?).and_return(true)
127
+ @interface.interfaces = [@interface, interface2]
128
+ # Verify that the command gets sent once to the target interface
129
+ expect(commanding).to_not receive(:send_command_to_interface)
130
+ allow(CmdTlmServer).to receive(:commanding).and_return(commanding)
131
+ target = spy("target")
132
+ allow(target).to receive(:interface).and_return(nil)
133
+ allow(System).to receive(:targets).and_return({'BOB' => target})
134
+ @interface.interfaces = [@interface]
135
+ @packet.target_name = 'BOB'
136
+ @packet.packet_name = 'SMITH'
137
+ thread = RouterThread.new(@interface)
138
+ capture_io do |stdout|
139
+ thread.start
140
+ sleep 0.2
141
+ Thread.list.length.should eql(2)
142
+ thread.stop
143
+ sleep 0.5
144
+ Thread.list.length.should eql(1)
145
+ stdout.string.should match "target with no interface"
146
+ end
94
147
  end
95
148
  end
96
149
  end
@@ -0,0 +1,460 @@
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2014 Ball Aerospace & Technologies Corp.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is free software; you can modify and/or redistribute it
7
+ # under the terms of the GNU General Public License
8
+ # as published by the Free Software Foundation; version 3 with
9
+ # attribution addendums as found in the LICENSE.txt
10
+
11
+ require 'spec_helper'
12
+ require 'cosmos'
13
+ require 'cosmos/tools/launcher/launcher_config'
14
+ require 'tempfile'
15
+
16
+ module Cosmos
17
+
18
+ describe LauncherConfig do
19
+ describe "initialize" do
20
+ it "checks for a given filename" do
21
+ expect { LauncherConfig.new('blah_file.txt') }.to raise_error
22
+ end
23
+
24
+ it "raises on unknown parameters" do
25
+ tf = Tempfile.new('mylauncher.txt')
26
+ tf.puts "UNKNOWN"
27
+ tf.close
28
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
29
+ tf.unlink
30
+ end
31
+
32
+ describe 'TITLE' do
33
+ it "parses a single string" do
34
+ tf = Tempfile.new('mylauncher.txt')
35
+ tf.puts "TITLE \"MyLauncher\""
36
+ tf.close
37
+
38
+ lc = LauncherConfig.new(tf.path)
39
+ expect(lc.title).to eq "MyLauncher"
40
+ tf.unlink
41
+ end
42
+
43
+ it "raises with more than 1 parameter" do
44
+ tf = Tempfile.new('mylauncher.txt')
45
+ tf.puts "TITLE My Launcher"
46
+ tf.close
47
+
48
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
49
+ tf.unlink
50
+ end
51
+ end
52
+
53
+ describe 'DIVIDER' do
54
+ it "parses without arguments" do
55
+ tf = Tempfile.new('mylauncher.txt')
56
+ tf.puts "DIVIDER"
57
+ tf.close
58
+
59
+ expect { LauncherConfig.new(tf.path) }.to_not raise_error
60
+ tf.unlink
61
+ end
62
+
63
+ it "raises with a parameter" do
64
+ tf = Tempfile.new('mylauncher.txt')
65
+ tf.puts "DIVIDER 1"
66
+ tf.close
67
+
68
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
69
+ tf.unlink
70
+ end
71
+ end
72
+
73
+ describe 'NUM_COLUMNS' do
74
+ it "parses a single value" do
75
+ tf = Tempfile.new('mylauncher.txt')
76
+ tf.puts "NUM_COLUMNS 6"
77
+ tf.close
78
+
79
+ lc = LauncherConfig.new(tf.path)
80
+ expect(lc.num_columns).to eq 6
81
+ tf.unlink
82
+ end
83
+
84
+ it "raises with a string" do
85
+ tf = Tempfile.new('mylauncher.txt')
86
+ tf.puts "NUM_COLUMNS TWO"
87
+ tf.close
88
+
89
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
90
+ tf.unlink
91
+ end
92
+
93
+ it "raises with more than 1 parameter" do
94
+ tf = Tempfile.new('mylauncher.txt')
95
+ tf.puts "NUM_COLUMNS 2 3"
96
+ tf.close
97
+
98
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
99
+ tf.unlink
100
+ end
101
+ end
102
+
103
+ describe 'LABEL' do
104
+ it "parses a single value" do
105
+ tf = Tempfile.new('mylauncher.txt')
106
+ tf.puts "LABEL 'HI THERE'"
107
+ tf.close
108
+
109
+ lc = LauncherConfig.new(tf.path)
110
+ expect(lc.items[0][0]).to eq :LABEL
111
+ expect(lc.items[0][1]).to eq "HI THERE"
112
+ expect(lc.items[0][2]).to be_nil
113
+ expect(lc.items[0][3]).to be_nil
114
+ expect(lc.items[0][4]).to be_nil
115
+ tf.unlink
116
+ end
117
+
118
+ it "raises with more than 1 parameter" do
119
+ tf = Tempfile.new('mylauncher.txt')
120
+ tf.puts "LABEL HI THERE"
121
+ tf.close
122
+
123
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
124
+ tf.unlink
125
+ end
126
+ end
127
+
128
+ describe 'TOOL_FONT' do
129
+ it "parses the font and size" do
130
+ tf = Tempfile.new('mylauncher.txt')
131
+ tf.puts "TOOL_FONT tahoma 12"
132
+ tf.close
133
+
134
+ lc = LauncherConfig.new(tf.path)
135
+ expect(lc.tool_font_settings[0]).to eq 'tahoma'
136
+ expect(lc.tool_font_settings[1]).to eq 12
137
+ tf.unlink
138
+ end
139
+
140
+ it "raises with only 1 parameter" do
141
+ tf = Tempfile.new('mylauncher.txt')
142
+ tf.puts "TOOL_FONT tahoma"
143
+ tf.close
144
+
145
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
146
+ tf.unlink
147
+ end
148
+
149
+ it "raises with more than 2 parameters" do
150
+ tf = Tempfile.new('mylauncher.txt')
151
+ tf.puts "TOOL_FONT tahoma 12 16"
152
+ tf.close
153
+
154
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
155
+ tf.unlink
156
+ end
157
+
158
+ # TODO: Is it possible to check for bad fonts?
159
+
160
+ it "raises with a bad size" do
161
+ tf = Tempfile.new('mylauncher.txt')
162
+ tf.puts "TOOL_FONT tahoma arial"
163
+ tf.close
164
+
165
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
166
+ tf.unlink
167
+ end
168
+ end
169
+
170
+ describe 'LABEL_FONT' do
171
+ it "parses the font and size" do
172
+ tf = Tempfile.new('mylauncher.txt')
173
+ tf.puts "LABEL_FONT tahoma 12"
174
+ tf.close
175
+
176
+ lc = LauncherConfig.new(tf.path)
177
+ expect(lc.label_font_settings[0]).to eq 'tahoma'
178
+ expect(lc.label_font_settings[1]).to eq 12
179
+ tf.unlink
180
+ end
181
+
182
+ it "raises with only 1 parameter" do
183
+ tf = Tempfile.new('mylauncher.txt')
184
+ tf.puts "LABEL_FONT tahoma"
185
+ tf.close
186
+
187
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
188
+ tf.unlink
189
+ end
190
+
191
+ it "raises with more than 2 parameters" do
192
+ tf = Tempfile.new('mylauncher.txt')
193
+ tf.puts "LABEL_FONT tahoma 12 16"
194
+ tf.close
195
+
196
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
197
+ tf.unlink
198
+ end
199
+
200
+ # TODO: Is it possible to check for bad fonts?
201
+
202
+ it "raises with a bad size" do
203
+ tf = Tempfile.new('mylauncher.txt')
204
+ tf.puts "LABEL_FONT tahoma arial"
205
+ tf.close
206
+
207
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
208
+ tf.unlink
209
+ end
210
+ end
211
+
212
+ describe "DONT_CAPTURE_IO" do
213
+ it "must follow a TOOL" do
214
+ tf = Tempfile.new('mylauncher.txt')
215
+ tf.puts ' DONT_CAPTURE_IO'
216
+ tf.close
217
+
218
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
219
+ tf.unlink
220
+
221
+ tf = Tempfile.new('mylauncher.txt')
222
+ tf.puts 'MULTITOOL_START "MyTool"'
223
+ tf.puts ' DONT_CAPTURE_IO'
224
+ tf.puts ' TOOL "LAUNCH CmdTlmServer"'
225
+ tf.puts 'MULTITOOL_END'
226
+ tf.close
227
+
228
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
229
+ tf.unlink
230
+
231
+ tf = Tempfile.new('mylauncher.txt')
232
+ tf.puts 'TOOL "Server" "LAUNCH CmdTlmServer"'
233
+ tf.puts ' DONT_CAPTURE_IO'
234
+ tf.close
235
+
236
+ lc = LauncherConfig.new(tf.path)
237
+ expect(lc.items[0][3]).to be false
238
+ tf.unlink
239
+ end
240
+
241
+ it "raises with a parameter" do
242
+ tf = Tempfile.new('mylauncher.txt')
243
+ tf.puts 'TOOL "Server" "LAUNCH CmdTlmServer"'
244
+ tf.puts ' DONT_CAPTURE_IO true'
245
+ tf.close
246
+
247
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
248
+ tf.unlink
249
+ end
250
+
251
+ it "valid within MULTITOOL" do
252
+ tf = Tempfile.new('mylauncher.txt')
253
+ tf.puts 'MULTITOOL_START "MyTool"'
254
+ tf.puts ' TOOL "LAUNCH CmdTlmServer"'
255
+ tf.puts ' DONT_CAPTURE_IO'
256
+ tf.puts 'MULTITOOL_END'
257
+ tf.close
258
+
259
+ lc = LauncherConfig.new(tf.path)
260
+ expect(lc.items[0][2][0][2]).to be false
261
+ tf.unlink
262
+ end
263
+ end
264
+
265
+ describe "TOOL" do
266
+ it "parses name and LAUNCH shell command" do
267
+ tf = Tempfile.new('mylauncher.txt')
268
+ tf.puts 'TOOL "Server" "LAUNCH CmdTlmServer --system system.txt -x 0 -y 0"'
269
+ tf.close
270
+
271
+ lc = LauncherConfig.new(tf.path)
272
+ expect(lc.items[0][0]).to eq :TOOL
273
+ expect(lc.items[0][1]).to eq 'Server'
274
+ if Kernel.is_mac? and File.exist?(File.join(USERPATH, 'tools', 'mac'))
275
+ expect(lc.items[0][2]).to eq 'open tools/mac/CmdTlmServer.app --args --system system.txt -x 0 -y 0'
276
+ else
277
+ expect(lc.items[0][2]).to eq 'RUBYW tools/CmdTlmServer --system system.txt -x 0 -y 0'
278
+ end
279
+ expect(lc.items[0][3]).to be true
280
+ expect(lc.items[0][4]).to be_nil
281
+ expect(lc.items[0][5]).to be_nil
282
+ tf.unlink
283
+ end
284
+
285
+ it "parses name and LAUNCH_TERMINAL shell command" do
286
+ tf = Tempfile.new('mylauncher.txt')
287
+ tf.puts 'TOOL "Example" "LAUNCH_TERMINAL Example"'
288
+ tf.close
289
+
290
+ lc = LauncherConfig.new(tf.path)
291
+ expect(lc.items[0][0]).to eq :TOOL
292
+ expect(lc.items[0][1]).to eq 'Example'
293
+ if Kernel.is_mac?
294
+ expect(lc.items[0][2]).to eq "osascript -e 'tell application \"Terminal\" to do script \"cd #{File.expand_path(USERPATH)} && ruby tools/Example \"' -e 'return'"
295
+ elsif Kernel.is_windows?
296
+ expect(lc.items[0][2]).to eq "start ruby tools/Example"
297
+ else
298
+ expect(lc.items[0][2]).to eq "gnome-terminal -e \"ruby tools/Example \""
299
+ end
300
+ expect(lc.items[0][3]).to be true
301
+ expect(lc.items[0][4]).to be_nil
302
+ expect(lc.items[0][5]).to be_nil
303
+ tf.unlink
304
+ end
305
+
306
+ it "parses name and random shell command" do
307
+ tf = Tempfile.new('mylauncher.txt')
308
+ tf.puts 'TOOL "List" "ls -la"'
309
+ tf.close
310
+
311
+ lc = LauncherConfig.new(tf.path)
312
+ expect(lc.items[0][0]).to eq :TOOL
313
+ expect(lc.items[0][1]).to eq 'List'
314
+ expect(lc.items[0][2]).to eq 'ls -la'
315
+ tf.unlink
316
+ end
317
+
318
+ it "parses icon and parameters" do
319
+ tf = Tempfile.new('mylauncher.txt')
320
+ tf.puts 'TOOL "Server" "LAUNCH CmdTlmServer --system system.txt -x 0 -y 0" "cts.png" --config server.txt --width 500 --height 500'
321
+ tf.close
322
+
323
+ lc = LauncherConfig.new(tf.path)
324
+ expect(lc.items[0][4]).to eq 'cts.png'
325
+ expect(lc.items[0][5].join(' ')).to eq '--config server.txt --width 500 --height 500'
326
+ tf.unlink
327
+ end
328
+
329
+ it "raises with less than 2 parameters" do
330
+ tf = Tempfile.new('mylauncher.txt')
331
+ tf.puts 'TOOL "Server"'
332
+ tf.close
333
+
334
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
335
+ tf.unlink
336
+ end
337
+ end
338
+
339
+ describe "DELAY" do
340
+ it "only valid within MULTITOOL" do
341
+ tf = Tempfile.new('mylauncher.txt')
342
+ tf.puts ' DELAY'
343
+ tf.close
344
+
345
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
346
+ tf.unlink
347
+
348
+ tf = Tempfile.new('mylauncher.txt')
349
+ tf.puts 'MULTITOOL_START "MyTool" icon.png'
350
+ tf.puts ' DELAY 1'
351
+ tf.puts ' TOOL "LAUNCH CmdTlmServer"'
352
+ tf.puts 'MULTITOOL_END'
353
+ tf.close
354
+
355
+ lc = LauncherConfig.new(tf.path)
356
+ expect(lc.items[0][2][0][0]).to eq :DELAY
357
+ expect(lc.items[0][2][0][1]).to eq 1
358
+ tf.unlink
359
+ end
360
+
361
+ it "raises without a parameter" do
362
+ tf = Tempfile.new('mylauncher.txt')
363
+ tf.puts 'MULTITOOL_START "MyTool" icon.png'
364
+ tf.puts ' DELAY'
365
+ tf.puts ' TOOL "LAUNCH CmdTlmServer"'
366
+ tf.puts 'MULTITOOL_END'
367
+ tf.close
368
+
369
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
370
+ tf.unlink
371
+ end
372
+
373
+ it "raises with more than 1 parameter" do
374
+ tf = Tempfile.new('mylauncher.txt')
375
+ tf.puts 'MULTITOOL_START "MyTool" icon.png'
376
+ tf.puts ' DELAY 1 2'
377
+ tf.puts ' TOOL "LAUNCH CmdTlmServer"'
378
+ tf.puts 'MULTITOOL_END'
379
+ tf.close
380
+
381
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
382
+ tf.unlink
383
+ end
384
+ end
385
+
386
+ describe "MULTITOOL" do
387
+ it "parses name and icon" do
388
+ tf = Tempfile.new('mylauncher.txt')
389
+ tf.puts 'MULTITOOL_START "MyTool" icon.png'
390
+ tf.puts ' TOOL "LAUNCH CmdTlmServer"'
391
+ tf.puts 'MULTITOOL_END'
392
+ tf.close
393
+
394
+ lc = LauncherConfig.new(tf.path)
395
+ expect(lc.items[0][0]).to eq :MULTITOOL
396
+ expect(lc.items[0][1]).to eq 'MyTool'
397
+ expect(lc.items[0][2]).to_not be_empty
398
+ expect(lc.items[0][3]).to be true
399
+ expect(lc.items[0][4]).to eq 'icon.png'
400
+ expect(lc.items[0][5]).to be_nil
401
+ tf.unlink
402
+ end
403
+
404
+ it "raises with no parameters" do
405
+ tf = Tempfile.new('mylauncher.txt')
406
+ tf.puts 'MULTITOOL_START'
407
+ tf.puts ' TOOL "LAUNCH CmdTlmServer"'
408
+ tf.puts 'MULTITOOL_END'
409
+ tf.close
410
+
411
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
412
+ tf.unlink
413
+ end
414
+
415
+ it "raises with more than two parameters" do
416
+ tf = Tempfile.new('mylauncher.txt')
417
+ tf.puts 'MULTITOOL_START Launch icon.png more'
418
+ tf.puts ' TOOL "LAUNCH CmdTlmServer"'
419
+ tf.puts 'MULTITOOL_END'
420
+ tf.close
421
+
422
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
423
+ tf.unlink
424
+ end
425
+
426
+ it "raises if no tools are defined" do
427
+ tf = Tempfile.new('mylauncher.txt')
428
+ tf.puts 'MULTITOOL_START Launch'
429
+ tf.puts 'MULTITOOL_END'
430
+ tf.close
431
+
432
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
433
+ tf.unlink
434
+
435
+ tf = Tempfile.new('mylauncher.txt')
436
+ tf.puts 'MULTITOOL_START Launch'
437
+ tf.puts ' DELAY 1'
438
+ tf.puts 'MULTITOOL_END'
439
+ tf.close
440
+
441
+ expect { LauncherConfig.new(tf.path) }.to raise_error(Cosmos::ConfigParser::Error)
442
+ tf.unlink
443
+ end
444
+ end
445
+ end
446
+
447
+ # DONT_CAPTURE_IO
448
+ #MULTITOOL_START "COSMOS"
449
+ # TOOL "LAUNCH CmdTlmServer -x 827 -y 2 -w 756 -t 475 -c cmd_tlm_server.txt"
450
+ # DELAY 5
451
+ # TOOL "LAUNCH TlmViewer -x 827 -y 517 -w 424 -t 111"
452
+ # DONT_CAPTURE_IO
453
+ #MULTITOOL_END
454
+ #DIVIDER
455
+ #LABEL "This is a test"
456
+ #DOC
457
+
458
+ end
459
+ end
460
+