mirror of
https://github.com/threeal/cmake-action.git
synced 2026-02-01 19:40:49 +00:00
fix: fix default build dir not relative to source dir (#269)
* test: fix get action inputs test when source dir specified * fix: default build dir should relative to source dir * ci: fix test directory location
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { jest } from "@jest/globals";
|
||||
import path from "node:path";
|
||||
import type { Inputs } from "./inputs.js";
|
||||
|
||||
jest.unstable_mockModule("@actions/core", () => ({
|
||||
@@ -23,13 +24,27 @@ describe("get action inputs", () => {
|
||||
{
|
||||
name: "with source directory specified",
|
||||
stringInputs: { "source-dir": "project" },
|
||||
expectedInputs: { sourceDir: "project" },
|
||||
expectedInputs: {
|
||||
sourceDir: "project",
|
||||
buildDir: path.join("project", "build"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "with build directory specified",
|
||||
stringInputs: { "build-dir": "output" },
|
||||
expectedInputs: { buildDir: "output" },
|
||||
},
|
||||
{
|
||||
name: "with source and build directories specified",
|
||||
stringInputs: {
|
||||
"source-dir": "project",
|
||||
"build-dir": "output",
|
||||
},
|
||||
expectedInputs: {
|
||||
sourceDir: "project",
|
||||
buildDir: "output",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "with generator specified",
|
||||
stringInputs: { generator: "Ninja" },
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { getBooleanInput, getInput, getMultilineInput } from "@actions/core";
|
||||
import path from "node:path";
|
||||
|
||||
export interface Inputs {
|
||||
sourceDir: string;
|
||||
@@ -15,9 +16,10 @@ export interface Inputs {
|
||||
}
|
||||
|
||||
export function getInputs(): Inputs {
|
||||
const sourceDir = getInput("source-dir") || ".";
|
||||
return {
|
||||
sourceDir: getInput("source-dir") || ".",
|
||||
buildDir: getInput("build-dir") || "build",
|
||||
sourceDir,
|
||||
buildDir: getInput("build-dir") || path.join(sourceDir, "build"),
|
||||
generator: getInput("generator"),
|
||||
cCompiler: getInput("c-compiler"),
|
||||
cxxCompiler: getInput("cxx-compiler"),
|
||||
|
||||
Reference in New Issue
Block a user