Skip to content

Instantly share code, notes, and snippets.

@dpino
Created March 14, 2019 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpino/f1d5d056d75728e7050f06e5e0423eaf to your computer and use it in GitHub Desktop.
Save dpino/f1d5d056d75728e7050f06e5e0423eaf to your computer and use it in GitHub Desktop.
Split LayoutTests in several jobs
#!/usr/bin/env bash
function usage {
echo "Usage: layout-tests-split [jobs] [webkit-dir]"
}
JOBS="${1:-1}"
WEBKIT_DIR="${2:-.}"
LAYOUT_TESTS_DIR="$WEBKIT_DIR/LayoutTests/"
if [[ ! -d "$LAYOUT_TESTS_DIR" ]]; then
echo "Couldn't find layout tests dir at '$LAYOUT_TESTS_DIR'"
exit 1
fi
OUT="$(mktemp)"
find ${LAYOUT_TESTS_DIR} -name "*.html" 1> $OUT
lines=$(wc -l $OUT | awk '{print $1}')
stride=$(expr $lines / $JOBS)
for i in `seq 1 $JOBS`; do
echo "layout-tests-$i"
until=$(expr $i \* $stride)
if [[ $i == $JOBS ]]; then
# On the last job, we get until the very end. Stride might be larger.
diff=$(expr $lines - $until)
until=$lines
stride=$(expr $stride + $diff)
fi
cat layout-tests | head -n $until | tail -n $stride > "layout-tests-$i"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment