         }
 
         // Export the codecov data as JSON.
-        try exportCodeCovAsJSON(filename: buildPlan.graph.rootPackages[0].name, testBinary: testProduct.binary)
+        let jsonPath = codeCovAsJSONPath(
+            buildParameters: buildPlan.buildParameters,
+            packageName: buildPlan.graph.rootPackages[0].name)
+        try exportCodeCovAsJSON(to: jsonPath, testBinary: testProduct.binary)
     }
 
     /// Merges all profraw profiles in codecoverage directory into default.profdata file.

public enum TestMode {
    case version
    case listTests
    case generateLinuxMain
    case runSerial
    case runParallel

            testBinary.pathString
        ]
        let result = try Process.popen(arguments: args)
        try localFileSystem.writeFileContents(path, bytes: ByteString(result.output.dematerialize()))
    }

    /// Builds the "test" target if enabled in options.
