-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathchapter-09.srt
145 lines (113 loc) · 2.83 KB
/
chapter-09.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
1
00:00:00,000 --> 00:00:03,988
Chapter 09.
Being lazy within a build.
2
00:00:04,830 --> 00:00:06,788
TS: What next?
3
00:00:06,880 --> 00:00:12,902
JC: We've got dependencies so the
next thing to do... The build has to lazy.
4
00:00:13,588 --> 00:00:18,422
And once you have dependencies, and
you know what your file depends on,
5
00:00:18,420 --> 00:00:24,422
you can tell if your file is up to date because you
can ask your dependencies if they're up to date.
6
00:00:26,110 --> 00:00:32,800
That also introduces the problem of... When a target
builds it tells all its other targets to build.
7
00:00:32,857 --> 00:00:36,708
So what if multiple things
depend on the same target?
8
00:00:36,900 --> 00:00:42,788
In that situation something will be told
to build multiple times, which is wasteful.
9
00:00:43,131 --> 00:00:50,834
So we could write a test that says if you call build
twice on a target, it only runs its command once.
10
00:00:50,868 --> 00:00:52,411
That would be good.
11
00:00:52,480 --> 00:01:03,428
And we also want a test that says if you try to build
a target that's newer than the things it depends on.
12
00:01:03,600 --> 00:01:07,417
Then that should also not do anything.
13
00:01:08,022 --> 00:01:11,748
So I think I'll deal with the first of those first.
14
00:01:12,160 --> 00:01:22,650
So if we go back into our tests:
spec/fakemake/target_spec.rb
15
00:01:24,788 --> 00:01:29,120
We have dealing with dependencies.
16
00:01:29,850 --> 00:01:34,114
You don't necessarily need
dependencies for what I was just talking about.
17
00:01:34,137 --> 00:01:38,342
You just want to say if you call build
twice, it should run its instructions once.
18
00:01:38,350 --> 00:01:41,542
So we can put that into the
case where there is an instruction.
19
00:01:41,542 --> 00:01:51,490
So it 'only executes the instructions once' do.
20
00:01:52,590 --> 00:01:56,537
So that's essentially this test over again.
21
00:01:56,560 --> 00:02:00,160
Except that we call this twice.
22
00:02:02,685 --> 00:02:05,120
This ought to fail.
23
00:02:07,085 --> 00:02:08,994
Which it does.
24
00:02:09,234 --> 00:02:14,040
One thing about this test (I'm glad
I did this); it should receive this once.
25
00:02:14,102 --> 00:02:18,022
It's a side effect we care about
how many times it's called.
26
00:02:18,045 --> 00:02:22,160
But RSpec says it was called 2 times.
27
00:02:22,190 --> 00:02:31,165
That ought to be reasonably easy to fix
if we go back into our source code.
28
00:02:31,720 --> 00:02:36,091
If we look at build self we could
store a flag in here that says
29
00:02:36,160 --> 00:02:38,868
I've been built you don't need to do anything.
30
00:02:38,891 --> 00:02:44,200
So return if already built.
31
00:02:44,200 --> 00:02:49,154
And then set that to true.
32
00:02:52,342 --> 00:02:58,114
And then that's passing. So I think I'll commit that.