Skip to content

Shadergraph/first pass integration tests #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .yamato/upm-ci-shadergraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,7 @@ Build_{{ project.name }}_Win_{{ win_api.name }}_Player_{{ editor.version }}:
{{ project.name }}_Win_{{ win_api.name }}_{{ testplatform.name }}_{{ editor.version }}:
name : {{ project.name }} on Win_{{ win_api.name }}_{{ testplatform.name }} on version {{ editor.version }}
agent:
{% if testplatform.name == "editmode" %}
type: Unity::VM
{% else %}
type: Unity::VM::GPU
{% endif %}
image: {{ platform.image }}
flavor: {{ platform.flavor }}
variables:
Expand Down Expand Up @@ -273,9 +269,6 @@ Build_{{ project.name }}_OSX_OpenGLCore_Player_{{ editor.version }}:
{% elsif platform.name == "OSX_Metal" %}

{% for testplatform in testplatforms %}
{% if testplatform.name == "editmode" %}
#skip because we don't need a GPU to run editmode tests
{% else %}
{{ project.name }}_OSX_Metal_{{ testplatform.name }}_{{ editor.version }}:
name : {{ project.name }} on OSX_Metal_{{ testplatform.name }} on version {{ editor.version }}
agent:
Expand Down Expand Up @@ -314,7 +307,6 @@ Build_{{ project.name }}_OSX_OpenGLCore_Player_{{ editor.version }}:
logs:
paths:
- "**/test-results/**"
{% endif %}
{% endfor %}

{% elsif platform.name == "Linux" %}
Expand All @@ -325,11 +317,7 @@ Build_{{ project.name }}_OSX_OpenGLCore_Player_{{ editor.version }}:
{{ project.name }}_Linux_{{ linux_api.name }}_{{ testplatform.name }}_{{ editor.version }}:
name : {{ project.name }} on Linux_{{ linux_api.name }}_{{ testplatform.name }} on version {{ editor.version }}
agent:
{% if testplatform.name == "editmode" %}
type: Unity::VM
{% else %}
type: {{ platform.type }}
{% endif %}
image: {{ platform.image }}
flavor: {{ platform.flavor }}
variables:
Expand Down

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"UnityEditor.TestTools.Graphics",
"Unity.ShaderGraph.Editor",
"UnityEngine.TestRunner",
"UnityEditor.TestRunner"
"UnityEditor.TestRunner",
"Unity.Searcher.Editor",
"Unity.Searcher.ScriptsSamples"
],
"includePlatforms": [
"Editor"
Expand All @@ -20,4 +22,4 @@
"UNITY_INCLUDE_TESTS"
],
"versionDefines": []
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.Reflection;

namespace UnityEditor.ShaderGraph.UnitTests
{
public static class TestAssemblyExtensions
{
private const BindingFlags privateBindingFlags = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy;
public static void InvokePrivateAction(this object obj, string methodName, object[] parameters = null) => GetMethod(obj, methodName).Invoke(obj, parameters);
private static MethodInfo GetMethod(object obj, string methodName)
{
MethodInfo method = GetMethodRecursive(obj.GetType(), methodName);
if (method == null)
throw new System.Exception($"Unnable to find private method {methodName} in class {obj.GetType().ToString()}");
return method;
}
private static MethodInfo GetMethodRecursive(Type type, string methodName)
{
MethodInfo method = type.GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance);
if (method == null && type.BaseType != null)
return GetMethodRecursive(type.BaseType, methodName);
return method;
}
public static T InvokePrivateFunc<T>(this object obj, string methodName, object[] parameters = null)
{
object value = GetMethod(obj, methodName).Invoke(obj, parameters);
return TryConvertValueToType<T>(value, methodName);
}
private static T TryConvertValueToType<T>(object input, string name)
{
T output = default;
try { output = (T)input; }
catch { throw new System.ArgumentException($"Unnable to convert {name} to type of {output.GetType().ToString()}"); }
return output;
}

public static void SetPrivateField(this object obj, string fieldName, object value)
{
FieldInfo fieldInfo = GetField(obj, fieldName, privateBindingFlags);
fieldInfo.SetValue(obj, value);
}
public static T GetPrivateField<T>(this object obj, string fieldName)
{
object value = GetField(obj, fieldName, privateBindingFlags).GetValue(obj);
return TryConvertValueToType<T>(value, fieldName);
}
private static FieldInfo GetField(object obj, string fieldName, BindingFlags bindingFlags)
{
FieldInfo field = obj.GetType().GetField(fieldName, bindingFlags);
if (field == null)
throw new System.Exception($"Unnable to find field {fieldName} in class {obj.GetType().ToString()} with binding flags {bindingFlags}");
return field;
}

public static T GetPrivateProperty<T>(this object obj, string propertyName)
{
object value = GetProperty(obj, propertyName, privateBindingFlags).GetValue(obj);
return TryConvertValueToType<T>(value, propertyName);
}

private static PropertyInfo GetProperty(object obj, string propertyName, BindingFlags bindingFlags)
{
PropertyInfo property = obj.GetType().GetProperty(propertyName, bindingFlags);
if(property == null)
throw new System.Exception($"Unnable to find private property {propertyName} in class {obj.GetType().ToString()} with binding flags {bindingFlags}");
return property;
}

}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading