Skip to content

Commit

Permalink
test(node): Fix running Yarn2Test on Windows
Browse files Browse the repository at this point in the history
Account for the fact that on Windows `node` needs to be explicitly
mentioned as the interpreter.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Dec 12, 2024
1 parent 7b93abf commit 7e51acc
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import java.io.File
import org.ossreviewtoolkit.model.config.AnalyzerConfiguration
import org.ossreviewtoolkit.model.config.PackageManagerConfiguration
import org.ossreviewtoolkit.model.config.RepositoryConfiguration
import org.ossreviewtoolkit.utils.common.Os

class Yarn2Test : WordSpec({
"command" should {
Expand Down Expand Up @@ -121,15 +122,21 @@ class Yarn2Test : WordSpec({
*/
private fun checkExecutableFromYarnRc(workingDir: File, config: AnalyzerConfiguration = AnalyzerConfiguration()) {
val executable = "yarn-wrapper.js"

workingDir.resolve(".yarnrc.yml").writeText("yarnPath: $executable")

val executableFile = workingDir.resolve(executable).apply {
writeText("#!/usr/bin/env node\nconsole.log('yarn')")
}

val yarn = Yarn2("Yarn2", workingDir, config, RepositoryConfiguration())
val command = yarn.command(workingDir)

command shouldBe executableFile.absolutePath
if (Os.isWindows) {
command shouldBe "node ${executableFile.absolutePath}"
} else {
command shouldBe executableFile.absolutePath
}
}

/**
Expand Down

0 comments on commit 7e51acc

Please sign in to comment.