nrk (owner)

Revisions

gist: 170232 Download_button fork
public
Description:
Testing rufus-scheduler (git 513214a) under IronRuby (git 8d1b9f3c)
Public Clone URL: git://gist.github.com/170232.git
Embed All Files: show embed
blocking_spec.rb.diff #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
diff --git a/spec/blocking_spec.rb b/spec/blocking_spec.rb
index 3f1b212..a29ad84 100644
--- a/spec/blocking_spec.rb
+++ b/spec/blocking_spec.rb
@@ -26,29 +26,31 @@ describe SCHEDULER_CLASS do
       puts '=' * 80
       p e
       puts '=' * 80
     end
   end
 
   it 'should not block when :blocking => nil' do
 
     $var = []
     @s.in('1s') { JOB.call(1) }
+ sleep 0.001
     @s.in('1s') { JOB.call(2) }
 
     sleep 5.0
 
     [ %w{ a1 a2 b1 b2 }, %w{ a1 a2 b2 b1 } ].should.include($var)
   end
 
   it 'should block when :blocking => true' do
 
     $var = []
     @s.in('1s', :blocking => true) { JOB.call(8) }
+ sleep 0.001
     @s.in('1s', :blocking => true) { JOB.call(9) }
 
     sleep 4.5
 
     $var.should.equal(%w{ a8 b8 a9 b9 })
   end
 end
 
 
ir_rufus-scheduler.txt #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
rufus-scheduler 2.0.2 (git commit 513214a)
IronRuby 0.9.x (git commit 8d1b9f3c)
 
* When new OS threads are scheduled for execution, their actual order of
  execution is non-deterministic and therefore we may get different results in
  the blocking specs from time to time. Adding a sleep between the creation of
  the two Job instances, even with a tiny value, alleviates the occurrence of
  the above mentioned issue.
 
* EmScheduler cannot work under IronRuby, we do not have EventMachine.
 
* There was a bug in Time#at in IronRuby, the local time must be computed on
  the resulting value and not on epoch. Fixed on my repository, the fix will
  get into IronRuby after code review + pull.
rufus-scheduler.specs_output.txt #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
Rufus::Scheduler::PlainScheduler
- should override jobs with the same id
 
Rufus::Scheduler::PlainScheduler#schedule_at
- should have job ids with the class name in it
- should accept integers as 'at'
- should schedule at 'top + 1'
- should trigger immediately jobs in the past
- should unschedule
- should accept tags for jobs
 
Rufus::Scheduler::AtJob
- should unschedule itself
- should respond to #next_time
 
Rufus::Scheduler::PlainScheduler
- should not block when :blocking => nil
- should block when :blocking => true
 
Rufus::CronLine
- should interpret cron strings correctly
 
Rufus::CronLine#next_time
- should compute next occurence correctly
 
Rufus::Scheduler::PlainScheduler#cron
- should have job ids with the class name in it
- should cron every second
- should unschedule
- should keep track of cron jobs
- should accept tags for jobs
- should accept job.unschedule within the job
 
Rufus::Scheduler::CronJob
- should respond to #next_time
 
Rufus::Scheduler::PlainScheduler#every
- should have job ids with the class name in it
- should compute frequency
- should schedule every 1s
- should be punctilious
- should unschedule
- should accept tags for jobs
- should honour :first_at
- should honour :first_in
- should accept job.unschedule within the job
- should respect :blocking => true
 
Rufus::Scheduler::EveryJob
- should respond to #next_time
 
Rufus::Scheduler::PlainScheduler
- should emit exception messages to stdout
- should accept custom handling of exceptions
- should accept overriding #log_exception
 
Rufus::Scheduler::PlainScheduler#in
- should have job ids with the class name in it
- should track scheduled in jobs
- should schedule in 1
- should schedule in 1.0
- should schedule in 1s
- should trigger [almost] immediately jobs in the past
- should not trigger jobs in the past when :discard_past => true
- should unschedule job
- should accept tags for jobs
 
Rufus::Scheduler::InJob
- should unschedule itself
- should respond to #next_time
 
rufus/otime
- should parse duration strings
- should generate duration strings
- should compute duration hashes
 
rufus/otime#at_to_f
- should turn Time at values to float
- should turn String at values to float
- should accept integers
 
Rufus::Scheduler::Schedulable
- should schedule via :schedulable
- should honour schedulables that reply to :call
 
Rufus::Scheduler::PlainScheduler
- should stop
- should set a default scheduler thread name
- should set the scheduler thread name
- should accept a custom frequency
 
Rufus::Scheduler#start_new
- should piggyback EM if present and running
 
58 specifications (130 requirements), 0 failures, 0 errors
 
 
TimeOps.cs.diff #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
diff --git a/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/TimeOps.cs b/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/TimeOps.cs
index 461f7c9..efb7b33 100644
--- a/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/TimeOps.cs
+++ b/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/TimeOps.cs
@@ -53,18 +53,18 @@ namespace IronRuby.Builtins {
             return new DateTime(other.Ticks, other.Kind);
         }
 
         [RubyMethod("at", RubyMethodAttributes.PublicSingleton)]
         public static DateTime Create(object/*!*/ self, double seconds) {
- return epoch.ToLocalTime().AddSeconds(seconds);
+ return epoch.AddSeconds(seconds).ToLocalTime();
         }
         
 
         [RubyMethod("at", RubyMethodAttributes.PublicSingleton)]
         public static DateTime Create(object/*!*/ self, long seconds, long microseconds) {
- long ticks = epoch.ToLocalTime().Ticks + secondsToTicks(seconds) + microsecondsToTicks(microseconds);
- return new DateTime(ticks);
+ long ticks = epoch.Ticks + secondsToTicks(seconds) + microsecondsToTicks(microseconds);
+ return new DateTime(ticks).ToLocalTime();
         }
 
         #endregion
 
         [RubyMethod("now", RubyMethodAttributes.PublicSingleton)]