Skip to content

Commit

Permalink
fix: xArgs command update (#2095)
Browse files Browse the repository at this point in the history
Fixes #1538 

A small update to use a default option instead of failing straight out if the maxArgs is reached.

## Checklist
- [x] Integration tests updated
  • Loading branch information
Sloox authored Jul 22, 2021
1 parent 156910c commit 7911f3f
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ internal fun parseSwiftTests(binary: String): List<String> {
// getconf ARG_MAX
// Windows has different limits
val argMax = if (isWindows) 250_36 else 262_144

val xargsOption = binary.quote().determineXArgsCommand(argMax)
val cmd = when {
isMacOS -> "nm -gU ${binary.quote()} | xargs -s $argMax xcrun swift-demangle"
isLinux -> "export LD_LIBRARY_PATH=~/.flank; export PATH=~/.flank:\$PATH; nm -gU ${binary.quote()} | xargs -s $argMax swift-demangle"
isWindows -> "llvm-nm.exe -gU ${binary.quote().replace("\\", "/")} | xargs.exe -s $argMax swift-demangle.exe"
isMacOS -> "nm -gU ${binary.quote()} | xargs $xargsOption xcrun swift-demangle"
isLinux -> "export LD_LIBRARY_PATH=~/.flank; export PATH=~/.flank:\$PATH; nm -gU ${binary.quote()} | xargs $xargsOption swift-demangle"
isWindows -> "llvm-nm.exe -gU ${binary.quote().replace("\\", "/")} | xargs.exe $xargsOption swift-demangle.exe"
else -> throw RuntimeException("Unsupported OS for Integration Tests")
}

Expand All @@ -45,3 +45,10 @@ internal fun parseSwiftTests(binary: String): List<String> {
}
return results.distinct()
}

private fun String.determineXArgsCommand(argsMax: Int) = if (this.length > argsMax) {
println("WARNING: The amount of characters has exceeded the OS threshold for xArgs. -n1 will be used to ensure the command completes successfully. It may increase completion time substantially.")
"-n1"
} else {
"-s $argsMax"
}

0 comments on commit 7911f3f

Please sign in to comment.