Skip to content

Commit

Permalink
fixed utest 2.x filter support
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexHaxe committed Feb 12, 2024
1 parent 6b57871 commit f6bc0bf
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion test-adapter/_testadapter/utest/Injector.hx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,38 @@ class Injector {
switch (field.name) {
case "new":
field.addInit(macro new _testadapter.utest.Reporter(this, $v{Sys.getCwd()}));
case "addITest":
#if (utest >= version("2.0.0-alpha"))
case "addCase": // utest 2.x support
field.patch(Replace, macro {
var className = Type.getClassName(Type.getClass(testCase));
if (fixtures.exists(className)) {
throw new UTestException('Cannot add the same test twice.');
}
var newFixtures = [];
var init:utest.TestData.InitializeUtest = (cast testCase : utest.TestData.Initializer).__initializeUtest__();
var cls:_testadapter.data.Data.SuiteId = ClassName(className);
for (test in init.tests) {
if (!isTestFixtureName(className, test.name, ['test', 'spec'], pattern, globalPattern)) {
continue;
}
if (!_testadapter.data.TestFilter.shouldRunTest($v{Macro.filters}, cls, test.name)) {
continue;
}
newFixtures.push(new utest.TestFixture(testCase, test, init.accessories));
}
if (newFixtures.length > 0) {
fixtures.set(className, {
caseInstance: testCase,
setupClass: init.accessories.getSetupClass(),
dependencies: #if UTEST_IGNORE_DEPENDS [] #else init.dependencies #end,
fixtures: newFixtures,
teardownClass: init.accessories.getTeardownClass()
});
length += newFixtures.length;
}
});
#else
case "addITest": // utest 1.x support
field.patch(Replace, macro {
var className = Type.getClassName(Type.getClass(testCase));
if (iTestFixtures.exists(className)) {
Expand Down Expand Up @@ -44,6 +75,7 @@ class Injector {
teardownClass: init.accessories.getTeardownClass()
});
});
#end
}
}
return fields;
Expand Down

0 comments on commit f6bc0bf

Please sign in to comment.