# -*- Makefile -*- # for cp-update tests # Created by: ddzeko@srce.hr, 2005-03-20 # path to cp-update script CPUPDATE=../cp-update tests: test0 test1 test2 test3 test4 test5 test6 @echo "All tests completed successfully" @cp test-file.start test-file clean: test0 test-file.start rm -f test[0-9] test[0-9][0-9] test-file.[0-9]* # prepare everything for test sequence test0: test-file.start cmp test-file test-file.start >/dev/null 2>&1 || cp test-file.start test-file # test line matching # - should match only from the beginning of line # not in the middle of it, so this text should # be added to the end of the file, also adding # newline to it (it's missing from the test-file) test1: echo Block inserted by $@ | $(CPUPDATE) -i update $@ test-file cp test-file test-new cmp test-new $@.ok mv test-new $@ echo Succeeded $@ # test placement # - insert something on top of the file test2: echo Block inserted by $@ | $(CPUPDATE) -t $@ test-file cp test-file test-new cmp test-new $@.ok mv test-new $@ echo Succeeded $@ # test placement # - insert something right in the middle using --insert-after test3: echo Block inserted by $@ | $(CPUPDATE) --insert-after '' $@ test-file cp test-file test-new cmp test-new $@.ok mv test-new $@ echo Succeeded $@ # insert something at the end using --insert-after, due to # failed match -- implicit placement at the end is used test4: echo Block inserted by $@ | $(CPUPDATE) --insert-after 'abracadabra' $@ test-file cp test-file test-new cmp test-new $@.ok mv test-new $@ echo Succeeded $@ # insert bigger blocks we can # - also, using regexp match # - also, alternative comment character # - won't work with old cp-update (no -R) test5: perl -e 'print "test line $$_ by $$ARGV[0]\n" for 1..5;' $@ \ | $(CPUPDATE) -R -c ';' --insert-after '[Jj]aneiro' $@ test-file cp test-file test-new cmp test-new $@.ok mv test-new $@ echo Succeeded $@ # now remove everything test6: test1 test2 test3 test4 test5 for i in test[1-4]; do $(CPUPDATE) -r $$i test-file; done $(CPUPDATE) -r -c ';' test5 test-file cp test-file.start $@.ok echo >> $@.ok cmp test-file $@.ok cp test-file $@ echo Succeeded $@ # more tests needed # --insert-before # --begin/end marks # --in-place mode # --no-close mode # more test on development roadmap: # -- add file-locking - test concurrent updates .SILENT: .PHONY: tests test0 clean