@@ -7,6 +7,17 @@ BASELINES=$ROOT/test/image/baselines
7
7
TEST_IMAGES=$ROOT /build/test_images
8
8
DIFF_IMAGES=$ROOT /build/test_images_diff
9
9
10
+ get_mock_path ()
11
+ {
12
+ echo " $MOCKS /$1 .json"
13
+ }
14
+ export -f get_mock_path
15
+
16
+ get_image_path ()
17
+ {
18
+ echo " $TEST_IMAGES /$1 .png"
19
+ }
20
+
10
21
# Deterministic shuffling (https://www.gnu.org/software/coreutils/manual/html_node/Random-sources.html)
11
22
get_seeded_random ()
12
23
{
31
42
CIRCLE_NODE_INDEX=0
32
43
fi
33
44
45
+ rm -f /tmp/all
34
46
if [[ $# -eq 0 ]]; then
35
- echo " No arguments provided"
36
- FIGURE=$( ls $MOCKS /* .json)
47
+ ls $MOCKS /* .json | xargs -I{} -n1 basename {} .json > /tmp/all
37
48
else
38
49
for var in " $@ "
39
50
do
40
- FIGURE= " $FIGURE $MOCKS / $ var.json "
51
+ echo " $ var" >> /tmp/all
41
52
done
42
53
fi
43
54
44
- echo $FIGURE | tr " " " \n" | deterministic_shuffle > /tmp/all
45
- split -d -a3 -n l/$CIRCLE_NODE_TOTAL /tmp/all /tmp/queue
55
+ cat /tmp/all | \
56
+ # Shuffle to distribute randomly slow and fast mocks
57
+ deterministic_shuffle > /tmp/shuffled_all
46
58
59
+ # Split on each node
60
+ split -d -a3 -n l/$CIRCLE_NODE_TOTAL /tmp/shuffled_all /tmp/queue
47
61
NODE_QUEUE=" /tmp/queue$( printf " %03d" $CIRCLE_NODE_INDEX ) "
48
62
49
63
echo " "
50
- echo " Generating test images"
51
- cat $NODE_QUEUE | awk ' !/mapbox/' | \
52
- # Shuffle to distribute randomly slow and fast mocks
53
- deterministic_shuffle | \
54
- # head -n 10 | \
55
- # Split in chunks of 20
56
- xargs -P1 -n20 xvfb-run -a orca graph --verbose --output-dir $TEST_IMAGES
64
+ function generate()
65
+ {
66
+ echo " Generating test images"
67
+ cat $1 | awk ' !/mapbox/' | \
68
+ xargs -n1 -I{} echo " $MOCKS /{}.json" | \
69
+ # Split in chunks of 20
70
+ xargs -P1 -n20 xvfb-run -a orca graph --verbose --output-dir $TEST_IMAGES
71
+ }
72
+ generate $NODE_QUEUE
57
73
58
- echo " Comparing with baselines"
59
- find $TEST_IMAGES -type f -name " *.png" -printf " %f\n" | \
60
- # shuf | \
61
- # sort | \
62
- # head -n 20 | \
63
- # xargs -n1 -P16 -I {} bash -c "echo {} && ./node_modules/.bin/pixelmatch $1/{} $2/{} diff/{} 0 true" | tee results.txt
64
- xargs -n1 -P` nproc` -I {} bash -c " compare -verbose -metric AE $TEST_IMAGES /{} $BASELINES /{} $DIFF_IMAGES /{} 2> $DIFF_IMAGES /{}.txt"
74
+ function compare()
75
+ {
76
+ echo " Comparing with baselines"
77
+ cat $1 | awk ' !/mapbox/' | \
78
+ # find $TEST_IMAGES -type f -name "*.png" -printf "%f\n" | \
79
+ # shuf | \
80
+ # sort | \
81
+ # head -n 20 | \
82
+ # xargs -n1 -P16 -I {} bash -c "echo {} && ./node_modules/.bin/pixelmatch $1/{} $2/{} diff/{} 0 true" | tee results.txt
83
+ xargs -n1 -P` nproc` -I {} bash -c " compare -verbose -metric AE $TEST_IMAGES /{} $BASELINES /{} $DIFF_IMAGES /{} 2> $DIFF_IMAGES /{}.txt"
84
+ }
85
+ compare $NODE_QUEUE
65
86
66
87
CODE=$( grep -R " all: [^0]" $DIFF_IMAGES / | wc -l)
67
- grep -l -R " all: [^0]" $DIFF_IMAGES / | gawk ' {match($0, /diff\/([^.]*)/, arr); print arr[1]}'
88
+
89
+ # If there are different images, retry
90
+ if [ " $CODE " -ne " 0" ]; then
91
+ grep -l -R " all: [^0]" $DIFF_IMAGES / | gawk ' {match($0, /diff\/([^.]*)/, arr); print arr[1]}' > /tmp/failed
92
+ echo " Retrying the following $CODE images"
93
+ cat /tmp/failed
94
+ generate /tmp/failed
95
+ compare /tmp/failed
96
+ CODE=$( grep -R " all: [^0]" $DIFF_IMAGES / | wc -l)
97
+ fi
68
98
echo " $CODE different images"
69
99
exit $CODE
0 commit comments