repla 0.8.2 → 0.8.3

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: ecfb7471869f1ce7c0dcd0cfb3d1902c715daf68
4
- data.tar.gz: 1f21628284db84e7fb3fccb80e9fadad4b11a8d8
3
+ metadata.gz: 57bbe0e7d55bf6e9d44f2c7f069040ac838954bf
4
+ data.tar.gz: '008ce57baa887b6b42d3087010f4c2e067ec5682'
5
5
  SHA512:
6
- metadata.gz: bd8adfb40f38eaaa5b347805bd1773e3f5b53443eaa466113fa49857c60abad2b6fbf48c1046d1817cbf06b0f987c6337a649472a5b4c06853b6d32f56d039aa
7
- data.tar.gz: 6c2df0aef4ba1fa73ff4c9b4b881384aae9036ad91c75be8f56954a1da93d4cf8e5c1bcb70938a70b19172769055b1f2b47231bdd7ac0c420c2b85adce8e7b11
6
+ metadata.gz: 917eedbbd7e7595b795a82e87aa21a14777949fbeb5b83af7673830e61719e2bf898af1417473717434629124b7d4b334eee1faa76d04c7e93bf2dc16fe8d5b9
7
+ data.tar.gz: e81ca1c9530aeec1c0764a647eeeab2135bd14e7498f7659af1aa75bb363a479cb653d425d379eb74eb4651216b1b12ae3cb7bb3bdf33be28f3bb709942ec519
@@ -27,7 +27,7 @@ module Repla
27
27
  end
28
28
 
29
29
  def number_of_log_messages
30
- @view.do_javascript(TEST_MESSAGE_COUNT_JAVASCRIPT)
30
+ @view.do_javascript(TEST_MESSAGE_COUNT_JAVASCRIPT).to_i
31
31
  end
32
32
 
33
33
  def last_log_message
@@ -1,48 +1,93 @@
1
1
  module Repla
2
2
  # Test
3
3
  module Test
