mirror of
https://github.com/copyrighttxt/watrbx-game-engine.git
synced 2026-09-06 05:37:48 +00:00
GEEKING
This commit is contained in:
@@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using RobloxLib;
|
||||
|
||||
namespace RegressionTestSuite
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Starting Regression Testing App");
|
||||
// create a writer and open the file
|
||||
TextWriter tw = new StreamWriter("Results.txt");
|
||||
|
||||
// write a line of text to the file
|
||||
tw.WriteLine("Simulation Testing Results " + System.DateTime.Now);
|
||||
tw.WriteLine("***************************************************");
|
||||
tw.WriteLine();
|
||||
|
||||
|
||||
string[] filePaths = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.rbxl",
|
||||
SearchOption.AllDirectories);
|
||||
|
||||
var app = new RobloxLib.AppClass();
|
||||
|
||||
int numTests = filePaths.Length;
|
||||
int numRepeats = 10; // Run each file this many times
|
||||
int numFailures = 0;
|
||||
int numNotSetUp = 0;
|
||||
|
||||
Stopwatch sw = new Stopwatch();
|
||||
Stopwatch fullSW = new Stopwatch();
|
||||
fullSW.Reset();
|
||||
fullSW.Start();
|
||||
|
||||
for (int i = 0; i < numTests; i++)
|
||||
{
|
||||
double actualSimTime = 0.0;
|
||||
long testClockDelta = 0;
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(filePaths[i]);
|
||||
tw.WriteLine();
|
||||
tw.WriteLine(filePaths[i]);
|
||||
|
||||
string testFilePath = filePaths[i].Replace("\\", "\\\\");
|
||||
|
||||
for (int j = 0; j < numRepeats; j++)
|
||||
{
|
||||
var w = app.CreateGame("44340105256");
|
||||
w.ExecScript("game:load('" + testFilePath + "')", null, null, null, null);
|
||||
|
||||
// If no stop time IntValue then run for 10 seconds
|
||||
int runTime = 10;
|
||||
var stopTimeExists = w.ExecScript("return game.Workspace:FindFirstChild(\"StopTime\") ~= nil", null, null, null, null);
|
||||
if (Convert.ToBoolean(stopTimeExists[0]))
|
||||
{
|
||||
var res = w.ExecScript("return Workspace.StopTime.Value", null, null, null, null);
|
||||
|
||||
if (res.Length > 0)
|
||||
runTime = Convert.ToInt16(res[0]);
|
||||
}
|
||||
|
||||
sw.Reset();
|
||||
sw.Start();
|
||||
w.ExecScript("game:GetService(\"RunService\"):Run()", null, null, null, null);
|
||||
System.Threading.Thread.Sleep(runTime * 1000 + 1000);
|
||||
w.ExecScript("game:GetService(\"RunService\"):Pause()", null, null, null, null);
|
||||
sw.Stop();
|
||||
testClockDelta += sw.ElapsedMilliseconds;
|
||||
|
||||
// Test success conditions
|
||||
var resultExists = w.ExecScript("return game.Workspace:FindFirstChild(\"Result\") ~= nil", null, null, null, null);
|
||||
var resultActualSimTime = w.ExecScript("return time()", null, null, null, null);
|
||||
actualSimTime += Convert.ToDouble(resultActualSimTime[0]);
|
||||
|
||||
// Intermediate results
|
||||
tw.WriteLine(Convert.ToDouble(resultActualSimTime[0]) + " " + sw.ElapsedMilliseconds / 1000.0);
|
||||
/*
|
||||
if (Convert.ToBoolean(resultExists[0]))
|
||||
{
|
||||
var testResult1 = w.ExecScript("return Workspace.Result.Value", null, null, null, null);
|
||||
{
|
||||
if (Convert.ToInt16(testResult1[0]) == 1)
|
||||
tw.WriteLine("Test Passed");
|
||||
else if (Convert.ToInt16(testResult1[0]) == -1)
|
||||
{
|
||||
numFailures++;
|
||||
tw.WriteLine("Test FAILED ********");
|
||||
}
|
||||
else
|
||||
{
|
||||
numFailures++;
|
||||
tw.WriteLine("The test was not executed properly (i.e. Parts went out of scope.)");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
numNotSetUp++;
|
||||
tw.WriteLine("This file is not set up as a regression test.");
|
||||
}
|
||||
*/
|
||||
|
||||
w.Close();
|
||||
}
|
||||
tw.WriteLine("Sim Run Time = " + actualSimTime / numRepeats);
|
||||
tw.WriteLine("Stopwatch = " + (testClockDelta / 1000.0) / numRepeats);
|
||||
tw.WriteLine("Simulation Time -to- Real Time Ratio = " + actualSimTime /(testClockDelta / 1000.0));
|
||||
tw.WriteLine();
|
||||
}
|
||||
fullSW.Stop();
|
||||
tw.WriteLine();
|
||||
tw.WriteLine();
|
||||
tw.WriteLine();
|
||||
tw.WriteLine("***************");
|
||||
tw.WriteLine("Results Summary");
|
||||
tw.WriteLine("Simulation Repeats: " + numRepeats);
|
||||
tw.WriteLine("Cumulative Test Time: " + fullSW.ElapsedMilliseconds / 1000.0);
|
||||
tw.WriteLine("Number of Tests Executed: " + numTests);
|
||||
tw.WriteLine("Number of Successes: " + (numTests - numFailures - numNotSetUp));
|
||||
tw.WriteLine("Number Failing: " + numFailures);
|
||||
tw.WriteLine("Number Not Configured: " + numNotSetUp);
|
||||
Console.WriteLine("Done Testing");
|
||||
|
||||
//if (numTests - numNotSetUp > 0)
|
||||
// Console.WriteLine("Success Rate: " + 100 * (numTests - numFailures - numNotSetUp) / (numTests - numNotSetUp) + "%");
|
||||
//else
|
||||
// Console.WriteLine("Success Rate: No tests were configured for regression.");
|
||||
|
||||
// close the stream
|
||||
tw.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("RegressionTestSuite")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("RegressionTestSuite")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("428dd2b1-97bd-4b2a-9b31-57c8e6a171cc")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{0A571D05-63E3-43F1-B8C3-1F688E008EB4}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>RegressionTestSuite</RootNamespace>
|
||||
<AssemblyName>RegressionTestSuite</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="RobloxLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\Roblox_Code\Trunk\Client\Roblox\RobloxLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Service References\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="RobloxLib.dll" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
Reference in New Issue
Block a user