]> git.ipfire.org Git - thirdparty/git.git/blame - t/lib-unique-files.sh
Merge branch 'mg/editorconfig-makefile'
[thirdparty/git.git] / t / lib-unique-files.sh
CommitLineData
d42bab44
NS
1# Helper to create files with unique contents
2
3# Create multiple files with unique contents within this test run. Takes the
4# number of directories, the number of files in each directory, and the base
5# directory.
6#
7# test_create_unique_files 2 3 my_dir -- Creates 2 directories with 3 files
8# each in my_dir, all with contents
9# different from previous invocations
10# of this command in this run.
11
12test_create_unique_files () {
13 test "$#" -ne 3 && BUG "3 param"
14
15 local dirs="$1" &&
16 local files="$2" &&
17 local basedir="$3" &&
18 local counter="0" &&
19 local i &&
20 local j &&
21 test_tick &&
22 local basedata="$basedir$test_tick" &&
23 rm -rf "$basedir" &&
24 for i in $(test_seq $dirs)
25 do
26 local dir="$basedir/dir$i" &&
27 mkdir -p "$dir" &&
28 for j in $(test_seq $files)
29 do
30 counter=$((counter + 1)) &&
31 echo "$basedata.$counter">"$dir/file$j.txt"
32 done
33 done
34}