Unverified Commit ad565c40 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

avoid running multiple test from the same directory in parallel (#29830)

parent e61068bf
......@@ -156,10 +156,6 @@ async function main() {
const groupParts = groupArg.split('/')
const groupPos = parseInt(groupParts[0], 10)
const groupTotal = parseInt(groupParts[1], 10)
const numPerGroup = Math.ceil(testNames.length / groupTotal)
let offset = groupPos === 1 ? 0 : (groupPos - 1) * numPerGroup - 1
// if there's an odd number of suites give the first group the extra
if (testNames.length % 2 !== 0 && groupPos !== 1) offset++
if (prevTimings) {
const groups = [[]]
......@@ -194,7 +190,9 @@ async function main() {
Math.round(groupTimes[curGroupIdx]) + 's'
)
} else {
testNames = testNames.splice(offset, numPerGroup)
const numPerGroup = Math.ceil(testNames.length / groupTotal)
let offset = (groupPos - 1) * numPerGroup
testNames = testNames.slice(offset, offset + numPerGroup)
}
}
......@@ -305,8 +303,15 @@ async function main() {
})
})
const directorySemas = new Map()
await Promise.all(
testNames.map(async (test) => {
const dirName = path.dirname(test)
let dirSema = directorySemas.get(dirName)
if (dirSema === undefined)
directorySemas.set(dirName, (dirSema = new Sema(1)))
await dirSema.acquire()
await sema.acquire()
let passed = false
......@@ -356,6 +361,7 @@ async function main() {
cleanUpAndExit(1)
}
sema.release()
dirSema.release()
})
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment