-
Notifications
You must be signed in to change notification settings - Fork 68
Added support for specifying an extracted type tree data file #60
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
32925ab
Added support for specifying an extracted type tree data file
paulb-unity 189a4c4
updated docs & tests
paulb-unity 7279c8c
Update UnityDataTool/Program.cs
paulb-unity dcb8f3f
updated test to check contents of file
paulb-unity 2e42c9f
Merge branch 'typetree-extraction-support' of https://github.com/Unit…
paulb-unity fdbb7d5
updated all dlls to 6000.5.0
paulb-unity a9d8e02
Add mention of the new typetree extraction feature in unity-content-f…
SkowronskiAndrew 0354272
Bump version to 1.3.3
SkowronskiAndrew b5e6ad3
Make new test more precise in expected file
SkowronskiAndrew 0a0c020
Documentation and same files related to TypeTrees
SkowronskiAndrew File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| using System; | ||
| using System.IO; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.Data.Sqlite; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace UnityDataTools.UnityDataTool.Tests; | ||
|
|
||
| #pragma warning disable NUnit2005, NUnit2006 | ||
|
|
||
| public class ExtractedTypeTreeTests | ||
| { | ||
| private string m_TestOutputFolder; | ||
| private string m_DataFolder; | ||
| private string m_SerializedFile; | ||
| private string m_TypeTreeDataFile; | ||
|
|
||
| [OneTimeSetUp] | ||
| public void OneTimeSetup() | ||
| { | ||
| m_TestOutputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, "test_folder_typetree"); | ||
| Directory.CreateDirectory(m_TestOutputFolder); | ||
|
|
||
| m_DataFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "ExtractedTypeTree"); | ||
| m_SerializedFile = Path.Combine(m_DataFolder, "sfwithextractedtypetrees1"); | ||
| m_TypeTreeDataFile = Path.Combine(m_DataFolder, "sfwithextractedtypetrees1.typetreedata"); | ||
| } | ||
|
|
||
| [SetUp] | ||
| public void Setup() | ||
| { | ||
| Directory.SetCurrentDirectory(m_TestOutputFolder); | ||
| } | ||
|
|
||
| [TearDown] | ||
| public void Teardown() | ||
| { | ||
| SqliteConnection.ClearAllPools(); | ||
|
|
||
| foreach (var file in new DirectoryInfo(m_TestOutputFolder).EnumerateFiles()) | ||
| { | ||
| file.Delete(); | ||
| } | ||
|
|
||
| foreach (var dir in new DirectoryInfo(m_TestOutputFolder).EnumerateDirectories()) | ||
| { | ||
| dir.Delete(true); | ||
| } | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task Analyze_WithTypeTreeData_DatabaseCorrect( | ||
| [Values("-d", "--typetree-data")] string option) | ||
| { | ||
| var databasePath = SQLTestHelper.GetDatabasePath(m_TestOutputFolder); | ||
|
|
||
| Assert.AreEqual(0, await Program.Main(new string[] { "analyze", m_DataFolder, option, m_TypeTreeDataFile })); | ||
|
|
||
| using var db = SQLTestHelper.OpenDatabase(databasePath); | ||
|
|
||
| var objectCount = SQLTestHelper.QueryInt(db, "SELECT COUNT(*) FROM objects"); | ||
| Assert.Greater(objectCount, 0, "Expected objects in database when TypeTree data file is provided"); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task Analyze_WithoutTypeTreeData_ReportsFailure() | ||
| { | ||
| var databasePath = SQLTestHelper.GetDatabasePath(m_TestOutputFolder); | ||
|
|
||
| using var swOut = new StringWriter(); | ||
| using var swErr = new StringWriter(); | ||
| var currentOut = Console.Out; | ||
| var currentErr = Console.Error; | ||
| try | ||
| { | ||
| Console.SetOut(swOut); | ||
| Console.SetError(swErr); | ||
|
|
||
| await Program.Main(new string[] { "analyze", m_DataFolder }); | ||
|
|
||
| var output = swOut.ToString() + swErr.ToString(); | ||
|
|
||
| Assert.That(output, Does.Contain("Failed files: 1"), | ||
| "Expected failure when analyzing without TypeTree data file"); | ||
| } | ||
| finally | ||
| { | ||
| Console.SetOut(currentOut); | ||
| Console.SetError(currentErr); | ||
| } | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task Dump_WithTypeTreeData_Succeeds( | ||
| [Values("-d", "--typetree-data")] string option) | ||
| { | ||
| Assert.AreEqual(0, await Program.Main(new string[] { "dump", m_SerializedFile, option, m_TypeTreeDataFile })); | ||
|
|
||
| var outputFiles = Directory.GetFiles(m_TestOutputFolder, "*.txt"); | ||
| Assert.IsNotEmpty(outputFiles, "Expected dump output files when TypeTree data file is provided"); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task Dump_WithoutTypeTreeData_Fails() | ||
| { | ||
| Assert.AreNotEqual(0, await Program.Main(new string[] { "dump", m_SerializedFile })); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task TypeTreeData_FileNotFound_ReturnsError() | ||
| { | ||
| var result = await Program.Main(new string[] { "analyze", m_DataFolder, "--typetree-data", "nonexistent_file.bin" }); | ||
| Assert.AreNotEqual(0, result, "Expected non-zero return code when TypeTree data file does not exist"); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.