Skip to content

Commit

Permalink
fixes #75 (I think) by incorporating aspects of #76 and modifying a test
Browse files Browse the repository at this point in the history
  • Loading branch information
ihh committed May 29, 2020
1 parent 19bf182 commit 14769f7
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 10 deletions.
2 changes: 2 additions & 0 deletions prolog/biomake/md5hash.pl
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@
update_md5_file(T,DL,Opts) :-
debug(md5,'updating MD5 hash file for ~w <-- ~w',[T,DL]),
delete_md5_file(T),
% retract the database value, which will be stale
retract_md5_hash(T),
md5_check(T,SizeT,HashT,Opts),
make_md5_hash_term(T,SizeT,HashT,HashTerm),
make_md5_valid_term(T,SizeT,HashT,ValidTerm),
Expand Down
5 changes: 4 additions & 1 deletion prolog/test/test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@
run_test("ref/md5.len","target/md5.len",["echo wrong >hello","echo wrong length >world","echo wrong_wrong >hello_world","sleep 1","mkdir -p .biomake/md5","cp ../md5.checksums/* .biomake/md5"],[],"-H","hello_world"),

% this next test checks that the MD5 checksums are recomputed if the MD5 cache file modification times look stale.
run_test("ref/md5.time","target/md5.time",["echo wrong >hello","echo wrong_wrong >hello_world","sleep 1","mkdir -p .biomake/md5","cp ../md5.checksums/* .biomake/md5","sleep 1","echo wrong >world"],[],"-H","hello_world"),
run_test("ref/md5.time","target/md5.time",["echo wrong >hello","echo wrong_wrong >hello_world","sleep 1","mkdir -p .biomake/md5","cp ../md5.checksums/* .biomake/md5","sleep 1","echo world >world"],[],"-H","hello_world"),

% this next test checks that, once the MD5 checksums are recomputed if the MD5 cache file modification times look stale, the target is then rebuilt if the hash turns out to have been different from the one stored in the cache file.
run_test("ref/md5.time2","target/md5.time2",["echo wrong >hello","echo wrong_wrong >hello_world","sleep 1","mkdir -p .biomake/md5","cp ../md5.checksums/* .biomake/md5","sleep 1","echo wrong >world"],[],"-H","hello_world"),

announce("QUEUES"),

Expand Down
6 changes: 3 additions & 3 deletions t/ref/md5.time/.biomake/md5/hello_world
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
md5_hash("hello_world",12,"d1f1b13ee233eca000599110b021bce7").
md5_valid("hello_world",12,"d1f1b13ee233eca000599110b021bce7",X) :-
md5_hash("hello_world",12,"0f723ae7f9bf07744445e93ac5595156").
md5_valid("hello_world",12,"0f723ae7f9bf07744445e93ac5595156",X) :-
md5_check("hello",6,"b1946ac92492d2347c6235b4d2611184",X),
md5_check("world",6,"0f7220a0df94ad88e497ae2fa6c56cdd",X).
md5_check("world",6,"591785b794601e212b260e25925636fd",X).
4 changes: 2 additions & 2 deletions t/ref/md5.time/.biomake/md5/world
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
md5_hash("world",6,"0f7220a0df94ad88e497ae2fa6c56cdd").
md5_valid("world",6,"0f7220a0df94ad88e497ae2fa6c56cdd",X).
md5_hash("world",6,"591785b794601e212b260e25925636fd").
md5_valid("world",6,"591785b794601e212b260e25925636fd",X).
5 changes: 4 additions & 1 deletion t/ref/md5.time/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
hello_world: hello world
cat $^ >$@

hello world:
hello:
echo $@ >$@

world:
echo dolly >$@
3 changes: 1 addition & 2 deletions t/ref/md5.time/hello_world
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
wrong
world
wrong_wrong
2 changes: 2 additions & 0 deletions t/ref/md5.time2/.biomake/md5/hello
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
md5_hash("hello",6,"b1946ac92492d2347c6235b4d2611184").
md5_valid("hello",6,"b1946ac92492d2347c6235b4d2611184",X).
4 changes: 4 additions & 0 deletions t/ref/md5.time2/.biomake/md5/hello_world
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
md5_hash("hello_world",12,"36b2377c5f708db7c8ce844965b2757d").
md5_valid("hello_world",12,"36b2377c5f708db7c8ce844965b2757d",X) :-
md5_check("hello",6,"b1946ac92492d2347c6235b4d2611184",X),
md5_check("world",6,"f8965eeb4165fef5104e147bb11b4bf5",X).
2 changes: 2 additions & 0 deletions t/ref/md5.time2/.biomake/md5/world
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
md5_hash("world",6,"f8965eeb4165fef5104e147bb11b4bf5").
md5_valid("world",6,"f8965eeb4165fef5104e147bb11b4bf5",X).
8 changes: 8 additions & 0 deletions t/ref/md5.time2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
hello_world: hello world
cat $^ >$@

hello:
echo $@ >$@

world:
echo dolly >$@
1 change: 1 addition & 0 deletions t/ref/md5.time2/hello
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wrong
2 changes: 2 additions & 0 deletions t/ref/md5.time2/hello_world
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
wrong
dolly
1 change: 1 addition & 0 deletions t/ref/md5.time2/world
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dolly
5 changes: 4 additions & 1 deletion t/target/md5.time/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
hello_world: hello world
cat $^ >$@

hello world:
hello:
echo $@ >$@

world:
echo dolly >$@
8 changes: 8 additions & 0 deletions t/target/md5.time2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
hello_world: hello world
cat $^ >$@

hello:
echo $@ >$@

world:
echo dolly >$@

0 comments on commit 14769f7

Please sign in to comment.