4
- MESSAGES = [
4
+ ERROR_MESSAGES = [
5
5
  'Testing log error',
6
+ 'ERROR'
7
+ ].freeze
8
+ MESSAGES = [
6
9
  'Testing log message',
7
- 'ERROR',
8
10
  'MESSAGE',
9
11
  'Done'
10
12
  ].freeze
11
- CLASSES = %w[
12
- error
13
- message
14
- message
15
- message
16
- message
17
- ].freeze
13
+ MESSAGE_COUNT = ERROR_MESSAGES.count + MESSAGES.count
18
14
  def self.test_log(window)
19
- test_message = 'Done'
20
15
  test_log_helper = Repla::Test::LogHelper.new(window.window_id)
21
- message = nil
16
+ result = nil
17
+ expected = MESSAGE_COUNT
22
18
  Repla::Test.block_until do
23
- message = test_log_helper.last_log_message
24
- message == test_message
19
+ result = test_log_helper.number_of_log_messages
20
+ result == expected
25
21
  end
26
- (0..MESSAGES.count).each do |i|
27
- result = test_log_helper.log_message_at(i)
28
- message = MESSAGES[i]
29
- if result != message
30
- STDERR.puts "Expected #{message} instead of #{result}"
31
- return false
32
- end
33
- type = CLASSES[i]
34
- type_result = test_log_helper.log_class_at(i)
35
- if type_result != type
36
- STDERR.puts "Expected #{type_result} instead of #{type}"
37
- return false
22
+ error_messages = []
23
+ messages = []
24
+ (0...MESSAGE_COUNT).each do |i|
25
+ message = test_log_helper.log_message_at(i)
26
+ type = test_log_helper.log_class_at(i)
27
+ next if message.nil?
28
+
29
+ if type == 'error'
30
+ error_messages.push(message)
31
+ else
32
+ messages.push(message)
38
33
  end
39
34
  end
40
- expected = MESSAGES.count
41
- result = test_log_helper.number_of_log_messages
42
35
  if expected != result
43
- STDERR.puts "Expected #{expected} instead of #{result}"
36
+ STDERR.puts "Expected #{expected} total messages instead of #{result}"
37
+ STDERR.puts "Messages #{messages}"
38
+ STDERR.puts "Error messages #{error_messages}"
39
+ return false
40
+ end
41
+ # Buffering issues are causing the output of `TestLog.replaplugin` to be
42
+ # unreliable, so for now we're running it through `/usr/bin/script`.
43
+ # Which is reliable, but standard out and standard error get combined.
44
+ combined_expected = ERROR_MESSAGES + MESSAGES
45
+ combined_result = error_messages + messages
46
+ expected = combined_expected.count
47
+ result = combined_result.count
48
+ if expected != result
49
+ STDERR.puts "Expected #{expected} messages instead of #{result}"
50
+ return false
51
+ end
52
+ (0..combined_expected.count).each do |i|
53
+ expected = combined_expected[i]
54
+ result = messages[i]
55
+ next unless expected != result
56
+
57
+ STDERR.puts "At index #{i}, expected message #{expected} instead of "\
58
+ "#{result}"
44
59
  return false
45
60
  end
61
+ # expected = MESSAGES.count
62
+ # result = messages.count
63
+ # if expected != result
64
+ # STDERR.puts "Expected #{expected} messages instead of #{result}"
65
+ # return false
66
+ # end
67
+ # expected = ERROR_MESSAGES.count
68
+ # result = error_messages.count
69
+ # if ERROR_MESSAGES.count != error_messages.count
70
+ # STDERR.puts "Expected #{expected} error messages instead of #{result}"
71
+ # return false
72
+ # end
73
+ # (0..MESSAGES.count).each do |i|
74
+ # expected = MESSAGES[i]
75
+ # result = messages[i]
76
+ # if expected != result
77
+ # STDERR.puts "At index #{i}, expected message #{expected} instead "\
78
+ # "of #{result}"
79
+ # return false
80
+ # end
81
+ # end
82
+ # (0..ERROR_MESSAGES.count).each do |i|
83
+ # expected = ERROR_MESSAGES[i]
84
+ # result = error_messages[i]
85
+ # if expected != result
86
+ # STDERR.puts "At index #{i}, expected error message #{expected} "\
87
+ # "instead of #{result}"
88
+ # return false
89
+ # end
90
+ # end
46
91
  true
47
92
  end
48
93
  end
@@ -65,12 +65,17 @@ class TestLoggerObject < Minitest::Test
65
65
 
66
66
  def test_logger_object
67
67
  # Test Error
68
+ # This test doesn't call `@logger.error` because `TestLog.replaplugin` had
69
+ # to be changed being run with `/usr/bin/script` which combines standard
70
+ # output and standard error.
68
71
  message = 'Testing log error'
69
- @logger.error(message)
70
- message = 'Testing log message'
71
72
  @logger.info(message)
73
+ # @logger.error(message)
72
74
  message = Repla::Logger::ERROR_PREFIX.rstrip
73
75
  @logger.info(message)
76
+ # @logger.error(message)
77
+ message = 'Testing log message'
78
+ @logger.info(message)
74
79
  message = Repla::Logger::MESSAGE_PREFIX.rstrip
75
80
  @logger.info(message)
76
81
  @logger.info('')
@@ -5,7 +5,7 @@
5
5
  <key>WCName</key>
6
6
  <string>TestLog</string>
7
7
  <key>WCCommand</key>
8
- <string>echo.sh</string>
8
+ <string>run.sh</string>
9
9
  <key>WCUUID</key>
10
10
  <string>7A95638E-798D-437C-9404-08E7DC68655B</string>
11
11
  <key>WCEditable</key>
@@ -4,8 +4,8 @@ set -e
4
4
 
5
5
  echo 'Testing log error' >&2
6
6
  printf "\n" >&2
7
+ echo 'ERROR ' >&2
7
8
  echo 'Testing log message'
8
- echo 'ERROR '
9
9
  echo 'MESSAGE '
10
10
  echo
11
11
  printf "\t"
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+ script_dir="$( cd "$(dirname "$0")" ; pwd -P )"
5
+ echo_path="$script_dir/echo.sh"
6
+ /usr/bin/script -q /dev/null "$echo_path"
data/lib/repla/test.rb CHANGED
@@ -24,8 +24,9 @@ module Repla
24
24
  'http://127.0.0.1:5000/' + filename
25
25
  end
26
26
 
27
- def self.block_until_with_timeout(timeout)
28
- cycles = [timeout / POLLING_INTERVAL, 1].max
27
+ def self.block_until_with_timeout(timeout,
28
+ polling_interval = POLLING_INTERVAL)
29
+ cycles = [timeout / polling_interval, 1].max
29
30
  count = 0
30
31
  until yield || count >= cycles
31
32
  sleep(POLLING_INTERVAL)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repla
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roben Kleene
@@ -141,6 +141,7 @@ files:
141
141
  - lib/repla/test/packages/TestEnvironment.replaplugin/Contents/Resources/test_environment.rb
142
142
  - lib/repla/test/packages/TestLog.replaplugin/Contents/Info.plist
143
143
  - lib/repla/test/packages/TestLog.replaplugin/Contents/Resources/echo.sh
144
+ - lib/repla/test/packages/TestLog.replaplugin/Contents/Resources/run.sh
144
145
  - lib/repla/test/packages/TestServer.replaplugin/Contents/Info.plist
145
146
  - lib/repla/test/packages/TestServer.replaplugin/Contents/Resources/server.sh
146
147
  homepage: