Skip to content

Commit

Permalink
try to run skipped tests when test name matches filter value exactly (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSiefke authored Dec 1, 2023
1 parent 3968871 commit ef301a8
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ export const runTests = async (
for (let i = 0; i < formattedPaths.length; i++) {
const formattedPath = formattedPaths[i]
const { absolutePath, relativeDirname, dirent, relativePath } = formattedPath
const forceRun = dirent === `${filterValue}.js`
if (i !== 0) {
callback(TestWorkerEventType.TestRunning, absolutePath, relativeDirname, dirent, /* isFirst */ true)
}
try {
const start = i === 0 ? initialStart : Time.now()
const testSkipped = await TestWorkerSetupTest.testWorkerSetupTest(testWorkerIpc, connectionId, formattedPath.absolutePath)
const testSkipped = await TestWorkerSetupTest.testWorkerSetupTest(testWorkerIpc, connectionId, formattedPath.absolutePath, forceRun)
if (testSkipped) {
skipped++
const end = Time.now()
Expand All @@ -82,12 +83,12 @@ export const runTests = async (
if (checkLeaks) {
if (measureAfter) {
for (let i = 0; i < 2; i++) {
await TestWorkerRunTest.testWorkerRunTest(testWorkerIpc, connectionId, formattedPath.absolutePath, root, color)
await TestWorkerRunTest.testWorkerRunTest(testWorkerIpc, connectionId, formattedPath.absolutePath, forceRun)
}
}
const before = await MemoryLeakFinder.start(memoryLeakWorkerIpc, connectionId)
for (let i = 0; i < runs; i++) {
await TestWorkerRunTest.testWorkerRunTest(testWorkerIpc, connectionId, formattedPath.absolutePath, root, color)
await TestWorkerRunTest.testWorkerRunTest(testWorkerIpc, connectionId, formattedPath.absolutePath, forceRun)
}
const after = await MemoryLeakFinder.stop(memoryLeakWorkerIpc, connectionId)
const result = await MemoryLeakFinder.compare(memoryLeakWorkerIpc, connectionId, before, after)
Expand All @@ -105,7 +106,7 @@ export const runTests = async (
}
} else {
for (let i = 0; i < runs; i++) {
await TestWorkerRunTest.testWorkerRunTest(testWorkerIpc, connectionId, formattedPath.absolutePath, root, color)
await TestWorkerRunTest.testWorkerRunTest(testWorkerIpc, connectionId, formattedPath.absolutePath, forceRun)
}
}
const end = Time.now()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import * as Assert from '../Assert/Assert.js'
import * as JsonRpc from '../JsonRpc/JsonRpc.js'
import * as TestWorkerCommandType from '../TestWorkerCommandType/TestWorkerCommandType.js'

export const testWorkerRunTest = (ipc, connectionId, absolutePath, root, color) => {
export const testWorkerRunTest = (ipc, connectionId, absolutePath, forceRun) => {
Assert.object(ipc)
Assert.string(absolutePath)
Assert.string(root)
Assert.boolean(color)
return JsonRpc.invoke(ipc, TestWorkerCommandType.RunTest, connectionId, absolutePath, root, color)
Assert.boolean(forceRun)
return JsonRpc.invoke(ipc, TestWorkerCommandType.RunTest, connectionId, absolutePath, forceRun)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as Assert from '../Assert/Assert.js'
import * as JsonRpc from '../JsonRpc/JsonRpc.js'
import * as TestWorkerCommandType from '../TestWorkerCommandType/TestWorkerCommandType.js'

export const testWorkerSetupTest = (ipc, connectionId, absolutePath) => {
export const testWorkerSetupTest = (ipc, connectionId, absolutePath, forceRun) => {
Assert.object(ipc)
Assert.string(absolutePath)
return JsonRpc.invoke(ipc, TestWorkerCommandType.SetupTest, connectionId, absolutePath)
return JsonRpc.invoke(ipc, TestWorkerCommandType.SetupTest, connectionId, absolutePath, forceRun)
}
4 changes: 2 additions & 2 deletions packages/test-worker-commands/src/parts/RunTest/RunTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import * as Assert from '../Assert/Assert.js'
import * as PageObjectState from '../PageObjectState/PageObjectState.js'
import * as RunTestWithCallback from '../RunTestWithCallback/RunTestWithCallback.js'

export const runTest = async (connectionId, absolutePath) => {
export const runTest = async (connectionId, absolutePath, forceRun) => {
Assert.number(connectionId)
Assert.string(absolutePath)
const pageObject = PageObjectState.getPageObject(connectionId)
const skipped = await RunTestWithCallback.runTestWithCallback(pageObject, absolutePath)
const skipped = await RunTestWithCallback.runTestWithCallback(pageObject, absolutePath, forceRun)
return skipped
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as ImportTest from '../ImportTest/ImportTest.js'
import * as TestStage from '../TestStage/TestStage.js'

export const runTestWithCallback = async (pageObject, file) => {
export const runTestWithCallback = async (pageObject, file, forceRun) => {
const module = await ImportTest.importTest(file)
if (module.skip) {
if (module.skip && !forceRun) {
return true
}
await TestStage.run(module, pageObject)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import * as Assert from '../Assert/Assert.js'
import * as PageObjectState from '../PageObjectState/PageObjectState.js'
import * as SetupTestWithCallback from '../SetupTestWithCallback/SetupTestWithCallback.js'

export const setupTest = async (connectionId, absolutePath) => {
export const setupTest = async (connectionId, absolutePath, forceRun) => {
Assert.number(connectionId)
Assert.string(absolutePath)
Assert.boolean(forceRun)
const pageObject = PageObjectState.getPageObject(connectionId)
const skipped = await SetupTestWithCallback.setupTestWithCallback(pageObject, absolutePath)
const skipped = await SetupTestWithCallback.setupTestWithCallback(pageObject, absolutePath, forceRun)
return skipped
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import * as ImportTest from '../ImportTest/ImportTest.js'
import * as TestStage from '../TestStage/TestStage.js'
import * as Assert from '../Assert/Assert.js'

export const setupTestWithCallback = async (pageObject, file) => {
export const setupTestWithCallback = async (pageObject, file, forceRun) => {
Assert.object(pageObject)
Assert.string(file)
Assert.boolean(forceRun)
const module = await ImportTest.importTest(file)
if (module.skip) {
if (module.skip && !forceRun) {
return true
}
await TestStage.beforeSetup(module, pageObject)
Expand Down

0 comments on commit ef301a8

Please sign in to comment.