Browse Source

Add script to generate a scene diff for a failed regression test (#384)

Lu Jiacheng 4 năm trước cách đây
mục cha
commit
0619f241ee
4 tập tin đã thay đổi với 49 bổ sung6 xóa
  1. 6 0
      .travis.yml
  2. 2 3
      Makefile
  3. 5 3
      README.md
  4. 36 0
      tests/update_scene_from_travis.sh

+ 6 - 0
.travis.yml

@@ -27,3 +27,9 @@ install:
 
 
 script:
 script:
     - make ${MAKE_OPTION} BLENDER=$BLENDER_BIN PYLINT='python3 -m pylint'
     - make ${MAKE_OPTION} BLENDER=$BLENDER_BIN PYLINT='python3 -m pylint'
+
+after_failure:
+    - make update-examples
+    - git diff HEAD > tests_scenes_diff.patch
+    - cat tests_scenes_diff.patch
+    - echo "scene diff path ends"

+ 2 - 3
Makefile

@@ -33,9 +33,8 @@ update-examples:
 	done;
 	done;
 
 
 compare: export-blends
 compare: export-blends
-	diff -x "*.escn.import" -r tests/godot_project/exports/ tests/reference_exports/
-
+	diff -x "*.escn.import" -rq tests/godot_project/exports/ tests/reference_exports/
 
 
 style-test: pep8 pylint
 style-test: pep8 pylint
 
 
-all: style-test compare
+all: compare style-test

+ 5 - 3
README.md

@@ -45,9 +45,11 @@ This repository includes a Makefile to assist with development. Running
 
 
 
 
 Current regression tests use the daily build of Blender 2.8 from Blender [official
 Current regression tests use the daily build of Blender 2.8 from Blender [official
-site](https://builder.blender.org/download/) and runs on ubuntu 16.04. If you run
-the tests with different Blender version or on different platforms, the output may
-slightly differ.
+site](https://builder.blender.org/download/) and runs on ubuntu 16.04. To fix the
+diff test failure:
+   -  You can run a `make export-blends` followed by a `make update-examples` and commit the changes made to the [reference_exports](tests/reference_exports). However, if you are running on a platform different than the one used by the TravisCI, there is a small chance that regression won't be passing because of float rounding. Then you might need to look at the TravisCI log and fix the remaining issue by hand.
+   - Or you can use the [update_scene_from_travis.sh](tests/update_scene_from_travis.sh) script, run it with the failing TravisCI job ID as the argument. The script will fetch the scene diffs from the Travis machine to your local git repository and apply it.
+
 
 
 
 
 ## License
 ## License

+ 36 - 0
tests/update_scene_from_travis.sh

@@ -0,0 +1,36 @@
+#!/bin/bash
+
+if [ -z "$1" ]
+  then
+    echo "Error: TravisCI job id is required."
+fi
+
+# These variable names should match the ones in .travis.yml
+PATCH_BEGIN_LINE='cat tests_scenes_diff.patch'
+PATCH_END_LINE='echo "scene diff path ends"'
+
+JOB_ID=$1
+RAW_LOG_URL=https://api.travis-ci.org/v3/job/${JOB_ID}/log.txt
+
+REPO_ROOT=$(dirname $0)/..
+
+cd $REPO_ROOT
+
+PWD=$(pwd)
+LOCAL_LOG_FILE=travis_${JOB_ID}_log.txt
+GIT_PATCH_FILE=${JOB_ID}_scene_diff.patch
+
+echo "Download travis build log from $RAW_LOG_URL"
+echo "Store to $PWD/$LOCAL_LOG_FILE"
+curl ${RAW_LOG_URL} --output $LOCAL_LOG_FILE
+
+BEGIN_LINE_NUMBER=$(awk "/${PATCH_BEGIN_LINE}/{ print NR; exit }" $LOCAL_LOG_FILE)
+END_LINE_NUMBER=$(awk "/${PATCH_END_LINE}/{ print NR; exit }" $LOCAL_LOG_FILE)
+sed -n "$((${BEGIN_LINE_NUMBER} + 1)),$((${END_LINE_NUMBER} - 1))p" $LOCAL_LOG_FILE > $GIT_PATCH_FILE
+
+git apply --verbose --ignore-whitespace --reject $GIT_PATCH_FILE 
+
+rm $LOCAL_LOG_FILE
+rm $GIT_PATCH_FILE
+
+cd -