mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:17:51 +08:00
Replace usage of TimeoutAttribute
to fix beatmap conversion test failures
This commit is contained in:
parent
f3e889d0f6
commit
f9713b8895
@ -14,7 +14,6 @@ using osu.Game.Tests.Beatmaps;
|
|||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
[Timeout(10000)]
|
|
||||||
public class CatchBeatmapConversionTest : BeatmapConversionTest<ConvertValue>
|
public class CatchBeatmapConversionTest : BeatmapConversionTest<ConvertValue>
|
||||||
{
|
{
|
||||||
protected override string ResourceAssembly => "osu.Game.Rulesets.Catch";
|
protected override string ResourceAssembly => "osu.Game.Rulesets.Catch";
|
||||||
|
@ -14,7 +14,6 @@ using osu.Game.Tests.Beatmaps;
|
|||||||
namespace osu.Game.Rulesets.Mania.Tests
|
namespace osu.Game.Rulesets.Mania.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
[Timeout(10000)]
|
|
||||||
public class ManiaBeatmapConversionTest : BeatmapConversionTest<ManiaConvertMapping, ConvertValue>
|
public class ManiaBeatmapConversionTest : BeatmapConversionTest<ManiaConvertMapping, ConvertValue>
|
||||||
{
|
{
|
||||||
protected override string ResourceAssembly => "osu.Game.Rulesets.Mania";
|
protected override string ResourceAssembly => "osu.Game.Rulesets.Mania";
|
||||||
|
@ -12,7 +12,6 @@ using osu.Game.Tests.Beatmaps;
|
|||||||
namespace osu.Game.Rulesets.Osu.Tests
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
[Timeout(10000)]
|
|
||||||
public class OsuBeatmapConversionTest : BeatmapConversionTest<ConvertValue>
|
public class OsuBeatmapConversionTest : BeatmapConversionTest<ConvertValue>
|
||||||
{
|
{
|
||||||
protected override string ResourceAssembly => "osu.Game.Rulesets.Osu";
|
protected override string ResourceAssembly => "osu.Game.Rulesets.Osu";
|
||||||
|
@ -12,7 +12,6 @@ using osu.Game.Tests.Beatmaps;
|
|||||||
namespace osu.Game.Rulesets.Taiko.Tests
|
namespace osu.Game.Rulesets.Taiko.Tests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
[Timeout(10000)]
|
|
||||||
public class TaikoBeatmapConversionTest : BeatmapConversionTest<ConvertValue>
|
public class TaikoBeatmapConversionTest : BeatmapConversionTest<ConvertValue>
|
||||||
{
|
{
|
||||||
protected override string ResourceAssembly => "osu.Game.Rulesets.Taiko";
|
protected override string ResourceAssembly => "osu.Game.Rulesets.Taiko";
|
||||||
|
@ -6,9 +6,11 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Audio.Track;
|
using osu.Framework.Audio.Track;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Extensions.ObjectExtensions;
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -108,37 +110,45 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
|
|
||||||
private ConvertResult convert(string name, Mod[] mods)
|
private ConvertResult convert(string name, Mod[] mods)
|
||||||
{
|
{
|
||||||
var beatmap = GetBeatmap(name);
|
var conversionTask = Task.Factory.StartNew(() =>
|
||||||
|
|
||||||
string beforeConversion = beatmap.Serialize();
|
|
||||||
|
|
||||||
var converterResult = new Dictionary<HitObject, IEnumerable<HitObject>>();
|
|
||||||
|
|
||||||
var working = new ConversionWorkingBeatmap(beatmap)
|
|
||||||
{
|
{
|
||||||
ConversionGenerated = (o, r, c) =>
|
var beatmap = GetBeatmap(name);
|
||||||
|
|
||||||
|
string beforeConversion = beatmap.Serialize();
|
||||||
|
|
||||||
|
var converterResult = new Dictionary<HitObject, IEnumerable<HitObject>>();
|
||||||
|
|
||||||
|
var working = new ConversionWorkingBeatmap(beatmap)
|
||||||
{
|
{
|
||||||
converterResult[o] = r;
|
ConversionGenerated = (o, r, c) =>
|
||||||
OnConversionGenerated(o, r, c);
|
{
|
||||||
}
|
converterResult[o] = r;
|
||||||
};
|
OnConversionGenerated(o, r, c);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
working.GetPlayableBeatmap(CreateRuleset().RulesetInfo, mods);
|
working.GetPlayableBeatmap(CreateRuleset().RulesetInfo, mods);
|
||||||
|
|
||||||
string afterConversion = beatmap.Serialize();
|
string afterConversion = beatmap.Serialize();
|
||||||
|
|
||||||
Assert.AreEqual(beforeConversion, afterConversion, "Conversion altered original beatmap");
|
Assert.AreEqual(beforeConversion, afterConversion, "Conversion altered original beatmap");
|
||||||
|
|
||||||
return new ConvertResult
|
return new ConvertResult
|
||||||
{
|
|
||||||
Mappings = converterResult.Select(r =>
|
|
||||||
{
|
{
|
||||||
var mapping = CreateConvertMapping(r.Key);
|
Mappings = converterResult.Select(r =>
|
||||||
mapping.StartTime = r.Key.StartTime;
|
{
|
||||||
mapping.Objects.AddRange(r.Value.SelectMany(CreateConvertValue));
|
var mapping = CreateConvertMapping(r.Key);
|
||||||
return mapping;
|
mapping.StartTime = r.Key.StartTime;
|
||||||
}).ToList()
|
mapping.Objects.AddRange(r.Value.SelectMany(CreateConvertValue));
|
||||||
};
|
return mapping;
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
}, TaskCreationOptions.LongRunning);
|
||||||
|
|
||||||
|
if (!conversionTask.Wait(10000))
|
||||||
|
Assert.Fail("Conversion timed out");
|
||||||
|
|
||||||
|
return conversionTask.WaitSafelyForResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnConversionGenerated(HitObject original, IEnumerable<HitObject> result, IBeatmapConverter beatmapConverter)
|
protected virtual void OnConversionGenerated(HitObject original, IEnumerable<HitObject> result, IBeatmapConverter beatmapConverter)
|
||||||
|
Loading…
Reference in New Issue
Block a user