Skip to content

Commit 21fc624

Browse files
PaulDemeulenaereEvergreen
authored andcommitted
[VFX] Add Template Validation Test
Add minimal coverage about not up to date template.
1 parent e71c6aa commit 21fc624

File tree

1 file changed

+68
-1
lines changed
  • Tests/SRPTests/Packages/com.unity.testing.visualeffectgraph/Tests/Editor

1 file changed

+68
-1
lines changed

Tests/SRPTests/Packages/com.unity.testing.visualeffectgraph/Tests/Editor/VFXSanitizeTest.cs

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
using System.Collections;
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Text;
25
using NUnit.Framework;
6+
using UnityEngine;
37
using UnityEngine.TestTools;
8+
using UnityEngine.VFX;
49

510
namespace UnityEditor.VFX.Test
611
{
@@ -23,5 +28,67 @@ public IEnumerator Check_SetCustomAttribute_Sanitize()
2328
yield return null;
2429
Assert.IsNotNull(graph);
2530
}
31+
32+
[UnityTest,
33+
#if VFX_TESTS_HAS_URP
34+
Ignore("See UUM-66527")
35+
#endif
36+
]
37+
public IEnumerator Insure_Templates_Are_Up_To_Date()
38+
{
39+
var allTemplatesGUI = AssetDatabase.FindAssets("t:VisualEffectAsset", new []{ "Packages/com.unity.visualeffectgraph" });
40+
var templatePath = new List<string>();
41+
foreach (var guid in allTemplatesGUI)
42+
{
43+
var currentPath = AssetDatabase.GUIDToAssetPath(guid);
44+
AssetDatabase.ImportAsset(currentPath);
45+
46+
var asset = AssetDatabase.LoadAssetAtPath<VisualEffectAsset>(currentPath);
47+
Assert.IsNotNull(asset);
48+
49+
var resource = asset.GetResource();
50+
EditorUtility.SetDirty(resource);
51+
AssetDatabase.ImportAsset(currentPath);
52+
53+
templatePath.Add(currentPath);
54+
}
55+
AssetDatabase.SaveAssets();
56+
Assert.AreNotEqual(0, templatePath.Count);
57+
yield return null;
58+
59+
using (var process = new System.Diagnostics.Process())
60+
{
61+
var rootPath = Path.Combine(Application.dataPath, "../../../../../");
62+
process.StartInfo = new System.Diagnostics.ProcessStartInfo
63+
{
64+
CreateNoWindow = true,
65+
UseShellExecute = false,
66+
RedirectStandardError = true,
67+
RedirectStandardOutput = true,
68+
FileName = "git",
69+
Arguments = "diff Packages/com.unity.visualeffectgraph/**",
70+
WorkingDirectory = rootPath
71+
};
72+
73+
var outputBuilder = new StringBuilder();
74+
var errorsBuilder = new StringBuilder();
75+
process.OutputDataReceived += (_, args) => outputBuilder.AppendLine(args.Data);
76+
process.ErrorDataReceived += (_, args) => errorsBuilder.AppendLine(args.Data);
77+
78+
process.Start();
79+
process.BeginOutputReadLine();
80+
process.BeginErrorReadLine();
81+
process.WaitForExit();
82+
83+
var output = outputBuilder.ToString().TrimEnd();
84+
var errors = errorsBuilder.ToString().TrimEnd();
85+
86+
Assert.AreEqual(0, process.ExitCode);
87+
Assert.AreEqual(string.Empty, errors);
88+
Assert.AreEqual(string.Empty, output, output);
89+
}
90+
yield return null;
91+
}
92+
2693
}
2794
}

0 commit comments

Comments
 (0)