run_loop 2.1.1.pre1 → 2.1.1.pre2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c918815b4ef775ad83f3f3ade7e33db64704d5b
4
- data.tar.gz: a41970f9c49cb57129305389b4613af8ae2eb833
3
+ metadata.gz: c874aaaaba2d83da288814e78328d8b663a4d44a
4
+ data.tar.gz: 32a4447b971655081d08d06684e974a907d1da8a
5
5
  SHA512:
6
- metadata.gz: 4602a64d7e56fadc22bb0eeb77f11421367b6513c51b0ab3dd6da8e5d38ed836e48223cfbd72176cc878e31c0e748ea5444a4eb5e5c38eee4ce9a58dc6491df5
7
- data.tar.gz: 4b6faebb8be5987067ee0a3af74c35f3c0010256d3636c40fef9d638fd9a3027c693c6786b5f715b04dd85d1fd2f4b63ddccdd10391898bbf8d0218038e52af1
6
+ metadata.gz: 518708e1ce2e1b5f305c2c0b337f85dd2ca86d62431052eba8837cf88b5834c37b56fc397ed5c67c0f8520b7430779b2e788180dac14aae5a6856c301b29eca1
7
+ data.tar.gz: 1899a1efbc4e93ee4bb37763e6a3cf5caacf7001b7cfdea350bc5c12f2c266b67b844c63791e3d5f6f1691695fb338310dfcda6ead233caf95b9229eaa8732d2
data/lib/run_loop/core.rb CHANGED
@@ -89,11 +89,20 @@ module RunLoop
89
89
 
90
90
  script = File.join(results_dir, '_run_loop.js')
91
91
 
92
- code = UIAScriptTemplate.new(SCRIPTS_PATH, options[:script]).result
93
- code = code.gsub(/\$PATH/, results_dir)
94
- code = code.gsub(/\$READ_SCRIPT_PATH/, READ_SCRIPT_PATH)
95
- code = code.gsub(/\$TIMEOUT_SCRIPT_PATH/, TIMEOUT_SCRIPT_PATH)
96
- code = code.gsub(/\$MODE/, 'FLUSH') unless options[:no_flush]
92
+ javascript = UIAScriptTemplate.new(SCRIPTS_PATH, options[:script]).result
93
+ UIAScriptTemplate.sub_path_var!(javascript, results_dir)
94
+ UIAScriptTemplate.sub_read_script_path_var!(javascript, READ_SCRIPT_PATH)
95
+ UIAScriptTemplate.sub_timeout_script_path_var!(javascript, TIMEOUT_SCRIPT_PATH)
96
+
97
+ # Using a :no_* option is confusing.
98
+ # TODO Replace :no_flush with :flush_uia_logs; it should default to true
99
+ if RunLoop::Environment.xtc?
100
+ UIAScriptTemplate.sub_mode_var!(javascript, "FLUSH") unless options[:no_flush]
101
+ else
102
+ if self.detect_flush_uia_log_option(options)
103
+ UIAScriptTemplate.sub_flush_uia_logs_var!(javascript, "FLUSH_LOGS")
104
+ end
105
+ end
97
106
 
98
107
  repl_path = File.join(results_dir, 'repl-cmd.pipe')
99
108
  FileUtils.rm_f(repl_path)
@@ -111,7 +120,7 @@ module RunLoop
111
120
  if include_calabash_script?(options)
112
121
  file.puts IO.read(cal_script)
113
122
  end
114
- file.puts code
123
+ file.puts javascript
115
124
  end
116
125
 
117
126
  args = options.fetch(:args, [])
@@ -661,6 +670,31 @@ Logfile: #{log_file}
661
670
  strategy
662
671
  end
663
672
 
673
+ # @!visibility private
674
+ #
675
+ # UIAutomation buffers log output in some very strange ways. RunLoop
676
+ # attempts to work around this buffering by forcing characters onto the
677
+ # UIALogger buffer. Once the buffer is full, UIAutomation will dump its
678
+ # contents. It is essential that the communication between UIAutomation
679
+ # and RunLoop be synchronized.
680
+ #
681
+ # Casual users should never set the :flush_uia_logs key; they should use the
682
+ # defaults.
683
+ #
684
+ # :no_flush is supported (for now) as alternative key.
685
+ #
686
+ # @param [Hash] options The launch options passed to .run_with_options
687
+ def self.detect_flush_uia_log_option(options)
688
+ if options.has_key?(:no_flush)
689
+ # Confusing.
690
+ # :no_flush == false means, flush the logs.
691
+ # :no_flush == true means, don't flush the logs.
692
+ return !options[:no_flush]
693
+ end
694
+
695
+ return options.fetch(:flush_uia_logs, true)
696
+ end
697
+
664
698
  # @!visibility private
665
699
  #
