Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mason test not working when make install is used #26698

Merged
merged 2 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions tools/mason/MasonTest.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@


use ArgumentParser;
use ChplConfig;
use FileSystem;
use List;
use Map;
Expand Down Expand Up @@ -422,14 +421,16 @@ proc getTestPath(fullPath: string, testPath = "") : string {
proc getRuntimeComm() throws {
var line: string;
var python: string;
var findPython = spawn([CHPL_HOME:string+"/util/config/find-python.sh"],
stdout = pipeStyle.pipe);
var findPython = spawn(
[MasonUtils.CHPL_HOME:string+"/util/config/find-python.sh"],
stdout = pipeStyle.pipe);
while findPython.stdout.readLine(line) {
python = line.strip();
}

var checkComm = spawn([python, CHPL_HOME:string+"/util/chplenv/chpl_comm.py"],
stdout = pipeStyle.pipe);
var checkComm = spawn(
[python, MasonUtils.CHPL_HOME:string+"/util/chplenv/chpl_comm.py"],
stdout = pipeStyle.pipe);
while checkComm.stdout.readLine(line) {
comm = line.strip();
}
Expand Down
36 changes: 36 additions & 0 deletions tools/mason/MasonUtils.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

/* A helper file of utilities for Mason */
private use CTypes;
private use ChplConfig;
public use FileSystem;
private use List;
private use Map;
Expand Down Expand Up @@ -170,6 +171,41 @@ proc SPACK_ROOT : string {

return spackRoot;
}

/*
Returns the current CHPL_HOME. Tries the following in order:
1. The CHPL_HOME environment variable
2. Using the `chpl` in PATH to print CHPL_HOME
3. The CHPL_HOME of the chpl that built this mason (`ChplConfig.CHPL_HOME`)
*/
proc CHPL_HOME : string {

proc CHPL_HOME_inner() : string {
proc getChplHomeFromChpl(): string {
var chplHome = "";
try {
var process = spawn(["chpl", "--print-chpl-home"],
stdout=pipeStyle.pipe);
for line in process.stdout.lines() {
chplHome = line.strip();
}
} catch {
chplHome = "";
}
return chplHome;
}

const env = getEnv("CHPL_HOME");
const chplHome = if !env.isEmpty() then env else getChplHomeFromChpl();
return if !chplHome.isEmpty() then chplHome else ChplConfig.CHPL_HOME;
}

@functionStatic
ref chplHome = CHPL_HOME_inner();
return chplHome;
}


/*
This fetches the mason-installed spack registry only.
Users that define SPACK_ROOT to their own spack installation will use
Expand Down
1 change: 1 addition & 0 deletions util/packaging/apt/test/Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ WORKDIR /home/user/MyPackage
RUN chplcheck src/*.chpl
RUN mason build
RUN mason run -- -nl 1
RUN mkdir test && touch test/test.chpl mason test
WORKDIR /home/user
1 change: 1 addition & 0 deletions util/packaging/rpm/test/Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ WORKDIR /home/user/MyPackage
RUN chplcheck src/*.chpl
RUN mason build
RUN mason run -- -nl 1
RUN mkdir test && touch test/test.chpl mason test
WORKDIR /home/user