From f1ab289022cf38a9e8502f65e7760e71e9723403 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Fri, 23 Dec 2016 09:48:55 -0800 Subject: [PATCH] Run unit tests before building Unity package Summary: - Enable destructor unit tests in Unity Editor - Exit pack.sh immediately if a command exits with a non-zero status - Run unit tests before building Unity package Reviewed By: emilsjolander Differential Revision: D4365773 fbshipit-source-id: 20d0a51f4cef791154c17d329ac36598dc333a60 --- csharp/Unity/pack.sh | 13 ++++++++++++- csharp/tests/Facebook.Yoga/YogaNodeTest.cs | 2 -- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/csharp/Unity/pack.sh b/csharp/Unity/pack.sh index 402a9632..cc79ef0b 100755 --- a/csharp/Unity/pack.sh +++ b/csharp/Unity/pack.sh @@ -6,6 +6,8 @@ # LICENSE file in the root directory of this source tree. An additional grant # of patent rights can be found in the PATENTS file in the same directory. +set -e + cd "$( dirname "$0" )" if [ \! -f yoga.dll ]; then @@ -49,5 +51,14 @@ tests=Yoga/Assets/Facebook.Yoga/Editor/Facebook.Yoga.Tests mkdir -p $tests (cd ../tests/Facebook.Yoga; tar cf - *.cs)|tar -C $tests -xf - -Unity -quit -batchMode -projectPath `pwd`/Yoga -exportPackage Assets/Facebook.Yoga $libs `pwd`/yoga.unitypackage +function onerror { + local xml=Yoga/EditorTestResults.xml + if [ -f $xml ]; then cat $xml|grep 'success="False"'; fi +} +trap onerror EXIT +Unity -quit -batchMode -projectPath `pwd`/Yoga -runEditorTests +pkg="`pwd`/yoga.unitypackage" +Unity -quit -batchMode -projectPath `pwd`/Yoga -exportPackage Assets/Facebook.Yoga $libs $pkg + +echo "Success: $pkg" diff --git a/csharp/tests/Facebook.Yoga/YogaNodeTest.cs b/csharp/tests/Facebook.Yoga/YogaNodeTest.cs index 5cf1002b..7efd2a67 100644 --- a/csharp/tests/Facebook.Yoga/YogaNodeTest.cs +++ b/csharp/tests/Facebook.Yoga/YogaNodeTest.cs @@ -228,7 +228,6 @@ namespace Facebook.Yoga Assert.AreEqual(100, node0.MaxHeight); } -#if !UNITY_EDITOR private void ForceGC() { GC.Collect(GC.MaxGeneration); @@ -356,6 +355,5 @@ namespace Facebook.Yoga return MeasureOutput.Make(120, 130); }); } -#endif } }