666
700
  # @param [Hash] options The launch options passed to .run_with_options
@@ -408,6 +408,7 @@ $ bundle exec run-loop simctl manage-processes
408
408
  hash = launch_app_with_simctl
409
409
  exit_status = hash[:exit_status]
410
410
  if exit_status != 0
411
+ out = hash[:out]
411
412
  RunLoop.log_debug("Failed to launch app.")
412
413
  out.split($-0).each do |line|
413
414
  RunLoop.log_debug(" #{line}")
@@ -17,6 +17,10 @@ module RunLoop::DotDir
17
17
  results_dir = File.join(self.directory, 'results')
18
18
  next_results_dir = self.next_timestamped_dirname(results_dir)
19
19
  FileUtils.mkdir_p(next_results_dir)
20
+
21
+ current = File.join(self.directory, "results", "current")
22
+ FileUtils.rm_rf(current)
23
+ FileUtils.ln_s(next_results_dir, current)
20
24
  end
21
25
 
22
26
  next_results_dir
@@ -32,7 +36,7 @@ module RunLoop::DotDir
32
36
  RunLoop.log_debug("Searching for run-loop results with glob: #{glob}")
33
37
 
34
38
  directories = Dir.glob(glob).select do |path|
35
- File.directory?(path)
39
+ File.directory?(path) && !File.symlink?(path)
36
40
  end
37
41
 
38
42
  oldest_first = directories.sort_by { |f| File.mtime(f) }
@@ -9,7 +9,8 @@ module RunLoop
9
9
  # @!visibility private
10
10
  def initialize(template_root, template_relative_path)
11
11
  @template_root = template_root
12
- @template = File.read(File.join(@template_root, template_relative_path)).force_encoding("utf-8")
12
+ template_path = File.join(@template_root, template_relative_path)
13
+ @template = File.read(template_path).force_encoding("utf-8")
13
14
  super(@template)
14
15
  end
15
16
 
@@ -22,5 +23,39 @@ module RunLoop
22
23
  def result
23
24
  super(binding)
24
25
  end
