2010-12-11 05:43:02 -08:00
|
|
|
rm -f stampy usestamp usestamp2 stampy.log usestamp.log usestamp2.log
|
2010-12-11 02:17:51 -08:00
|
|
|
echo one >inp
|
|
|
|
|
|
2011-02-23 01:24:48 -08:00
|
|
|
../flush-cache
|
2010-12-11 02:17:51 -08:00
|
|
|
redo stampy
|
|
|
|
|
[ "$(wc -l <stampy.log)" -eq 1 ] || exit 11
|
|
|
|
|
|
2010-12-11 05:43:02 -08:00
|
|
|
# stampy already exists, so we won't generate it a second time, even though
|
|
|
|
|
# usestamp depends on it.
|
2011-02-23 01:24:48 -08:00
|
|
|
../flush-cache
|
2010-12-11 02:17:51 -08:00
|
|
|
redo-ifchange usestamp
|
|
|
|
|
[ "$(wc -l <stampy.log)" -eq 1 ] || exit 21
|
|
|
|
|
[ "$(wc -l <usestamp.log)" -eq 1 ] || exit 12
|
|
|
|
|
|
2011-02-23 01:24:48 -08:00
|
|
|
../flush-cache
|
2010-12-11 02:17:51 -08:00
|
|
|
redo stampy
|
2010-12-11 20:54:46 -08:00
|
|
|
. ../skip-if-minimal-do.sh
|
2010-12-11 02:17:51 -08:00
|
|
|
[ "$(wc -l <stampy.log)" -eq 2 ] || exit 31
|
|
|
|
|
[ "$(wc -l <usestamp.log)" -eq 1 ] || exit 32
|
|
|
|
|
|
2010-12-11 05:43:02 -08:00
|
|
|
# same as above: stampy is already up-to-date, so it won't be redone.
|
2011-02-23 01:24:48 -08:00
|
|
|
../flush-cache
|
2010-12-11 02:17:51 -08:00
|
|
|
redo-ifchange usestamp
|
|
|
|
|
[ "$(wc -l <stampy.log)" -eq 2 ] || exit 41
|
|
|
|
|
[ "$(wc -l <usestamp.log)" -eq 1 ] || exit 42
|
|
|
|
|
|
2010-12-11 05:43:02 -08:00
|
|
|
# stampy depends on bob, so we'll have to rebuild stampy automatically. But
|
2012-02-07 23:52:54 -05:00
|
|
|
# stampy's checksum will still be identical, so usestamp shouldn't rebuild.
|
2011-02-23 01:24:48 -08:00
|
|
|
../flush-cache
|
2010-12-11 03:29:38 -08:00
|
|
|
redo bob
|
2012-02-07 23:52:54 -05:00
|
|
|
../flush-cache
|
2010-12-11 03:29:38 -08:00
|
|
|
redo-ifchange usestamp
|
|
|
|
|
[ "$(wc -l <stampy.log)" -eq 3 ] || exit 43
|
The second half of redo-stamp: out-of-order building.
If a depends on b depends on c, and c is dirty but b uses redo-stamp
checksums, then 'redo-ifchange a' is indeterminate: we won't know if we need
to run a.do unless we first build b, but the script that *normally* runs
'redo-ifchange b' is a.do, and we don't want to run that yet, because we
don't know for sure if b is dirty, and we shouldn't build a unless one of
its dependencies is dirty. Eek!
Luckily, there's a safe solution. If we *know* a is dirty - eg. because
a.do or one of its children has definitely changed - then we can just run
a.do immediately and there's no problem, even if b is indeterminate, because
we were going to run a.do anyhow.
If a's dependencies are *not* definitely dirty, and all we have is
indeterminate ones like b, then that means a's build process *hasn't
changed*, which means its tree of dependencies still includes b, which means
we can deduce that if we *did* run a.do, it would end up running b.do.
Since we know that anyhow, we can safely just run b.do, which will either
b.set_checked() or b.set_changed(). Once that's done, we can re-parse a's
dependencies and this time conclusively tell if it needs to be redone or
not. Even if it does, b is already up-to-date, so the 'redo-ifchange b'
line in a.do will be fast.
...now take all the above and do it recursively to handle nested
dependencies, etc, and you're done.
2010-12-11 04:40:05 -08:00
|
|
|
[ "$(wc -l <usestamp.log)" -eq 1 ] || exit 44
|
2010-12-11 03:29:38 -08:00
|
|
|
|
2012-02-07 23:52:54 -05:00
|
|
|
# Make sure the previous step correctly marked stampy and usestamp as
|
|
|
|
|
# up-to-date even though *neither* of them is newer than bob.
|
2011-02-23 01:24:48 -08:00
|
|
|
../flush-cache
|
2010-12-11 03:29:38 -08:00
|
|
|
redo-ifchange usestamp
|
|
|
|
|
[ "$(wc -l <stampy.log)" -eq 3 ] || exit 45
|
The second half of redo-stamp: out-of-order building.
If a depends on b depends on c, and c is dirty but b uses redo-stamp
checksums, then 'redo-ifchange a' is indeterminate: we won't know if we need
to run a.do unless we first build b, but the script that *normally* runs
'redo-ifchange b' is a.do, and we don't want to run that yet, because we
don't know for sure if b is dirty, and we shouldn't build a unless one of
its dependencies is dirty. Eek!
Luckily, there's a safe solution. If we *know* a is dirty - eg. because
a.do or one of its children has definitely changed - then we can just run
a.do immediately and there's no problem, even if b is indeterminate, because
we were going to run a.do anyhow.
If a's dependencies are *not* definitely dirty, and all we have is
indeterminate ones like b, then that means a's build process *hasn't
changed*, which means its tree of dependencies still includes b, which means
we can deduce that if we *did* run a.do, it would end up running b.do.
Since we know that anyhow, we can safely just run b.do, which will either
b.set_checked() or b.set_changed(). Once that's done, we can re-parse a's
dependencies and this time conclusively tell if it needs to be redone or
not. Even if it does, b is already up-to-date, so the 'redo-ifchange b'
line in a.do will be fast.
...now take all the above and do it recursively to handle nested
dependencies, etc, and you're done.
2010-12-11 04:40:05 -08:00
|
|
|
[ "$(wc -l <usestamp.log)" -eq 1 ] || exit 46
|
2010-12-11 03:29:38 -08:00
|
|
|
|
2012-02-07 23:52:54 -05:00
|
|
|
# now we're changing the contents of stampy. Thus usestamp will need to
|
|
|
|
|
# be rebuilt, but not yet...
|
2010-12-11 02:17:51 -08:00
|
|
|
echo two >inp
|
2012-02-07 23:52:54 -05:00
|
|
|
../flush-cache
|
2010-12-11 02:17:51 -08:00
|
|
|
redo stampy
|
2010-12-11 03:29:38 -08:00
|
|
|
[ "$(wc -l <stampy.log)" -eq 4 ] || exit 51
|
The second half of redo-stamp: out-of-order building.
If a depends on b depends on c, and c is dirty but b uses redo-stamp
checksums, then 'redo-ifchange a' is indeterminate: we won't know if we need
to run a.do unless we first build b, but the script that *normally* runs
'redo-ifchange b' is a.do, and we don't want to run that yet, because we
don't know for sure if b is dirty, and we shouldn't build a unless one of
its dependencies is dirty. Eek!
Luckily, there's a safe solution. If we *know* a is dirty - eg. because
a.do or one of its children has definitely changed - then we can just run
a.do immediately and there's no problem, even if b is indeterminate, because
we were going to run a.do anyhow.
If a's dependencies are *not* definitely dirty, and all we have is
indeterminate ones like b, then that means a's build process *hasn't
changed*, which means its tree of dependencies still includes b, which means
we can deduce that if we *did* run a.do, it would end up running b.do.
Since we know that anyhow, we can safely just run b.do, which will either
b.set_checked() or b.set_changed(). Once that's done, we can re-parse a's
dependencies and this time conclusively tell if it needs to be redone or
not. Even if it does, b is already up-to-date, so the 'redo-ifchange b'
line in a.do will be fast.
...now take all the above and do it recursively to handle nested
dependencies, etc, and you're done.
2010-12-11 04:40:05 -08:00
|
|
|
[ "$(wc -l <usestamp.log)" -eq 1 ] || exit 52
|
2010-12-11 02:17:51 -08:00
|
|
|
|
2012-02-07 23:52:54 -05:00
|
|
|
# let's see about usestamp. It needs to be rebuilt because stampy has changed,
|
|
|
|
|
# but since stampy is *already* changed, stampy itself shouldn't be re-rebuilt.
|
|
|
|
|
../flush-cache
|
2010-12-11 05:43:02 -08:00
|
|
|
redo-ifchange usestamp usestamp2
|
2010-12-11 03:29:38 -08:00
|
|
|
[ "$(wc -l <stampy.log)" -eq 4 ] || exit 61
|
The second half of redo-stamp: out-of-order building.
If a depends on b depends on c, and c is dirty but b uses redo-stamp
checksums, then 'redo-ifchange a' is indeterminate: we won't know if we need
to run a.do unless we first build b, but the script that *normally* runs
'redo-ifchange b' is a.do, and we don't want to run that yet, because we
don't know for sure if b is dirty, and we shouldn't build a unless one of
its dependencies is dirty. Eek!
Luckily, there's a safe solution. If we *know* a is dirty - eg. because
a.do or one of its children has definitely changed - then we can just run
a.do immediately and there's no problem, even if b is indeterminate, because
we were going to run a.do anyhow.
If a's dependencies are *not* definitely dirty, and all we have is
indeterminate ones like b, then that means a's build process *hasn't
changed*, which means its tree of dependencies still includes b, which means
we can deduce that if we *did* run a.do, it would end up running b.do.
Since we know that anyhow, we can safely just run b.do, which will either
b.set_checked() or b.set_changed(). Once that's done, we can re-parse a's
dependencies and this time conclusively tell if it needs to be redone or
not. Even if it does, b is already up-to-date, so the 'redo-ifchange b'
line in a.do will be fast.
...now take all the above and do it recursively to handle nested
dependencies, etc, and you're done.
2010-12-11 04:40:05 -08:00
|
|
|
[ "$(wc -l <usestamp.log)" -eq 2 ] || exit 62
|
2010-12-11 05:43:02 -08:00
|
|
|
[ "$(wc -l <usestamp2.log)" -eq 1 ] || exit 62
|
|
|
|
|
|
|
|
|
|
# when we delete the file and it gets regenerated identically, it's as good as
|
|
|
|
|
# never having been deleted. So usestamp won't need to change.
|
2011-02-23 01:24:48 -08:00
|
|
|
../flush-cache
|
2010-12-11 05:43:02 -08:00
|
|
|
rm -f stampy
|
|
|
|
|
redo-ifchange usestamp usestamp2
|
|
|
|
|
[ "$(wc -l <stampy.log)" -eq 5 ] || exit 71
|
|
|
|
|
[ "$(wc -l <usestamp.log)" -eq 2 ] || exit 72
|
|
|
|
|
[ "$(wc -l <usestamp2.log)" -eq 1 ] || exit 73
|
2010-12-11 06:16:32 -08:00
|
|
|
|
|
|
|
|
# this simple test used to cause a deadlock.
|
2011-02-23 01:24:48 -08:00
|
|
|
../flush-cache
|
2010-12-11 06:16:32 -08:00
|
|
|
rm -f stampy
|
|
|
|
|
redo-ifchange stampy
|
|
|
|
|
[ "$(wc -l <stampy.log)" -eq 6 ] || exit 74
|