-
- Downloads
tests: use 'test_must_be_empty' instead of 'test_cmp <empty> <out>'
Using 'test_must_be_empty' is shorter and more idiomatic than >empty && test_cmp empty out as it saves the creation of an empty file. Furthermore, sometimes the expected empty file doesn't have such a descriptive name like 'empty', and its creation is far away from the place where it's finally used for comparison (e.g. in 't7600-merge.sh', where two expected empty files are created in the 'setup' test, but are used only about 500 lines later). These cases were found by instrumenting 'test_cmp' to error out the test script when it's used to compare empty files, and then converted manually. Note that even after this patch there still remain a lot of cases where we use 'test_cmp' to check empty files: - Sometimes the expected output is not hard-coded in the test, but 'test_cmp' is used to ensure that two similar git commands produce the same output, and that output happens to be empty, e.g. the test 'submodule update --merge - ignores --merge for new submodules' in 't7406-submodule-update.sh'. - Repetitive common tasks, including preparing the expected results and running 'test_cmp', are often extracted into a helper function, and some of this helper's callsites expect no output. - For the same reason as above, the whole 'test_expect_success' block is within a helper function, e.g. in 't3070-wildmatch.sh'. - Or 'test_cmp' is invoked in a loop, e.g. the test 'cvs update (-p)' in 't9400-git-cvsserver-server.sh'. Signed-off-by:SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by:
Junio C Hamano <gitster@pobox.com>
Showing
- t/t0001-init.sh 2 additions, 3 deletionst/t0001-init.sh
- t/t0003-attributes.sh 1 addition, 2 deletionst/t0003-attributes.sh
- t/t0030-stripspace.sh 9 additions, 13 deletionst/t0030-stripspace.sh
- t/t0040-parse-options.sh 1 addition, 3 deletionst/t0040-parse-options.sh
- t/t0061-run-command.sh 4 additions, 5 deletionst/t0061-run-command.sh
- t/t1300-config.sh 1 addition, 4 deletionst/t1300-config.sh
- t/t1410-reflog.sh 1 addition, 2 deletionst/t1410-reflog.sh
- t/t1411-reflog-show.sh 1 addition, 2 deletionst/t1411-reflog-show.sh
- t/t1450-fsck.sh 5 additions, 6 deletionst/t1450-fsck.sh
- t/t1600-index.sh 1 addition, 2 deletionst/t1600-index.sh
- t/t1700-split-index.sh 1 addition, 3 deletionst/t1700-split-index.sh
- t/t2200-add-update.sh 1 addition, 2 deletionst/t2200-add-update.sh
- t/t2203-add-intent.sh 2 additions, 4 deletionst/t2203-add-intent.sh
- t/t3001-ls-files-others-exclude.sh 2 additions, 4 deletionst/t3001-ls-files-others-exclude.sh
- t/t3004-ls-files-basic.sh 2 additions, 4 deletionst/t3004-ls-files-basic.sh
- t/t3035-merge-sparse.sh 2 additions, 3 deletionst/t3035-merge-sparse.sh
- t/t3301-notes.sh 1 addition, 3 deletionst/t3301-notes.sh
- t/t3404-rebase-interactive.sh 2 additions, 3 deletionst/t3404-rebase-interactive.sh
- t/t4015-diff-whitespace.sh 1 addition, 3 deletionst/t4015-diff-whitespace.sh
- t/t4027-diff-submodule.sh 1 addition, 2 deletionst/t4027-diff-submodule.sh
Please register or sign in to comment