-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathchapter-11.srt
256 lines (200 loc) · 5.04 KB
/
chapter-11.srt
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
1
00:00:00,000 --> 00:00:03,805
Chapter 11.
Specifying Target behaviour
with older and newer dependencies.
2
00:00:04,080 --> 00:00:07,005
JC: OK, now everything is passing,
so the thing does check its mtime.
3
00:00:07,005 --> 00:00:12,537
The next question is does it use the mtime
to do something useful like skipping work.
4
00:00:12,660 --> 00:00:17,211
So when the dependencies are newer than the target...
5
00:00:17,220 --> 00:00:26,160
And that means... So let's say...
Some offset to base these on...
6
00:00:26,354 --> 00:00:32,274
Let the target_time be Time.now.
7
00:00:32,845 --> 00:00:41,142
And then we can say, use that here.
8
00:00:41,140 --> 00:00:46,811
And then it's clearer that they are in
the future from when the target was built.
9
00:00:46,822 --> 00:00:48,628
It doesn't matter that it's Time.now
10
00:00:48,651 --> 00:00:54,480
TS: So are you using Time.now as the most
convenient way to get a real time value?
11
00:00:54,514 --> 00:01:01,165
JC: Yes, actually the current time is not relevant.
12
00:01:01,160 --> 00:01:05,908
So what's the context? When the
dependencies are newer than the target.
13
00:01:05,900 --> 00:01:13,988
That means that the...
14
00:01:14,914 --> 00:01:19,314
allow(File).to receive(:mtime)
15
00:01:19,325 --> 00:01:29,222
So the time the target asks
for will return the target time.
16
00:01:32,845 --> 00:01:37,954
And we need exists to return true as well.
17
00:01:41,930 --> 00:01:47,497
The target will use target_time as its time and the
dependencies have times which are later than that.
18
00:01:49,020 --> 00:01:54,262
The dependencies are newer, so that means
the target should execute its instruction.
19
00:01:54,525 --> 00:01:57,988
But we haven't given it any instructions.
20
00:01:58,170 --> 00:02:04,605
[Silence]
21
00:02:04,690 --> 00:02:12,011
Let the instruction be echo something;
it doesn't really matter what it is.
22
00:02:12,900 --> 00:02:18,537
System is stubbed out in all these tests,
so I'm not really worried about that.
23
00:02:19,100 --> 00:02:26,171
And also we want that output here because
it's going to start printing stuff otherwise.
24
00:02:26,354 --> 00:02:31,668
Do we have that everywhere? We do, OK.
25
00:02:31,660 --> 00:02:40,994
And that line's got quite long so
I'll use terminator block like that.
26
00:02:43,451 --> 00:02:50,525
So we have a target with some dependencies,
an instruction and an output stream.
27
00:02:50,697 --> 00:02:57,588
So we want to say is that in
this case it executes its instruction.
28
00:02:57,634 --> 00:03:02,045
I don't want to specify this by saying you should
invoke some private method that you have,
29
00:03:02,068 --> 00:03:05,188
because that's over specifying
the implementation.
30
00:03:05,211 --> 00:03:12,994
I want to specify the effect that it has on the
world which is that it makes a system command.
31
00:03:14,560 --> 00:03:26,620
So, we expect the target to receive system
with the instruction once when we build it.
32
00:03:28,651 --> 00:03:32,800
Now, it will prob do this anyway
because it isn't checking anything so far
33
00:03:32,800 --> 00:03:36,697
because I haven't introduced
anything that will make that test fail.
34
00:03:36,742 --> 00:03:40,948
TS: So you're currently testing
what it would already do.
35
00:03:40,960 --> 00:03:46,788
But what we're driving towards is what happens when
it's NOT out of date, and you haven't tested that yet.
36
00:03:46,780 --> 00:03:48,491
JC: Exactly.
37
00:03:49,770 --> 00:03:55,005
JC: It's basically going to result
in duplicating most of this context.
38
00:03:55,028 --> 00:03:59,908
So I feel I should pull some of this stuff out.
39
00:04:02,651 --> 00:04:05,211
Lazy building.
40
00:04:05,340 --> 00:04:11,977
So if i have that... I want to take this stuff
which is going to be needed for all of these tests,
41
00:04:12,228 --> 00:04:16,925
and put it in here. But not like that!
42
00:04:21,051 --> 00:04:24,960
And then...
43
00:04:25,050 --> 00:04:33,508
[Silence]
44
00:04:33,630 --> 00:04:39,280
Is that all back in shape? I think so... Yes.
45
00:04:39,370 --> 00:04:41,885
TS: So what's going to be
different in the other context?
46
00:04:41,954 --> 00:04:47,851
JC: The difference is these steps here,
rather than returning things in the future
47
00:04:47,870 --> 00:04:53,702
will return things in the past; or the past
relative to the targets' own modification time.
48
00:04:53,730 --> 00:05:00,697
And in that case we shouldn't execute
the instruction, but just leave things alone.
49
00:05:00,830 --> 00:05:07,531
So I'm going to copy most of that.
50
00:05:07,691 --> 00:05:12,971
and they are not newer, they are older.
51
00:05:13,630 --> 00:05:16,868
And these can be minus signs.
52
00:05:16,910 --> 00:05:23,257
And we can say it does not execute its instruction.
53
00:05:25,440 --> 00:05:30,982
And this is the thing that should fail.
54
00:05:31,165 --> 00:05:37,748
[Silence]
55
00:05:38,120 --> 00:05:44,925
So target.system("echo hi")
expected zero times; received one time.
56
00:05:44,948 --> 00:05:46,845
So that's the thing that needs fixing.