Skip to content

Commit

Permalink
[Tests] Fixes random test failures
Browse files Browse the repository at this point in the history
- The Stride.GameStudio.Tests must not run in parallel
- The Stride.Core.Assets.Tests could fail if the hard disk wouldn't react fast enough
  • Loading branch information
azeno committed Jan 28, 2024
1 parent 0cf6078 commit 7a7e15a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 10 additions & 3 deletions sources/assets/Stride.Core.Assets.Tests/TestFileVersionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Xunit;
using Stride.Core.IO;
using Stride.Core.Storage;
using System.Threading.Tasks;

namespace Stride.Core.Assets.Tests
{
Expand Down Expand Up @@ -43,7 +44,7 @@ public void Test()


[Fact]
public void TestAsync()
public async Task TestAsync()
{
var files = new List<UFile>();
for (int i = 0; i < 10; i++)
Expand All @@ -54,8 +55,14 @@ public void TestAsync()
}

var ids = new List<Tuple<UFile, ObjectId>>();
FileVersionManager.Instance.ComputeFileHashAsync(files, (file, id) => ids.Add(new Tuple<UFile, ObjectId>(file, id)));
Thread.Sleep(200);
var tcs = new TaskCompletionSource();
FileVersionManager.Instance.ComputeFileHashAsync(files, (file, id) =>
{
ids.Add(new Tuple<UFile, ObjectId>(file, id));
if (ids.Count == files.Count)
tcs.SetResult();
});
await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5));

Assert.Equal(files.Count, ids.Count);

Expand Down
6 changes: 6 additions & 0 deletions sources/editor/Stride.GameStudio.Tests/XunitAttributes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.

using Xunit;

[assembly: CollectionBehavior(DisableTestParallelization = true)]

0 comments on commit 7a7e15a

Please sign in to comment.