Class: Bwoken::Script
- Inherits:
-
Object
- Object
- Bwoken::Script
- Defined in:
- lib/bwoken/script.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
- .run(javascript_path) ⇒ Object
- .run_all(device_family) ⇒ Object
- .run_one(feature_name, device_family) ⇒ Object
- .test_files(device_family) ⇒ Object
- .trace_file_path ⇒ Object
Instance Method Summary collapse
- #cmd ⇒ Object
- #device_flag ⇒ Object
- #env_variables ⇒ Object
- #env_variables_for_cli ⇒ Object
- #make_results_path_dir ⇒ Object
- #run ⇒ Object
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
12 13 14 |
# File 'lib/bwoken/script.rb', line 12 def path @path end |
Class Method Details
.run(javascript_path) ⇒ Object
29 30 31 32 33 |
# File 'lib/bwoken/script.rb', line 29 def run javascript_path script = new script.path = javascript_path script.run end |
.run_all(device_family) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/bwoken/script.rb', line 16 def run_all device_family Simulator.device_family = device_family test_files(device_family).each do |javascript| run(javascript) end end |
.run_one(feature_name, device_family) ⇒ Object
24 25 26 27 |
# File 'lib/bwoken/script.rb', line 24 def run_one feature_name, device_family Simulator.device_family = device_family run File.join(Bwoken.test_suite_path, device_family, "#{feature_name}.js") end |
.test_files(device_family) ⇒ Object
39 40 41 42 43 |
# File 'lib/bwoken/script.rb', line 39 def test_files device_family all_files_in_test_dir = Dir["#{Bwoken.test_suite_path}/#{device_family}/**/*.js"] helper_files = Dir["#{Bwoken.test_suite_path}/#{device_family}/**/helpers/**/*.js"] all_files_in_test_dir - helper_files end |
.trace_file_path ⇒ Object
35 36 37 |
# File 'lib/bwoken/script.rb', line 35 def trace_file_path File.join(Bwoken.tmp_path, 'trace') end |
Instance Method Details
#cmd ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/bwoken/script.rb', line 58 def cmd build = Bwoken::Build.new "#{File.expand_path('../../../bin', __FILE__)}/unix_instruments.sh \ #{device_flag} \ -D #{self.class.trace_file_path} \ -t #{Bwoken.path_to_automation_template} \ #{build.app_dir} \ #{env_variables_for_cli}" end |
#device_flag ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/bwoken/script.rb', line 68 def device_flag if Bwoken::Device.should_use_simulator? '' else "-w #{Bwoken::Device.uuid}" end end |
#env_variables ⇒ Object
47 48 49 50 51 52 |
# File 'lib/bwoken/script.rb', line 47 def env_variables { 'UIASCRIPT' => path, 'UIARESULTSPATH' => Bwoken.results_path } end |
#env_variables_for_cli ⇒ Object
54 55 56 |
# File 'lib/bwoken/script.rb', line 54 def env_variables_for_cli env_variables.map{|key,val| "-e #{key} #{val}"}.join(' ') end |
#make_results_path_dir ⇒ Object
76 77 78 |
# File 'lib/bwoken/script.rb', line 76 def make_results_path_dir FileUtils.mkdir_p Bwoken.results_path end |
#run ⇒ Object
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/bwoken/script.rb', line 80 def run Bwoken.formatter.before_script_run path make_results_path_dir exit_status = 0 Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr| exit_status = Bwoken.formatter.format stdout end raise ScriptFailedError.new('Test Script Failed') unless exit_status == 0 end |