1#!/bin/bash
2
3set -ex
4
5REMOTE=${1:-https://github.com/web-platform-tests/wpt}
6REF=${2:-master}
7
8cd ~
9
10if [ -e /dev/kvm ]; then
11    # If kvm is present ensure that the test user can access it
12    # Ideally this could be done by adding the test user to the
13    # owning group, but then we need to re-login to evaluate the
14    # group membership. This chmod doesn't affect the host.
15    sudo chmod a+rw /dev/kvm
16fi
17
18if [ ! -d web-platform-tests ]; then
19    mkdir web-platform-tests
20    cd web-platform-tests
21
22    git init
23    git remote add origin ${REMOTE}
24
25    # Initially we just fetch 50 commits in order to save several minutes of fetching
26    retry git fetch --quiet --depth=50 --tags origin ${REF}:task_head
27
28    git checkout --quiet task_head
29fi
30