@@ -84,7 +84,6 @@ def raise_on_mismatches?
8484 #
8585 # Returns the configured block.
8686 def before_run ( &block )
87- marshalize ( block )
8887 @_scientist_before_run = block
8988 end
9089
@@ -100,7 +99,6 @@ def behaviors
10099 #
101100 # Returns the configured block.
102101 def clean ( &block )
103- marshalize ( block )
104102 @_scientist_cleaner = block
105103 end
106104
@@ -133,7 +131,6 @@ def clean_value(value)
133131 #
134132 # Returns the block.
135133 def compare ( *args , &block )
136- marshalize ( block )
137134 @_scientist_comparator = block
138135 end
139136
@@ -144,7 +141,6 @@ def compare(*args, &block)
144141 #
145142 # Returns the block.
146143 def compare_errors ( *args , &block )
147- marshalize ( block )
148144 @_scientist_error_comparator = block
149145 end
150146
@@ -163,7 +159,6 @@ def context(context = nil)
163159 #
164160 # This can be called more than once with different blocks to use.
165161 def ignore ( &block )
166- marshalize ( block )
167162 @_scientist_ignores ||= [ ]
168163 @_scientist_ignores << block
169164 end
@@ -256,7 +251,6 @@ def run(name = nil)
256251
257252 # Define a block that determines whether or not the experiment should run.
258253 def run_if ( &block )
259- marshalize ( block )
260254 @_scientist_run_if_block = block
261255 end
262256
@@ -282,7 +276,6 @@ def should_experiment_run?
282276
283277 # Register a named behavior for this experiment, default "candidate".
284278 def try ( name = nil , &block )
285- marshalize ( block )
286279 name = ( name || "candidate" ) . to_s
287280
288281 if behaviors . include? ( name )
@@ -294,7 +287,6 @@ def try(name = nil, &block)
294287
295288 # Register the control behavior for this experiment.
296289 def use ( &block )
297- marshalize ( block )
298290 try "control" , &block
299291 end
300292
@@ -332,13 +324,14 @@ def generate_result(name)
332324 # In order to support marshaling, we have to make the procs marshalable. Some
333325 # CI providers attempt to marshal Scientist mismatch errors so that they can
334326 # be sent out to different places (logs, etc.) The mismatch errors contain
335- # code from the experiment. This code contains Procs - which can't be
336- # marshaled until we run the following code.
337- def marshalize ( block )
338- unless block . respond_to? ( :_dump ) || block . respond_to? ( :_dump_data )
339- def block . _dump ( _ )
340- to_s
341- end
342- end
327+ # code from the experiment. This code contains procs. These procs prevent the
328+ # error from being marshaled. To fix this, we simple exclude the procs from
329+ # the data that we marshal.
330+ def marshal_dump
331+ [ @name , @result , @raise_on_mismatches ]
332+ end
333+
334+ def marshal_load
335+ @name , @result , @raise_on_mismatches = array
343336 end
344337end
0 commit comments