26
+
27
+ # @!visibility private
28
+ def self.sub_path_var!(javascript, results_dir)
29
+ self.substitute_variable!(javascript, "PATH", results_dir)
30
+ end
31
+
32
+ # @!visibility private
33
+ def self.sub_read_script_path_var!(javascript, read_cmd_sh)
34
+ self.substitute_variable!(javascript, "READ_SCRIPT_PATH", read_cmd_sh)
35
+ end
36
+
37
+ # @!visibility private
38
+ def self.sub_timeout_script_path_var!(javascript, timeout_sh)
39
+ self.substitute_variable!(javascript, "TIMEOUT_SCRIPT_PATH", timeout_sh)
40
+ end
41
+
42
+ # @!visibility private
43
+ def self.sub_flush_uia_logs_var!(javascript, value)
44
+ self.substitute_variable!(javascript, "FLUSH_LOGS", value)
45
+ end
46
+
47
+ # @!visibility private
48
+ #
49
+ # Legacy and XTC - related to :no_flush which is a deprecated option.
50
+ #
51
+ # Replaced with :flush_uia_logs
52
+ def self.sub_mode_var!(javascript, value)
53
+ self.substitute_variable!(javascript, "MODE", value)
54
+ end
55
+
56
+ # @!visibility private
57
+ def self.substitute_variable!(javascript, variable, value)
58
+ javascript.gsub!(/\$#{variable}/, value)
59
+ end
25
60
  end
26
61
  end
@@ -1,5 +1,5 @@
1
1
  module RunLoop
2
- VERSION = "2.1.1.pre1"
2
+ VERSION = "2.1.1.pre2"
3
3
 
4
4
  # A model of a software release version that can be used to compare two versions.
5
5
  #
data/scripts/lib/log.js CHANGED
@@ -1,26 +1,26 @@
1
1
  var Log = (function () {
2
- var forceFlush = [],
3
- N = 16384,
4
- i = N;
2
+ var forceFlush = [];
3
+ var N = "$FLUSH_LOGS" == "FLUSH_LOGS" ? 16384 : 0;
4
+ var i = N;
5
5
  while (i--) {
6
6
  forceFlush[i] = "*";
7
7
  }
8
8
  forceFlush = forceFlush.join('');
9
9
 
10
- function log_json(object, flush)
10
+ function log_json(object)
11
11
  {
12
12
  UIALogger.logMessage("OUTPUT_JSON:\n"+JSON.stringify(object)+"\nEND_OUTPUT");
13
- if (flush) {
13
+ if (forceFlush.length > 0) {
14
14
  UIALogger.logMessage(forceFlush);
15
15
  }
16
16
  }
17
17
 
18
18
  return {
19
- result: function (status, data, flush) {
20
- log_json({"status": status, "value": data, "index":_actualIndex}, flush)
19
+ result: function (status, data) {
20
+ log_json({"status": status, "value": data, "index":_actualIndex})
21
21
  },
22
- output: function (msg, flush) {
23
- log_json({"output": msg,"last_index":_actualIndex}, flush);
22
+ output: function (msg) {
23
+ log_json({"output": msg,"last_index":_actualIndex});
24
24
  }
25
25
  };
26
26
  })();
@@ -3,7 +3,7 @@
3
3
  <%= render_template("lib/on_alert.js"); %>
4
4
 
5
5
  UIATarget.onAlert = function (alert) {
6
- Log.output({"output":"on alert"}, true);
6
+ Log.output({"output":"on alert"});
7
7
  var target = UIATarget.localTarget();
8
8
  target.pushTimeout(10);
9
9
  function dismissPrivacyAlert(retry_count) {
@@ -41,6 +41,7 @@ UIATarget.onAlert = function (alert) {
41
41
 
42
42
  dismissPrivacyAlert(0);
43
43
  target.popTimeout();
44
+
44
45
  for (var i=0;i<_RUN_LOOP_MAX_RETRY_AFTER_HANDLER;i++) {
45
46
  req = app.preferencesValueForKey(__calabashRequest);
46
47
  rsp = app.preferencesValueForKey(__calabashResponse);
@@ -143,7 +144,7 @@ var target = null,
143
144
  };
144
145
 
145
146
  _resetCalabashPreferences();
146
- Log.result('success',true,true);
147
+ Log.result('success', true);
147
148
  target = UIATarget.localTarget();
148
149
  while (true) {
149
150
  try {
@@ -175,7 +176,7 @@ while (true) {
175
176
  }
176
177
  catch(err) {
177
178
  failureMessage = "Failure: "+ err.toString() + " " + (err.stack ? err.stack.toString() : "");
178
- Log.output({"output":failureMessage}, true);
179
+ Log.output({"output":failureMessage});
179
180
  _failure(err, _actualIndex);
180
181
  }
181
182
  }
@@ -23,7 +23,7 @@ var _expectedIndex = 0,//expected index of next command
23
23
  <%= render_template("lib/on_alert.js"); %>
24
24
 
25
25
  UIATarget.onAlert = function (alert) {
26
- Log.output({"output":"on alert"}, true);
26
+ Log.output({"output":"on alert");
27
27
  var target = UIATarget.localTarget();
28
28
  target.pushTimeout(10);
29
29
  function dismissPrivacyAlert(retry_count) {
@@ -74,7 +74,12 @@ while (true) {
74
74
  }
75
75
  if (_process.exitCode != 0) {
76
76
  if (_process.exitCode != 15) {
77
- Log.output("unable to execute: " + timeoutScriptPath + " " +readPipeScriptPath + " " + commandPath + " exitCode " + _process.exitCode + ". Error: " + _process.stderr + _process.stdout);
77
+ Log.output("unable to execute: " +
78
+ timeoutScriptPath + " " +
79
+ readPipeScriptPath + " " +
80
+ commandPath + " exitCode "
81
+ + _process.exitCode + ". Error: " +
82
+ _process.stderr + _process.stdout);
78
83
  }
79
84
  }
80
85
  else {
@@ -98,7 +103,9 @@ while (true) {
98
103
 
99
104
  }
100
105
  catch (err) {
101
- Log.result("error", "Input: " + (_exp ? _exp.toString() : "null") + ". Error: " + err.toString() + " " + (err.stack ? err.stack.toString() : ""));
106
+ Log.result("error", "Input: " + (_exp ? _exp.toString() : "null") +
107
+ ". Error: " + err.toString() + " " +
108
+ (err.stack ? err.stack.toString() : ""));
102
109
  _expectedIndex++;
103
110
  continue;
104
111
  }
@@ -45,7 +45,7 @@ UIATarget.onAlert = function (alert) {
45
45
  };
46
46
 
47
47
 
48
- Log.result('success',true,true);
48
+ Log.result('success', true);
49
49
 
50
50
  var _calabashSharedTextField = null,
51
51
  __calabashSharedTextFieldName = '__calabash_uia_channel',
@@ -114,7 +114,7 @@ while (true) {
114
114
  }
115
115
  catch(err) {
116
116
  failureMessage = "Failure: "+ err.toString() + " " + (err.stack ? err.stack.toString() : "");
117
- Log.output({"output":failureMessage}, true);
117
+ Log.output({"output":failureMessage});
118
118
  _failure(err, _actualIndex);
119
119
  }
120
120
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: run_loop
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1.pre1
4
+ version: 2.1.1.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Krukow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-05 00:00:00.000000000 Z
11
+ date: 2016-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json