2 # Update tests based on upstream repositories.
7 ignore_dirs='document interpreter test/harness'
15 bulk-memory-operations
27 echo "sub-command failed: $*"
38 pushd $1 >/dev/null || exit
42 popd >/dev/null || exit
48 if [ -d ${repo} ]; then
49 log_and_run git -C ${repo} fetch origin
50 log_and_run git -C ${repo} reset origin/master --hard
52 log_and_run git clone https://github.com/WebAssembly/${repo}
55 # Add upstream spec as "spec" remote.
56 if [ "${repo}" != "spec" ]; then
58 if ! git remote | grep spec >/dev/null; then
59 log_and_run git remote add spec https://github.com/WebAssembly/spec
62 log_and_run git fetch spec
71 [ "${repo}" == "spec" ] && return
74 # Create and checkout "try-merge" branch.
75 if ! git branch | grep try-merge >/dev/null; then
76 log_and_run git branch try-merge origin/master
78 log_and_run git checkout try-merge
80 # Attempt to merge with spec/master.
81 log_and_run git reset origin/master --hard
82 try_log_and_run git merge -q spec/master -m "merged"
84 # Ignore merge conflicts in non-test directories.
85 # We don't care about those changes.
86 try_log_and_run git checkout --ours ${ignore_dirs}
87 try_log_and_run git add ${ignore_dirs}
88 try_log_and_run git -c core.editor=true merge --continue
100 echo -e "Update repos\n" > commit_message
104 for repo in ${repos}; do
105 echo "++ updating ${repo}"
108 if ! merge_with_spec ${repo}; then
109 echo -e "!! error merging ${repo}, skipping\n"
110 failed_repos="${failed_repos} ${repo}"
114 if [ "${repo}" = "spec" ]; then
116 log_and_run cp $(find repos/${repo}/test/core -name \*.wast) ${wast_dir}
118 wast_dir=proposals/${repo}
121 # Don't add tests from proposal that are the same as spec.
122 pushdir repos/${repo}
123 for new in $(find test/core -name \*.wast); do
124 old=../../repos/spec/${new}
125 if [[ ! -f ${old} ]] || ! diff ${old} ${new} >/dev/null; then
126 log_and_run cp ${new} ../../${wast_dir}
132 # Check whether any files were removed.
133 for old in $(find ${wast_dir} -maxdepth 1 -name \*.wast); do
134 new=$(find repos/${repo}/test/core -name ${old##*/})
135 if [[ ! -f ${new} ]]; then
136 log_and_run git rm ${old}
140 # Check whether any files were updated.
141 if [ $(git status -s ${wast_dir} | wc -l) -ne 0 ]; then
142 log_and_run git add ${wast_dir}/*.wast
144 repo_sha=$(git -C repos/${repo} log --max-count=1 --oneline origin/master| sed -e 's/ .*//')
145 echo " ${repo}:" >> commit_message
146 echo " https://github.com/WebAssembly/${repo}/commit/${repo_sha}" >> commit_message
149 echo -e "-- ${repo}\n"
152 echo "" >> commit_message
153 echo "This change was automatically generated by \`update-testsuite.sh\`" >> commit_message
154 git commit -a -F commit_message
159 if [ -n "${failed_repos}" ]; then
160 echo "!! failed to update repos: ${failed_repos}"