From ba4d3fbb55a1fd1d53514fe455c669eab2a0f794 Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Tue, 16 Dec 2025 12:45:13 -0800 Subject: [PATCH 01/19] add chplcheck linting to mason Signed-off-by: Jade Abraham --- .github/workflows/CI.yml | 3 +++ Makefile.devel | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9fdfd10f81e3..a775288685c2 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -104,6 +104,9 @@ jobs: - name: lint standard modules run: | CHPL_HOME=$PWD make DYNO_ENABLE_ASSERTIONS=1 lint-standard-modules -j`util/buildRelease/chpl-make-cpu_count` + - name: lint mason + run: | + CHPL_HOME=$PWD make DYNO_ENABLE_ASSERTIONS=1 lint-mason -j`util/buildRelease/chpl-make-cpu_count` make_check_llvm_none: runs-on: ubuntu-latest diff --git a/Makefile.devel b/Makefile.devel index b6d213187270..ce2b3d6c0a75 100644 --- a/Makefile.devel +++ b/Makefile.devel @@ -107,6 +107,10 @@ lint-standard-modules: chplcheck FORCE --disable-rule LineLength \ $(MODULES_TO_LINT) +MASON_MODULES_TO_LINT = $(shell find $(CHPL_MAKE_HOME)/tools/mason -name '*.chpl') +lint-mason: chplcheck FORCE + tools/chplcheck/chplcheck $(MASON_MODULES_TO_LINT) + run-frontend-linters: FORCE @cd compiler && $(MAKE) run-frontend-linters From 5642916d0ba2cb931b93130d2566a110953cd6cd Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 9 Jan 2026 16:26:09 -0800 Subject: [PATCH 02/19] resolve a few lints Signed-off-by: Jade Abraham --- tools/mason/MasonEnv.chpl | 23 +++++++----- tools/mason/MasonHelp.chpl | 71 +++++++++++++++++++----------------- tools/mason/MasonSystem.chpl | 23 ++++++++---- 3 files changed, 68 insertions(+), 49 deletions(-) diff --git a/tools/mason/MasonEnv.chpl b/tools/mason/MasonEnv.chpl index ee145d9860f8..38c7b445006a 100644 --- a/tools/mason/MasonEnv.chpl +++ b/tools/mason/MasonEnv.chpl @@ -32,9 +32,10 @@ proc MASON_HOME : string { return masonHome; } -/* Returns an array of directory strings corresponding to MASON_HOME/name for - each name in MASON_REGISTRY. - */ +/* + Returns an array of directory strings corresponding to MASON_HOME/name for + each name in MASON_REGISTRY. +*/ proc MASON_CACHED_REGISTRY { const masonRegistry = MASON_REGISTRY; const masonHome = MASON_HOME; @@ -45,14 +46,17 @@ proc MASON_CACHED_REGISTRY { return cachedRegistry; } -/* Returns value of MASON_OFFLINE, environment variable that disales online access. - */ +/* + Returns value of MASON_OFFLINE, environment variable that + disables online access. +*/ proc MASON_OFFLINE { const offlineEnv = getEnv('MASON_OFFLINE'); const default = false; var offline = false; - if (offlineEnv == 'true') || (offlineEnv == 'True') || (offlineEnv == 'TRUE') || (offlineEnv == '1') { + if (offlineEnv == 'true') || (offlineEnv == 'True') || + (offlineEnv == 'TRUE') || (offlineEnv == '1') { offline = true; } else offline = default; @@ -100,9 +104,10 @@ proc MASON_REGISTRY throws { for i in registries.indices { for j in i+1.. [...]'); - writeln(' mason [options]'); - writeln(); - writeln('Options:'); - writeln(' -h, --help Display this message'); - writeln(' -V, --version Print version info and exit'); - writeln(' --no-color Do not format text printed on console'); - writeln(); - writeln('Mason commands:'); - writeln(' new Create a new mason project'); - writeln(' init Initialize a mason project inside an existing directory'); - writeln(' add Add a dependency to Mason.toml'); - writeln(' rm Remove a dependency from Mason.toml'); - writeln(' update Update/Generate Mason.lock'); - writeln(' build Compile the current project'); - writeln(' run Build and execute src/.chpl'); - writeln(' search Search the registry for packages'); - writeln(' env Print environment variables recognized by mason'); - writeln(' clean Remove the target directory'); - writeln(' doc Build this project\'s documentation'); - writeln(' system Integrate with system packages found via pkg-config'); - writeln(' test Compile and run tests found in /test'); - writeln(' external Integrate external dependencies into mason packages'); - writeln(' publish Publish package to mason-registry'); - writeln(' modules Print flags for including mason dependencies from TOML file'); + const s = """ + Chapel's package manager + + Usage: + mason [...] + mason [options] + + Options: + -h, --help Display this message + -V, --version Print version info and exit + --no-color Do not format text printed on console + + Mason commands: + new Create a new mason project + init Initialize a mason project inside an existing directory + add Add a dependency to Mason.toml + rm Remove a dependency from Mason.toml + update Update/Generate Mason.lock + build Compile the current project + run Build and execute src/.chpl + search Search the registry for packages + env Print environment variables recognized by mason + clean Remove the target directory + doc Build this project\'s documentation + system Integrate with system packages found via pkg-config + test Compile and run tests found in /test + external Integrate external dependencies into mason packages + publish Publish package to mason-registry + modules Print flags for including mason dependencies from TOML file + """.dedent().strip(); + writeln(s); } proc masonRunHelp() { @@ -615,9 +618,11 @@ proc masonDocHelp() { } proc masonModulesHelp() { - writeln("Print flags to include modules from a toml file"); - writeln(); - writeln('Usage:'); - writeln(' mason modules'); - writeln(); + const s = """ + Print flags to include modules from a toml file + + Usage: + mason modules + """.dedent().strip(); + writeln(s); } diff --git a/tools/mason/MasonSystem.chpl b/tools/mason/MasonSystem.chpl index 2eec64f314d4..52fe3c079819 100644 --- a/tools/mason/MasonSystem.chpl +++ b/tools/mason/MasonSystem.chpl @@ -72,7 +72,8 @@ proc pkgConfigExists() throws { /* Searches available system packages */ proc pkgSearch(args) throws { - var parser = new argumentParser(helpHandler=new MasonSystemSearchHelpHandler()); + var parser = + new argumentParser(helpHandler=new MasonSystemSearchHelpHandler()); var quietFlag = parser.addFlag(name="no-show-desc", defaultValue=false); var descFlag = parser.addFlag(name="desc", defaultValue=false); @@ -147,7 +148,9 @@ proc printPkgPc(args) throws { // Add a these call, since `string.join` has an iterator overload but // not one for list. // - var pcDir = "".join(getPkgVariable(pkgName, "--variable=pcfiledir").these()).strip(); + var pcDir = "".join( + getPkgVariable(pkgName, "--variable=pcfiledir").these() + ).strip(); var pcFile = joinPath(pcDir, pkgName + ".pc"); var pc = openReader(pcFile, locking=false); writeln("\n------- " + pkgName + ".pc -------\n"); @@ -157,7 +160,8 @@ proc printPkgPc(args) throws { writeln("\n-------------------\n"); } else { - throw new owned MasonError("Mason could not find " + pkgName + " on your system"); + throw new MasonError("Mason could not find " + + pkgName + " on your system"); } } catch e: FileNotFoundError { @@ -212,9 +216,13 @@ proc getPkgInfo(pkgName: string, version: string) throws { if pkgExists(pkgName) { // Pass "these" to join instead of converting the list to an array. - const pcVersion = "".join(getPkgVariable(pkgName, "--modversion").these()).strip(); + const pcVersion = "".join( + getPkgVariable(pkgName, "--modversion").these() + ).strip(); const libs = "".join(getPkgVariable(pkgName, "--libs").these()).strip(); - const includePath = "".join(getPkgVariable(pkgName, "--variable=includedir").these()).strip(); + const includePath = "".join( + getPkgVariable(pkgName, "--variable=includedir").these() + ).strip(); pkgInfo.set("name", pkgName); pkgInfo.set("version", pcVersion); @@ -222,11 +230,12 @@ proc getPkgInfo(pkgName: string, version: string) throws { pkgInfo.set("include", includePath); if pcVersion != version && version != "*" { - throw new owned MasonError("Unable to locate " + pkgName + ": " +version + "\n Found " + pcVersion); + throw new MasonError("Unable to locate " + pkgName + + ": " +version + "\n Found " + pcVersion); } } else { - throw new owned MasonError("No pkg-config package by the name of: " + pkgName); + throw new MasonError("No pkg-config package by the name of: " + pkgName); } return pkgInfo; } From 0c68e2d166c833602fe7ce79499bdc9114166e6a Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 9 Jan 2026 17:04:39 -0800 Subject: [PATCH 03/19] fix a ton of lints Signed-off-by: Jade Abraham --- tools/mason/MasonPublish.chpl | 346 ++++++++++++++++++++-------------- 1 file changed, 201 insertions(+), 145 deletions(-) diff --git a/tools/mason/MasonPublish.chpl b/tools/mason/MasonPublish.chpl index 533ef297923b..b086e7768d5a 100644 --- a/tools/mason/MasonPublish.chpl +++ b/tools/mason/MasonPublish.chpl @@ -33,11 +33,13 @@ use Subprocess; use TOML; import Path; -/* Top Level procedure that gets called from mason.chpl that takes in arguments from command line. - If --dry-run is passed then it checks to see if the package is able to be published. - Takes in the username of the package owner as an argument +/* + Top Level procedure that gets called from mason.chpl that takes in arguments + from command line. If --dry-run is passed then it checks to see if the package + is able to be published. Takes in the username of the package owner as an + argument */ -proc masonPublish(args: [?d] string) { +proc masonPublish(args: [] string) { var listArgs: list(string); for x in args do listArgs.pushBack(x); masonPublish(listArgs); @@ -82,7 +84,8 @@ proc masonPublish(ref args: list(string)) throws { } var createReg = createFlag.valueAsBool(); - const badSyntaxMessage = 'Arguments do not follow "mason publish [options] " syntax'; + const badSyntaxMessage = + 'Arguments do not follow "mason publish [options] " syntax'; if refreshLicenses { writeln("Force updating list of valid license names from SPDX repo..."); @@ -94,19 +97,23 @@ proc masonPublish(ref args: list(string)) throws { if createReg { var pathReg = registryPath; try! { - if !isDir(pathReg) then mkdir(pathReg); - else throw new owned MasonError("Registry already exists at %s".format(pathReg)); + if !isDir(pathReg) + then mkdir(pathReg); + else + throw new MasonError("Registry already exists at %s".format(pathReg)); if !isDir(pathReg + '/Bricks') then mkdir(pathReg + '/Bricks'); if !isDir(pathReg + '/README.md') then touch(pathReg + '/README.md'); if !isDir(pathReg + '/.git') { gitC(pathReg, 'git init -q'); gitC(pathReg, 'git add .'); - commitSubProcess(pathReg, ['git','commit', '-q', '-m',' "initialized registry"']); + gitC(pathReg, ['git','commit', '-q', '-m',' "initialized registry"']); } const absPathReg = Path.absPath(pathReg); writeln("Initialized local registry at %s".format(pathReg)); - writeln("Add this registry to MASON_REGISTRY environment variable to include it in search path:"); - writeln(' export MASON_REGISTRY="%s|%s,%s|%s"'.format("mason-registry",regUrl, basename(pathReg), absPathReg)); + writeln("Add this registry to MASON_REGISTRY environment variable to " + + "include it in search path:"); + writeln(' export MASON_REGISTRY="%s|%s,%s|%s"' + .format("mason-registry",regUrl, basename(pathReg), absPathReg)); exit(0); } catch e: MasonError { @@ -129,14 +136,17 @@ proc masonPublish(ref args: list(string)) throws { } if ((MASON_OFFLINE && !update) || noUpdate) && !falseIfRemotePath() { - if !isLocal { - throw new owned MasonError('You cannot publish to a remote repository when MASON_OFFLINE is set to true or "--no-update" is passed, override with --update'); - } - else updateRegistry(skipUpdate); + if !isLocal then + throw new MasonError('You cannot publish to a remote repository ' + + 'when MASON_OFFLINE is set to true or ' + + '"--no-update" is passed, override with --update'); + else + updateRegistry(skipUpdate); } if !isLocal && !doesGitOriginExist() && !dry { - throw new owned MasonError('Your package must have a git origin remote in order to publish to a remote registry.'); + throw new MasonError('Your package must have a git origin remote ' + + 'in order to publish to a remote registry.'); } if checkRegistryPath(registryPath, isLocal) { @@ -162,34 +172,38 @@ proc masonPublish(ref args: list(string)) throws { /* creates a file at a given path */ proc touch(pathToFile: string) throws { const fileWriter = open(pathToFile, ioMode.cw).writer(locking=false); - const contents = "This registry was generated by mason publish --create-registry"; + const contents = + "This registry was generated by mason publish --create-registry"; fileWriter.write(contents); fileWriter.close(); } -/* Uses the existence of a colon to see if a passed registryPath is a local or remote registryPath - */ +/* + Uses the existence of a colon to see if a passed registryPath is a + local or remote registryPath +*/ proc isRegistryPathLocal(registryPath : string) throws { return registryPath.find(":") == -1; } -/* When passed a registryPath and whether or not that registryPath is a local or remote registryPath, - the function checks to make sure that it is a valid registryPath to a mason-registry - by checking the existence of the Bricks +/* + When passed a registryPath and whether or not that registryPath is a local or + remote registryPath, the function checks to make sure that it is a valid + registryPath to a mason-registry by checking the existence of the Bricks */ proc checkRegistryPath(registryPath : string, trueIfLocal : bool) throws { try! { if registryPath == MASON_HOME then return true; if !exists('.git') { - throw new owned MasonError(registryPath + ' is not a local git repository.'); + throw new MasonError(registryPath + ' is not a local git repository.'); } if trueIfLocal { if exists(registryPath) && exists(registryPath + "/Bricks/") { return true; } else { - throw new owned MasonError(registryPath + " is not a valid path to a local mason-registry."); - exit(0); + throw new MasonError(registryPath + + " is not a valid path to a local mason-registry."); } } else { @@ -198,8 +212,7 @@ proc checkRegistryPath(registryPath : string, trueIfLocal : bool) throws { checkRemote.wait(); if checkRemote.exitCode == 0 then return true; else { - throw new owned MasonError(registryPath + " is not a valid remote path"); - exit(0); + throw new MasonError(registryPath + " is not a valid remote path"); } } } @@ -208,11 +221,14 @@ proc checkRegistryPath(registryPath : string, trueIfLocal : bool) throws { exit(0); } } -/* Main Script that goes through the act of publishing the package to the mason registry. - Takes the package owners GitHub username as input will throw errors through command - line git commands if any of the git calls fails. +/* + Main Script that goes through the act of publishing the package to the mason + registry. Takes the package owners GitHub username as input will throw errors + through command line git commands if any of the git calls fails. */ -proc publishPackage(username: string, registryPath : string, isLocal : bool) throws { +proc publishPackage(username: string, + registryPath: string, + isLocal: bool) throws { try! { const packageLocation = absPath(here.cwd()); var stream = new randomStream(int, false); @@ -235,22 +251,27 @@ proc publishPackage(username: string, registryPath : string, isLocal : bool) thr branchMasonReg(username, name, safeDir, registryPath); } - const version = addPackageToBricks(packageLocation, safeDir, name, registryPath, isLocal); - var message = ' "Adding %s package to registry via mason publish"'.format(version); + const version = addPackageToBricks(packageLocation, safeDir, name, + registryPath, isLocal); + const message = + ' "Adding %s package to registry via mason publish"'.format(version); var command = ['git', 'commit', '-q', '-m', message]; if !isLocal { gitC(safeDir + "/mason-registry", "git add ."); - commitSubProcess(safeDir + '/mason-registry', command); - gitC(safeDir + "/mason-registry", 'git push --set-upstream origin ' + name, true); + gitC(safeDir + '/mason-registry', command); + gitC(safeDir + "/mason-registry", + 'git push --set-upstream origin ' + name, true); rmTree(safeDir + '/'); - writeln('--------------------------------------------------------------------'); - writeln('Go to the above link to open up a Pull Request to the mason-registry'); + writeln('----------------------------------' + + '----------------------------------'); + writeln('Go to the above link to open up a ' + + 'Pull Request to the mason-registry'); } else { gitC(safeDir, 'git add Bricks/' + name); - commitSubProcess(safeDir, command); + gitC(safeDir, command); writeln('Successfully published package to ' + registryPath); } @@ -260,21 +281,10 @@ proc publishPackage(username: string, registryPath : string, isLocal : bool) thr } } -/* Subprocess function designed to pass a message to 'git commit' without get the string - split by the MasonUtils runCommand()/ - */ -private proc commitSubProcess(dir: string, command: [] string) throws { - var spawnArgs = command; - const oldDir = here.cwd(); - here.chdir(dir); - var commitSpawn = spawn(spawnArgs, stdout=pipeStyle.pipe, stderr=pipeStyle.pipe); - commitSpawn.wait(); - here.chdir(oldDir); - return commitSpawn; -} - -/* If --dry-run is passed then it takes the username and checks to see if the mason-registry is forked - and the package has a git remote origin. If both exist then the package can be published. +/* + If --dry-run is passed then it takes the username and checks to see if the + mason-registry is forked and the package has a git remote origin. + If both exist then the package can be published. */ proc dryRun(username: string, registryPath : string, isLocal : bool) throws { if !isLocal { @@ -288,23 +298,24 @@ proc dryRun(username: string, registryPath : string, isLocal : bool) throws { git = true; } if git && fork { - writeln('Package can be published to the mason-registry'); - writeln('Commands that will be run:'); - writeln('> git clone git:github.com:[username]/mason-registry mason-registry'); - writeln('> git checkout -b [package name]'); - writeln('Package Name will be added to the Bricks in the mason-registry'); - writeln('> git add .'); - writeln('> git commit -m [package info]'); - writeln('> git push --set-upstream origin [package name]'); + const s = """ + Package can be published to the mason-registry + Commands that will be run: + > git clone git:github.com:[username]/mason-registry mason-registry + > git checkout -b [package name] + Package Name will be added to the Bricks in the mason-registry + > git add . + > git commit -m [package info] + > git push --set-upstream origin [package name] + """.dedent().strip(); + writeln(s); exit(0); } else { - if fork == false { - throw new owned MasonError('mason-registry is not forked on your GitHub'); - } - else { - throw new owned MasonError('Package does not gave a git origin'); - } + if !fork then + throw new MasonError('mason-registry is not forked on your GitHub'); + else + throw new MasonError('Package does not gave a git origin'); } } else { @@ -316,39 +327,44 @@ proc dryRun(username: string, registryPath : string, isLocal : bool) throws { returnMasonEnv(); var reg = MASON_REGISTRY; - if reg.size == 1 { - if reg[0] == ('mason-registry', regUrl) - then writeln(' In order to use a local registry, ensure that MASON_REGISTRY points to the path.'); - } + if reg.size == 1 && reg[0] == ('mason-registry', regUrl) then + writeln(' In order to use a local registry, ' + + 'ensure that MASON_REGISTRY points to the path.'); if checkRegistryPath(registryPath, isLocal) { writeln('Package can be published to local registry'); exit(0); } else { - throw new owned MasonError(registryPath + ' is not a valid registryPath to a local registry.'); + throw new MasonError(registryPath + + ' is not a valid registryPath to a local registry.'); } } } /* Clones the mason registry fork from the users repo. Takes username as input. */ -proc cloneMasonReg(username: string, safeDir : string, registryPath : string) throws { +proc cloneMasonReg(username: string, + safeDir: string, + registryPath: string) throws { try! { if registryPath == MASON_HOME { - const gitClone = 'git clone --quiet git@github.com:'; - var ret = gitC(safeDir, gitClone + username + "/mason-registry mason-registry", false); + const gitClone = + 'git clone --quiet git@github.com:%s/mason-registry mason-registry'; + var ret = gitC(safeDir, gitClone.format(username), false); return ret; } else { - const gitRegistryPath = 'git clone --quiet '; - var gitCall = gitC(safeDir, gitRegistryPath + registryPath + ' mason-registry', false); + const gitRegistryPath = + 'git clone --quiet ' + registryPath + ' mason-registry'; + var gitCall = gitC(safeDir, gitRegistryPath, false); return gitCall; } } catch { - throw new owned MasonError('Error cloning the fork of mason-registry. Make sure you have forked the mason-registry on GitHub'); - exit(1); + throw new MasonError( + 'Error cloning the fork of mason-registry. ' + + 'Make sure you have forked the mason-registry on GitHub'); } } @@ -367,16 +383,17 @@ proc doesGitOriginExist() { /* Opens Spawn call to get username for the mason registry fork */ private proc usernameCheck(username: string) { - const gitRemote = 'git ls-remote https://github.com/'; - var usernameCheck = runWithStatus(gitRemote + username + '/mason-registry', true); + const gitRemote = 'git ls-remote https://github.com/%s/mason-registry'; + var usernameCheck = runWithStatus(gitRemote.format(username), true); return usernameCheck; } /* Runs Commands to see if Fork of mason-registry exists under the username */ private proc checkIfForkExists(username: string) { - var getFork = ('git ls-remote https://github.com/' + username + '/mason-registry'); - return runWithStatus(getFork, false); + var getFork = 'git ls-remote https://github.com/%s/mason-registry'; + var p = runWithProcess(getFork.format(username), false); + return p.exitCode; } /* Gets the GitHub username of the user, by parsing from the remote origin url. @@ -389,8 +406,9 @@ private proc getUsername() { return username; } -/* Procedure that returns the url of the git remote origin - */ +/* + Procedure that returns the url of the git remote origin +*/ private proc gitUrl() { try { var url = runCommand("git config --get remote.origin.url", true); @@ -400,18 +418,20 @@ private proc gitUrl() { } } -/* Takes the git username and creates a new branch of the mason registry users fork, - name or branch is taken from the Mason.toml of the mason package. +/* + Takes the git username and creates a new branch of the mason registry users + fork, name or branch is taken from the Mason.toml of the mason package. */ -proc branchMasonReg(username: string, name: string, safeDir: string, registryPath : string) throws { +proc branchMasonReg(username: string, name: string, + safeDir: string, registryPath : string) throws { try! { const branchCommand = "git checkout --quiet -b "+ name: string; var ret = gitC(safeDir + '/mason-registry', branchCommand, false); return ret; } catch { - throw new owned MasonError('Error branching the registry, make sure you have a remote origin set up'); - exit(1); + throw new MasonError('Error branching the registry, make sure you have a ' + + 'remote origin set up'); } } @@ -425,29 +445,36 @@ proc getPackageName() throws { return name; } catch { - throw new owned MasonError('Issue getting the name of your package, ensure your package is a mason project.'); - exit(1); + throw new MasonError('Issue getting the name of your package, ' + + 'ensure your package is a mason project.'); } } -/* Adds package to the Bricks of the mason-registry branch and then adds the version.toml - with the source url of the package's GitHub repo. +/* + Adds package to the Bricks of the mason-registry branch and then adds the + version.toml with the source url of the package's GitHub repo. */ -private proc addPackageToBricks(projectLocal: string, safeDir: string, name : string,registryPath : string, isLocal : bool) throws { +private proc addPackageToBricks(projectLocal: string, safeDir: string, + name: string, registryPath: string, + isLocal: bool) throws { + const bricksDir = joinPath(safeDir, 'Bricks'); + const projectBrickDir = joinPath(bricksDir, name); + const versionToml = joinPath(projectBrickDir, versionNum + ".toml"); try! { - const toParse = open(projectLocal+ "/Mason.toml", ioMode.r); + const toParse = open(projectLocal + "/Mason.toml", ioMode.r); var tomlFile = (parseToml(toParse)); const versionNum = tomlFile!['brick.version']!.s; if !isLocal { - if !exists(safeDir + '/mason-registry/Bricks/') { - throw new owned MasonError('Registry does not have the expected structure. Ensure your registry has a Bricks directory.'); + if !exists(bricksDir) { + throw new MasonError('Registry does not have the expected structure. ' + + 'Ensure your registry has a Bricks directory.'); } - if !exists(safeDir + "/mason-registry/Bricks/" + name) { - mkdir(safeDir + "/mason-registry/Bricks/" + name); + if !exists(projectBrickDir) { + mkdir(projectBrickDir); } - if !exists(safeDir + '/mason-registry/Bricks/' + name + "/" + versionNum + ".toml") { + if !exists(versionToml) { const baseToml = tomlFile; - var newToml = open(safeDir + "/mason-registry/Bricks/" + name + "/" + versionNum + ".toml", ioMode.cw); + var newToml = open(versionToml, ioMode.cw); var tomlWriter = newToml.writer(locking=false); const url = gitUrl(); baseToml["brick"]!.set("source", url[0.. 0 { writeln(' Missing fields in manifest file (Mason.toml). (FAILED)'); writeln(' The missing fields are as follows: '); @@ -566,7 +600,8 @@ proc check(username: string, path: string, trueIfLocal: bool, ci: bool) throws { if package { writeln('Checking for tests:'); if testCheck(projectCheckHome) { - writeln(' Found tests in the package, can be published to a registry. (PASSED)'); + writeln(' Found tests in the package, can be published to a ' + + 'registry. (PASSED)'); } else { writeln(' No tests found in package. (FAILED)'); testTest = false; @@ -578,7 +613,8 @@ proc check(username: string, path: string, trueIfLocal: bool, ci: bool) throws { writeln('Checking git tag version formatting:'); const tagResults = gitTagVersionCheck(projectCheckHome); if tagResults[0] { - writeln(' Valid git tag version formatting, can be published to a registry. (PASSED)'); + writeln(' Valid git tag version formatting, can be published to a ' + + 'registry. (PASSED)'); } else { writeln(' Invalid git tag version formatting. (FAILED)'); const listTags = tagResults[1]; @@ -597,8 +633,9 @@ proc check(username: string, path: string, trueIfLocal: bool, ci: bool) throws { if validLicenseCheck[0] { writeln(' Found valid license in manifest file. (PASSED)'); } else { - writeln(' Invalid license name: "' + validLicenseCheck[1] + '". Please use a valid name from ' + - 'SPDX license list. (FAILED)'); + writeln(' Invalid license name: "' + + validLicenseCheck[1] + '". Please use a valid name from ' + + 'SPDX license list. (FAILED)'); licenseTest = false; } writeln(spacer); @@ -607,11 +644,13 @@ proc check(username: string, path: string, trueIfLocal: bool, ci: bool) throws { if package && !ci { writeln('Git Remote Check:'); if doesGitOriginExist() { - writeln(' Package has a git remote origin and can be published to a remote registry (PASSED)'); + writeln(' Package has a git remote origin and can be published ' + + 'to a remote registry (PASSED)'); writeln(' Remote Origin: ' + getRemoteOrigin()); } else { - writeln(' Package has no remote origin and cannot be publish to a registry with path:' + path + ' (FAILED)'); + writeln(' Package has no remote origin and cannot be publish to a ' + + 'registry with path:' + path + ' (FAILED)'); remoteTest = false; } writeln(spacer); @@ -619,13 +658,16 @@ proc check(username: string, path: string, trueIfLocal: bool, ci: bool) throws { writeln(spacer); if package && !ci { - writeln('Attempting to build package using following options:'); - writeln(' show = false'); - writeln(' release = false'); - writeln(' force = true'); - writeln(' opt = false'); - writeln(' example = false'); - writeln('If these are different than what is required to build your package you can disregard this check'); + const s = """ + Attempting to build package using following options: + show = false + release = false + force = true + opt = false + example = false + If these are different than what is required to build your package you can disregard this check + """.dedent().strip(); + writeln(s); attemptToBuild(); } writeln(spacer); @@ -637,19 +679,21 @@ proc check(username: string, path: string, trueIfLocal: bool, ci: bool) throws { writeln('RESULTS'); writeln(spacer); - if packageTest && remoteTest && moduleTest && testTest - && licenseTest && gitTagTest && masonFieldsTest { + if packageTest && remoteTest && moduleTest && testTest && + licenseTest && gitTagTest && masonFieldsTest { writeln('(PASSED) Your package is ready to publish'); } else { if !packageTest { - writeln('(FAILED) Your package does not have to proper package structure'); + writeln( + '(FAILED) Your package does not have to proper package structure'); } if !moduleTest { writeln('(FAILED) Your package has more than one main module'); } if !masonFieldsTest { - writeln('(FAILED) Your package has missing fields in manifest file (Mason.toml)'); + writeln('(FAILED) Your package has missing fields in manifest file ' + + '(Mason.toml)'); } if !licenseTest { writeln('(FAILED) Your package does not have valid license name.'); @@ -661,7 +705,8 @@ proc check(username: string, path: string, trueIfLocal: bool, ci: bool) throws { writeln('(FAILED) Your package does not have tests'); } if !remoteTest { - writeln('(FAILED) Your package has no remote origin and cannot be published'); + writeln('(FAILED) Your package has no remote origin and cannot be ' + + 'published'); } if !gitTagTest { writeln('(FAILED) Your package has invalid git tag version formatting'); @@ -754,18 +799,24 @@ private proc attemptToBuild() throws { } } -/* registryPathCheck accepts the path, username, and trueIfLocal in order to check whether the registry that someone - is trying to publish to is properly set up and has the correct structure. +/* + registryPathCheck accepts the path, username, and trueIfLocal in order to + check whether the registry that someone is trying to publish to is properly + set up and has the correct structure. */ -private proc registryPathCheck(path : string, username : string, trueIfLocal : bool) throws { +private proc registryPathCheck(path: string, + username: string, + trueIfLocal: bool) throws { if path == MASON_HOME { var forkCheck = usernameCheck(username); if forkCheck == 0 { - writeln(' The mason-registry is forked under username: ' + username + ' (PASSED)'); + writeln(' The mason-registry is forked under username: ' + + username + ' (PASSED)'); return true; } else { - writeln(' You must have a fork of the mason-registry to publish a package (FAILED)'); + writeln(' You must have a fork of the mason-registry to ' + + 'publish a package (FAILED)'); return false; } } @@ -774,17 +825,22 @@ private proc registryPathCheck(path : string, username : string, trueIfLocal : b const isLocalGit = exists(path + '/.git'); const hasBricks = exists(path + '/Bricks/'); if !isLocalGit { - writeln(' Registry with path ' + path + ' is not a git repository. (FAILED)'); - writeln(" Local registries must be git repositories in order to publish"); + writeln(' Registry with path ' + + path + ' is not a git repository. (FAILED)'); + writeln(" Local registries must be git repositories " + + "in order to publish"); return false; } else if !hasBricks { - writeln(' The registry with path ' + path + ' does not have proper registry structure (FAILED)'); - writeln(" A registry must have a /Bricks/ directory to be a valid registry"); + writeln(' The registry with path ' + + path + ' does not have proper registry structure (FAILED)'); + writeln(" A registry must have a /Bricks/ " + + "directory to be a valid registry"); return false; } else { - writeln(' The local registry with path ' + path + ' is a valid registry to be publish too (PASSED)'); + writeln(' The local registry with path ' + + path + ' is a valid registry to be publish too (PASSED)'); return true; } } From 4005755aed781bbbd8b3bfd6ab297150643f23af Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 9 Jan 2026 17:08:21 -0800 Subject: [PATCH 04/19] use joinPath Signed-off-by: Jade Abraham --- tools/mason/MasonPublish.chpl | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tools/mason/MasonPublish.chpl b/tools/mason/MasonPublish.chpl index b086e7768d5a..9725ced64efa 100644 --- a/tools/mason/MasonPublish.chpl +++ b/tools/mason/MasonPublish.chpl @@ -459,11 +459,11 @@ private proc addPackageToBricks(projectLocal: string, safeDir: string, isLocal: bool) throws { const bricksDir = joinPath(safeDir, 'Bricks'); const projectBrickDir = joinPath(bricksDir, name); - const versionToml = joinPath(projectBrickDir, versionNum + ".toml"); try! { - const toParse = open(projectLocal + "/Mason.toml", ioMode.r); + const toParse = open(joinPath(projectLocal, "Mason.toml"), ioMode.r); var tomlFile = (parseToml(toParse)); const versionNum = tomlFile!['brick.version']!.s; + const versionToml = joinPath(projectBrickDir, versionNum + ".toml"); if !isLocal { if !exists(bricksDir) { throw new MasonError('Registry does not have the expected structure. ' + @@ -487,8 +487,7 @@ private proc addPackageToBricks(projectLocal: string, safeDir: string, 'already exists in the Bricks.'); exit(1); } - } - else { + } else { if !exists(joinPath(safeDir, '.git')) { throw new MasonError( 'Unable to publish your package to the registry, ' + @@ -510,7 +509,6 @@ private proc addPackageToBricks(projectLocal: string, safeDir: string, else { throw new MasonError('A package with that name and version '+ 'already exists in the Bricks.'); - exit(1); } } } From cb165358c3d776b7c8c244832ad3fc6d5874d99f Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 9 Jan 2026 17:13:26 -0800 Subject: [PATCH 05/19] more cleanups Signed-off-by: Jade Abraham --- tools/mason/MasonPublish.chpl | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/tools/mason/MasonPublish.chpl b/tools/mason/MasonPublish.chpl index 9725ced64efa..a39e2a3b6191 100644 --- a/tools/mason/MasonPublish.chpl +++ b/tools/mason/MasonPublish.chpl @@ -251,8 +251,7 @@ proc publishPackage(username: string, branchMasonReg(username, name, safeDir, registryPath); } - const version = addPackageToBricks(packageLocation, safeDir, name, - registryPath, isLocal); + const version = addPackageToBricks(packageLocation, safeDir, name, isLocal); const message = ' "Adding %s package to registry via mason publish"'.format(version); var command = ['git', 'commit', '-q', '-m', message]; @@ -355,9 +354,8 @@ proc cloneMasonReg(username: string, return ret; } else { - const gitRegistryPath = - 'git clone --quiet ' + registryPath + ' mason-registry'; - var gitCall = gitC(safeDir, gitRegistryPath, false); + const gitClone = 'git clone --quiet %s mason-registry'; + var gitCall = gitC(safeDir, gitClone.format(registryPath), false); return gitCall; } } @@ -455,8 +453,7 @@ proc getPackageName() throws { version.toml with the source url of the package's GitHub repo. */ private proc addPackageToBricks(projectLocal: string, safeDir: string, - name: string, registryPath: string, - isLocal: bool) throws { + name: string, isLocal: bool) throws { const bricksDir = joinPath(safeDir, 'Bricks'); const projectBrickDir = joinPath(bricksDir, name); try! { @@ -663,7 +660,8 @@ proc check(username: string, path: string, trueIfLocal: bool, ci: bool) throws { force = true opt = false example = false - If these are different than what is required to build your package you can disregard this check + If these are different than what is required to build your package + you can disregard this check """.dedent().strip(); writeln(s); attemptToBuild(); @@ -852,7 +850,8 @@ private proc registryPathCheck(path: string, */ private proc getRemoteOrigin() { const packageDir = here.cwd(); - var gitRemoteOrigin = gitC(packageDir, 'git config --get remote.origin.url', true); + const gitRemoteOrigin = + gitC(packageDir, 'git config --get remote.origin.url', true); return gitRemoteOrigin; } @@ -870,7 +869,8 @@ private proc ensureMasonProject(cwd : string, tomlName="Mason.toml") : string { return ensureMasonProject(dirname, tomlName); } -/*Checks to make sure the package has a main module +/* + Checks to make sure the package has a main module The source file for the main module should have the same name as the package. For example, `foo.chpl` is a valid main module for the following package: @@ -878,12 +878,12 @@ private proc ensureMasonProject(cwd : string, tomlName="Mason.toml") : string { foo/ Mason.toml src/ - foo.chpl # module foo { include module bar; use bar; proc main() { ... } } + foo.chpl # module foo { include module bar; use bar; proc main() {...} } foo/ bar.chpl ... - */ +*/ private proc moduleCheck(projectHome : string) throws { const files = listDir(projectHome + '/src', dirs=false), modules = for f in files do if f.endsWith('.chpl') then f; @@ -907,8 +907,7 @@ proc testCheck(projectHome: string) { return tests.size > 0; } else return false; } -/* Returns the mason env - */ +/* Returns the mason env */ private proc returnMasonEnv() { const fakeArgs = ['env']; masonEnv(fakeArgs); @@ -939,8 +938,10 @@ proc gitTagVersionCheck(projectHome: string) throws { return (false, allTags, version); } -/* make sure directory created is same as that of package - name in manifest file */ +/* + make sure directory created is same as that of package + name in manifest file +*/ proc namespaceCollisionCheck(projectHome: string) throws { var directoryName = basename(projectHome); const toParse = open(projectHome + "/Mason.toml", ioMode.r); From 1f470609f60fbc1aebafdb95f5199b61299bd1aa Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 30 Jan 2026 16:41:58 +0100 Subject: [PATCH 06/19] fix more lints Signed-off-by: Jade Abraham --- tools/mason/MasonRun.chpl | 5 +++-- tools/mason/MasonTest.chpl | 6 +++--- tools/mason/SpecParser.chpl | 3 ++- tools/mason/TestResult.chpl | 12 ++++++------ 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tools/mason/MasonRun.chpl b/tools/mason/MasonRun.chpl index 8d07b223340b..2a7d256f2f11 100644 --- a/tools/mason/MasonRun.chpl +++ b/tools/mason/MasonRun.chpl @@ -72,7 +72,8 @@ proc masonRun(args: [] string) throws { runProjectBinary(show, release, execopts); } -proc runProjectBinary(show: bool, release: bool, execopts: list(string)) throws { +proc runProjectBinary(show: bool, release: bool, + execopts: list(string)) throws { const cwd = here.cwd(); const projectHome = getProjectHome(cwd); @@ -130,7 +131,7 @@ proc runProjectBinary(show: bool, release: bool, execopts: list(string)) throws /* Builds program before running. */ -private proc masonBuildRun(args: [?d] string) throws { +private proc masonBuildRun(args: [] string) throws { var parser = new argumentParser(helpHandler=new MasonRunHelpHandler()); diff --git a/tools/mason/MasonTest.chpl b/tools/mason/MasonTest.chpl index 2336bdd4ecd7..a3d2c4956244 100644 --- a/tools/mason/MasonTest.chpl +++ b/tools/mason/MasonTest.chpl @@ -401,7 +401,7 @@ private proc runTestBinary(projectHome: string, outputLoc: string, result.addFailure(testName, testName+".chpl", errMsg); } else { - result.addSuccess(testName, testName+".chpl"); + result.addSuccess(); } } } @@ -596,7 +596,7 @@ proc testFile(file, const ref compopts: list(string), result.addFailure(executable, fileName, errMsg); } else { - result.addSuccess(executable, fileName); + result.addSuccess(); } } if !keepExec { @@ -754,7 +754,7 @@ proc addTestResult(ref result, ref localesCountMap, ref testNames, select flavour { when "OK" { if show then writeln("Ran ",testName," ",flavour); - result.addSuccess(testName, fileName); + result.addSuccess(); testsPassed.pushBack(testName); } when "ERROR" { diff --git a/tools/mason/SpecParser.chpl b/tools/mason/SpecParser.chpl index e1a33355ea4d..c56dd2639cf2 100644 --- a/tools/mason/SpecParser.chpl +++ b/tools/mason/SpecParser.chpl @@ -156,5 +156,6 @@ private proc parseSpec(ref tokenList: list(string)): 4*string throws { variants.pushBack(toke); } } - return (package, packageVersion, compiler, " ".join(variants.these()).strip()); + return (package, packageVersion, compiler, + " ".join(variants.these()).strip()); } diff --git a/tools/mason/TestResult.chpl b/tools/mason/TestResult.chpl index bfe520626124..6763cf50d286 100644 --- a/tools/mason/TestResult.chpl +++ b/tools/mason/TestResult.chpl @@ -46,14 +46,14 @@ module TestResult { var lock = new ChapelLocks.chpl_LocalSpinlock(); // called when a test ran - proc _testRan() { + proc testRan() { this.testsRun += 1; } /*Called when an error has occurred.*/ proc addError(testName: string, fileName: string, errMsg: string) { manage lock { - this._testRan(); + this.testRan(); var fileAdd = fileName + ": " + testName; this.errors.pushBack((fileAdd, errMsg)); } @@ -62,16 +62,16 @@ module TestResult { /*called when error occured */ proc addFailure(testName: string, fileName: string, errMsg: string) { manage lock { - this._testRan(); + this.testRan(); var fileAdd = fileName + ": " + testName; this.failures.pushBack((fileAdd, errMsg)); } } /*Called when a test has completed successfully*/ - proc addSuccess(testName: string, fileName: string) { + proc addSuccess() { manage lock { - this._testRan(); + this.testRan(); this.testsPassed += 1; } } @@ -79,7 +79,7 @@ module TestResult { /*Called when a test is skipped.*/ proc addSkip(testName: string, fileName: string, errMsg: string) { manage lock { - this._testRan(); + this.testRan(); var fileAdd = fileName + ": " + testName; this.skipped.pushBack((fileAdd, errMsg)); } From 11b9a177d2b8480acea309f35614438573bc49f2 Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 30 Jan 2026 17:25:06 +0100 Subject: [PATCH 07/19] more lints Signed-off-by: Jade Abraham --- tools/mason/MasonInit.chpl | 4 +- tools/mason/MasonNew.chpl | 52 +++++++++---- tools/mason/MasonPublish.chpl | 20 ++--- tools/mason/MasonUtils.chpl | 139 ++++++++++++++++++---------------- 4 files changed, 117 insertions(+), 98 deletions(-) diff --git a/tools/mason/MasonInit.chpl b/tools/mason/MasonInit.chpl index 399be2c8291a..c4bb9960a57c 100644 --- a/tools/mason/MasonInit.chpl +++ b/tools/mason/MasonInit.chpl @@ -115,9 +115,9 @@ proc masonInit(args: [] string) throws { } else { // We can create the /src/ dir and Mason.toml if dirName == '' then - InitProject(cwd, name, vcs, show, version, chplVersion, license, packageType); + initProject(cwd, name, vcs, show, version, chplVersion, license, packageType); else - InitProject(path, name, vcs, show, version, chplVersion, license, packageType); + initProject(path, name, vcs, show, version, chplVersion, license, packageType); } writeln("Tip: To convert existing code to a mason project, " + "move the driver application to the `src/" + name + ".chpl`" + diff --git a/tools/mason/MasonNew.chpl b/tools/mason/MasonNew.chpl index 5bdc845ba715..123c7d8f2210 100644 --- a/tools/mason/MasonNew.chpl +++ b/tools/mason/MasonNew.chpl @@ -87,10 +87,12 @@ proc masonNew(args: [] string) throws { if !isLightweight && validatePackageName(dirName=packageName) { if isDir(dirName) { - throw new owned MasonError("A directory named '" + dirName + "' already exists"); + throw new MasonError("A directory named '" + + dirName + "' already exists"); } } - InitProject(dirName, packageName, vcs, show, version, chplVersion, license, packageType); + initProject(dirName, packageName, vcs, show, version, chplVersion, + license, packageType); } /* Exit terminal when CTRL + D is pressed */ @@ -104,11 +106,13 @@ proc exitOnEOF(parameter) { /* Previews the Mason.toml file that is going to be created */ proc previewMasonFile(packageName, version, chapelVersion, license) { // TODO: update hardcode - const baseToml = getBaseTomlString(packageName, version, chapelVersion, license, "application"); + const baseToml = getBaseTomlString(packageName, version, chapelVersion, + license, "application"); writeln(); writeln(baseToml); } +// TODO: this function is completely unused - remove or use it? /* Perform validation checks on Chapel Version */ proc validateChplVersion(chapelVersion) throws { var low, hi : VersionInfo; @@ -117,19 +121,23 @@ proc validateChplVersion(chapelVersion) throws { var ret = false; (low, hi) = checkChplVersion(chapelVersion, low, hi); ret = low <= current && current <= hi; - if !ret then throw new owned MasonError("Your current " + - "Chapel version ( " + getChapelVersionStr() + " ) is not compatible with this chplVersion."); - else return true; + if !ret { + throw new MasonError("Your current Chapel version ( " + + getChapelVersionStr() + + " ) is not compatible with this chplVersion."); + } else + return true; } /* Checks for illegal package names */ proc validatePackageName(dirName) throws { if dirName == '' { - throw new owned MasonError("No package name specified"); + throw new MasonError("No package name specified"); } else if !isIdentifier(dirName) { - throw new owned MasonError("Bad package name '" + dirName + - "' - only Chapel identifiers are legal package names.\n" + - "Please use mason new %s --name ".format(dirName)); + throw new MasonError( + "Bad package name '" + dirName + + "' - only Chapel identifiers are legal package names.\n" + + "Please use mason new %s --name ".format(dirName)); } else { return true; } @@ -151,7 +159,8 @@ proc addGitIgnore(dirName: string) { GIwriter.close(); } -proc getBaseTomlString(packageName: string, version: string, chapelVersion: string, +proc getBaseTomlString(packageName: string, version: string, + chapelVersion: string, license: string, packageType: string) { const baseToml = """[brick] name="%s" @@ -178,7 +187,8 @@ proc makeBasicToml(dirName: string, path: string, version: string, then defaultChplVersion = chplVersion; if !license.isEmpty() then defaultLicense = license; - const baseToml = getBaseTomlString(dirName, defaultVersion, defaultChplVersion, + const baseToml = getBaseTomlString(dirName, defaultVersion, + defaultChplVersion, defaultLicense, packageType); var tomlFile = open(path+"/Mason.toml", ioMode.cw); var tomlWriter = tomlFile.writer(locking=false); @@ -195,11 +205,21 @@ proc makeSrcDir(path:string) { proc makeModule(path:string, fileName:string, packageType="application") { var libTemplate: string; if packageType == "application" { - libTemplate = '/* Documentation for ' + fileName + - ' */\nmodule '+ fileName + ' {\n proc main() {\n writeln("New mason package: '+ fileName +'");\n }\n}'; + libTemplate = """ + /* Documentation for %s */ + module %s { + proc main() { + writeln("New mason package: %s"); + } + } + """.format(fileName, fileName, fileName).dedent().strip(); } else if packageType == "library" { - libTemplate = '/* Documentation for ' + fileName + - ' */\nmodule '+ fileName + ' {\n // Your library here\n}'; + libTemplate = """ + /* Documentation for %s */ + module %s { + // Your library here + } + """.format(fileName, fileName).dedent().strip(); } var lib = open(path+'/src/'+fileName+'.chpl', ioMode.cw); var libWriter = lib.writer(locking=false); diff --git a/tools/mason/MasonPublish.chpl b/tools/mason/MasonPublish.chpl index a39e2a3b6191..4bcdceef4b59 100644 --- a/tools/mason/MasonPublish.chpl +++ b/tools/mason/MasonPublish.chpl @@ -287,15 +287,9 @@ proc publishPackage(username: string, */ proc dryRun(username: string, registryPath : string, isLocal : bool) throws { if !isLocal { - var fork = true; var remoteCheck = checkIfForkExists(username: string); - if remoteCheck == 1 { - fork = false; - } - var git = false; - if doesGitOriginExist() { - git = true; - } + const fork = remoteCheck != 1; + const git = doesGitOriginExist(); if git && fork { const s = """ Package can be published to the mason-registry @@ -309,15 +303,13 @@ proc dryRun(username: string, registryPath : string, isLocal : bool) throws { """.dedent().strip(); writeln(s); exit(0); - } - else { + } else { if !fork then throw new MasonError('mason-registry is not forked on your GitHub'); else throw new MasonError('Package does not gave a git origin'); } - } - else { + } else { const spacer = '------------------------------------------------------'; writeln('Checking Registry with ' + registryPath + ' path.'); var registryTest = registryPathCheck(registryPath, username, false); @@ -390,8 +382,8 @@ private proc usernameCheck(username: string) { */ private proc checkIfForkExists(username: string) { var getFork = 'git ls-remote https://github.com/%s/mason-registry'; - var p = runWithProcess(getFork.format(username), false); - return p.exitCode; + var status = runWithStatus(getFork.format(username), false); + return status; } /* Gets the GitHub username of the user, by parsing from the remote origin url. diff --git a/tools/mason/MasonUtils.chpl b/tools/mason/MasonUtils.chpl index 8bf8c645415f..ef448c0972ef 100644 --- a/tools/mason/MasonUtils.chpl +++ b/tools/mason/MasonUtils.chpl @@ -83,7 +83,7 @@ proc makeTargetFiles(binLoc: string, projectHome: string) { } } const test = joinPath(target, 'test'); - if(!isDir(test)) { + if !isDir(test) { mkdir(test); } } @@ -171,6 +171,7 @@ proc runWithStatus(command: [] string, quiet=false): int { } } +@chplcheck.ignore("CamelCaseFunctions") proc SPACK_ROOT : string { const envHome = getEnv("SPACK_ROOT"); const default = MASON_HOME + "/spack"; @@ -186,8 +187,10 @@ proc SPACK_ROOT : string { 2. Using the `chpl` in PATH to print CHPL_HOME 3. The CHPL_HOME of the chpl that built this mason (`ChplConfig.CHPL_HOME`) */ +@chplcheck.ignore("CamelCaseFunctions") proc CHPL_HOME : string { + @chplcheck.ignore("CamelCaseFunctions") proc CHPL_HOME_inner() : string { proc getChplHomeFromChpl(): string { var chplHome = ""; @@ -235,11 +238,12 @@ proc getSpackResult(cmd, quiet=false) : string throws { var splitCmd = prefix + cmd; try { log.debugf("running spack command %s\n", splitCmd); - var process = spawnshell(splitCmd, stdout=pipeStyle.pipe, executable="bash"); + var process = spawnshell(splitCmd, + stdout=pipeStyle.pipe, executable="bash"); for line in process.stdout.lines() { ret += line; - if quiet == false { + if !quiet { write(line); } } @@ -263,7 +267,8 @@ proc runSpackCommand(command, quiet=false) { " && . $SPACK_ROOT/share/spack/setup-env.sh && "; var cmd = (prefix + command); - var sub = spawnshell(cmd, stdout=pipeStyle.pipe, stderr=pipeStyle.pipe, executable="bash"); + var sub = spawnshell(cmd, stdout=pipeStyle.pipe, + stderr=pipeStyle.pipe, executable="bash"); // quiet flag necessary for tests to be portable if !quiet { @@ -340,7 +345,9 @@ record VersionInfo { } proc containsMax() { - return this.major == max(int) || this.minor == max(int) || this.bug == max(int); + return this.major == max(int) || + this.minor == max(int) || + this.bug == max(int); } proc isCompatible(other:VersionInfo) : bool { @@ -450,7 +457,8 @@ proc developerMode: bool { proc getProjectHome(cwd: string, tomlName="Mason.toml") : string throws { const (dirname, basename) = splitPath(cwd); if dirname == '/' { - throw new owned MasonError("Mason could not find your configuration file (Mason.toml)"); + throw new MasonError("Mason could not find your " + + "configuration file (Mason.toml)"); } const tomlFile = joinPath(cwd, tomlName); if exists(tomlFile) { @@ -459,28 +467,16 @@ proc getProjectHome(cwd: string, tomlName="Mason.toml") : string throws { return getProjectHome(dirname, tomlName); } - -extern "struct sys_stat_s" record chpl_stat { - var st_mtim: chpl_timespec; -} - -extern "struct timespec" record chpl_timespec { - var tv_sec: int; - var tv_nsec: int; -} - proc getLastModified(filename: string) : int { - use CTypes; + use CTypes, OS.POSIX; - extern proc sys_stat(filename: c_ptrConst(c_char), ref chpl_stat): c_int; - - var file_buf: chpl_stat; + var file_buf: struct_stat; var file_path = filename.c_str(); - if (sys_stat(file_path, file_buf) == 0) { + if stat(file_path, c_ptrTo(file_buf)) == 0 then return file_buf.st_mtim.tv_sec; - } - return -1; + else + return -1; } proc projectModified(projectHome, projectName, binLocation) : bool { @@ -581,6 +577,7 @@ proc getMasonDependencies(sourceList: list(srcSource), // Add dependencies to project // can't use _ since it will leak // see https://github.com/chapel-lang/chapel/issues/25926 + @chplcheck.ignore("UnusedLoopIndex") for (_x, name, version) in srcSource.iterList(sourceList) { const depSrc = joinPath(depPath, "%s-%s".format(name, version), "src", "%s.chpl".format(name)); @@ -593,6 +590,7 @@ proc getMasonDependencies(sourceList: list(srcSource), // Add git dependencies // can't use _ since it will leak // see https://github.com/chapel-lang/chapel/issues/25926 + @chplcheck.ignore("UnusedLoopIndex") for (_x, name, branch, _y) in gitSource.iterList(gitList) { const gitDepSrc = joinPath(gitDepPath, "%s-%s".format(name, branch), "src", "%s.chpl".format(name)); @@ -622,7 +620,8 @@ proc getProjectType(): string throws { const tomlFile = parseToml(toParse); if const type_ = tomlFile.get("brick.type") then return type_.s; - throw new MasonError('Type not found in TOML file; please add a type="application" key'); + throw new MasonError('Type not found in TOML file; '+ + 'please add a type="application" key'); } record package { @@ -787,15 +786,14 @@ proc parseChplVersion(brick: borrowed Toml?): (VersionInfo, VersionInfo) { } const chplVersion = brick!["chplVersion"]!.s; - var low, high : VersionInfo; + var low, high: VersionInfo; try { - var res = checkChplVersion(chplVersion, low, high); - low = res[0]; - high = res[1]; + (low, high) = checkChplVersion(chplVersion); } catch e : Error { const name = brick!["name"]!.s + "-" + brick!["version"]!.s; - stderr.writeln("Invalid chplVersion in package '", name, "': ", chplVersion); + stderr.writeln("Invalid chplVersion in package '", + name, "': ", chplVersion); stderr.writeln("Details: ", e.message()); exit(1); } @@ -805,7 +803,7 @@ proc parseChplVersion(brick: borrowed Toml?): (VersionInfo, VersionInfo) { /* Ensure that Chapel version is properly formatted. Returns a tuple of the low, high supported verisons.*/ -proc checkChplVersion(chplVersion, low, high) throws { +proc checkChplVersion(chplVersion) throws { use Regex; var lo, hi : VersionInfo; const formatMessage = "\n\n" + @@ -815,44 +813,48 @@ proc checkChplVersion(chplVersion, low, high) throws { " x.x\n" + "where 'x' is a positive integer.\n"; - var versions = chplVersion.split(".."); - [v in versions] v = v.strip(); + var versions = chplVersion.split(".."); + [v in versions] v = v.strip(); - // Expecting 1 or 2 version strings - if versions.size > 2 || versions.size < 1 { - throw new owned MasonError("Expecting 1 or 2 versions in chplVersion range." + formatMessage); - } else if versions.size == 2 && (versions[0] == "" || versions[1] == "") { - throw new owned MasonError("Unbounded chplVersion ranges are not allowed." + formatMessage); - } - - proc parseString(ver:string): VersionInfo throws { - var ret : VersionInfo; + // Expecting 1 or 2 version strings + if versions.size > 2 || versions.size < 1 { + throw new MasonError("Expecting 1 or 2 versions in chplVersion range." + + formatMessage); + } else if versions.size == 2 && (versions[0] == "" || versions[1] == "") { + throw new MasonError("Unbounded chplVersion ranges are not allowed." + + formatMessage); + } - // Finds 'x.x' or 'x.x.x' where x is a positive number - const pattern = new regex("^(\\d+\\.\\d+(\\.\\d+)?)$"); - var semver : string; - if pattern.match(ver, semver).matched == false { - throw new owned MasonError("Invalid Chapel version format: " + ver + formatMessage); - } - const nums = for s in semver.split(".") do s:int; - ret.major = nums[0]; - ret.minor = nums[1]; - if nums.size == 3 then ret.bug = nums[2]; + proc parseString(ver:string): VersionInfo throws { + var ret : VersionInfo; - return ret; + // Finds 'x.x' or 'x.x.x' where x is a positive number + const pattern = new regex("^(\\d+\\.\\d+(\\.\\d+)?)$"); + var semver : string; + if !pattern.match(ver, semver).matched { + throw new MasonError("Invalid Chapel version format: " + ver + + formatMessage); } + const nums = for s in semver.split(".") do s:int; + ret.major = nums[0]; + ret.minor = nums[1]; + if nums.size == 3 then ret.bug = nums[2]; - lo = parseString(versions[0]); + return ret; + } - if (versions.size == 1) { - hi = new VersionInfo(max(int), max(int), max(int)); - } else { - hi = parseString(versions[1]); - } - if (lo <= hi) == false then - throw new owned MasonError("Lower bound of chplVersion must be <= upper bound: " + lo.str() + " > " + hi.str()); + lo = parseString(versions[0]); + + if versions.size == 1 { + hi = new VersionInfo(max(int), max(int), max(int)); + } else { + hi = parseString(versions[1]); + } + if lo > hi then + throw new MasonError("Lower bound of chplVersion must be <= upper bound: " + + lo.str() + " > " + hi.str()); - return (lo, hi); + return (lo, hi); } /* Print a TOML file. Expects full path. */ @@ -869,14 +871,17 @@ proc showToml(tomlFile : string) { A library project consists of .gitignore file, Mason.toml file, and directories such as .git, src, example, test */ -proc InitProject(dirName, packageName, vcs, show, +proc initProject(dirName, packageName, vcs, show, version: string, chplVersion: string, license: string, packageType: string) throws { if packageType == "light" { const path = if dirName == "" then here.cwd() else dirName; - const lightName = if packageName == "" then basename(here.cwd()) else packageName; + const lightName = if packageName == "" + then basename(here.cwd()) + else packageName; mkdir(dirName); - makeBasicToml(dirName=lightName, path=path, version, chplVersion, license, packageType); + makeBasicToml(dirName=lightName, path=path, version, chplVersion, + license, packageType); } else { if vcs { gitInit(dirName, show); @@ -887,12 +892,13 @@ proc InitProject(dirName, packageName, vcs, show, } // Confirm git init before creating files if isDir(dirName) { - makeBasicToml(dirName=packageName, path=dirName, version, chplVersion, license, packageType); + makeBasicToml(dirName=packageName, path=dirName, version, chplVersion, + license, packageType); makeSrcDir(dirName); makeModule(dirName, fileName=packageName, packageType); } else { - throw new owned MasonError("Failed to create project"); + throw new MasonError("Failed to create project"); } } if packageName != "" then @@ -950,6 +956,7 @@ record chplOptions { var execopts: list(string); } +@chplcheck.ignore("CamelCaseFunctions") proc MASON_VERSION : string { return "0.2.0"; } From ec49d3e1936c6a6d55a15b519ca6aa480acec1c1 Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 30 Jan 2026 18:15:00 +0100 Subject: [PATCH 08/19] more lints Signed-off-by: Jade Abraham --- tools/mason/MasonExternal.chpl | 2 +- tools/mason/MasonUpdate.chpl | 46 ++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/tools/mason/MasonExternal.chpl b/tools/mason/MasonExternal.chpl index 401c1fa50782..dc9514c89482 100644 --- a/tools/mason/MasonExternal.chpl +++ b/tools/mason/MasonExternal.chpl @@ -639,7 +639,7 @@ proc installSpkg(args: [?d] string) throws { /* Uninstall an external package */ -proc uninstallSpkg(args: [?d] string) throws { +proc uninstallSpkg(args: [] string) throws { var parser = new argumentParser(helpHandler=new MasonUninstallHelpHandler()); diff --git a/tools/mason/MasonUpdate.chpl b/tools/mason/MasonUpdate.chpl index d7cfae977b47..3d538dec6132 100644 --- a/tools/mason/MasonUpdate.chpl +++ b/tools/mason/MasonUpdate.chpl @@ -235,16 +235,14 @@ proc chplVersionError(brick:borrowed Toml) { from the Mason.toml. Starts at the root of the project and continues down dep tree recursively until each dep is recorded */ -private proc createDepTree(root: Toml) { +private proc createDepTree(root: Toml) throws { var dp: domain(string, parSafe=false); var dps: [dp] shared Toml?; var depTree = new shared Toml(dps); if root.pathExists("brick") { depTree.set("root", new shared Toml(root["brick"]!)); - } - else { - stderr.writeln("Could not find brick; Mason cannot update"); - exit(1); + } else { + throw new MasonError("Could not find brick; Mason cannot update"); } log.debugln("Setting depTree for Chapel dependencies"); @@ -307,10 +305,11 @@ private proc createDepTree(root: Toml) { return depTree; } -private proc createDepTrees(depTree: Toml, ref deps: list(shared Toml), name: string) : shared Toml { +private proc createDepTrees(depTree: Toml, + deps: list(shared Toml), + name: string): shared Toml throws { var depList: list(shared Toml?); - while deps.size > 0 { - var dep = deps[0]; + for dep in deps { var brick = dep["brick"]!; var package = brick["name"]!.s; @@ -341,7 +340,6 @@ private proc createDepTrees(depTree: Toml, ref deps: list(shared Toml), name: st var manifests = getManifests(subDeps); var dependency = createDepTrees(depTree, manifests, package); } - deps.getAndRemove(0); } // Use toArray here to avoid making Toml aware of `list`, for now. if depList.size > 0 then @@ -382,14 +380,18 @@ private proc IVRS(A: borrowed Toml, B: borrowed Toml) { const (okB, Blo, Bhi) = verifyChapelVersion(B); const version1 = A["version"]!.s; const version2 = B["version"]!.s; - if okA == false && okB == false { - stderr.writeln("Dependency resolution error: unable to find version of '", name, "' compatible with your version of Chapel (", getChapelVersionStr(), "):"); - stderr.writeln(" v", version1, " expecting ", prettyVersionRange(Alo, Ahi)); - stderr.writeln(" v", version2, " expecting ", prettyVersionRange(Blo, Bhi)); + if !okA && !okB { + stderr.writeln("Dependency resolution error: unable to find version of '", + name, "' compatible with your version of Chapel (", + getChapelVersionStr(), "):"); + stderr.writeln(" v", version1, " expecting ", + prettyVersionRange(Alo, Ahi)); + stderr.writeln(" v", version2, " expecting ", + prettyVersionRange(Blo, Bhi)); exit(1); - } else if okA == true && okB == false { + } else if okA && !okB { return A; - } else if okA == false && okB == true { + } else if !okA && okB { return B; } @@ -400,7 +402,9 @@ private proc IVRS(A: borrowed Toml, B: borrowed Toml) { var v1 = vers1(0): int; var v2 = vers2(0): int; if vers1(0) != vers2(0) { - stderr.writeln("Dependency resolution error: package '", name, "' used by multiple packages expecting different major versions:"); + stderr.writeln( + "Dependency resolution error: package '", name, + "' used by multiple packages expecting different major versions:"); stderr.writeln(" v", version1); stderr.writeln(" v", version2); exit(1); @@ -427,7 +431,7 @@ private proc IVRS(A: borrowed Toml, B: borrowed Toml) { /* Returns the Mason.toml for each dep listed as a Toml */ -private proc getManifests(deps: list((string, shared Toml?))) { +private proc getManifests(deps: list((string, shared Toml?))) throws { var manifests: list(shared Toml); for dep in deps { var name = dep(0); @@ -441,9 +445,9 @@ private proc getManifests(deps: list((string, shared Toml?))) { /* Responsible for parsing the Mason.toml to be given back to a call from getManifests */ -private proc retrieveDep(name: string, version: string) { +private proc retrieveDep(name: string, version: string) throws { for cached in MASON_CACHED_REGISTRY { - const tomlPath = cached + "/Bricks/"+name+"/"+version+".toml"; + const tomlPath = joinPath(cached, "Bricks", name, version + ".toml"); if isFile(tomlPath) { var tomlFile = open(tomlPath, ioMode.r); var depToml = parseToml(tomlFile); @@ -451,8 +455,8 @@ private proc retrieveDep(name: string, version: string) { } } - stderr.writeln("No toml file found in mason-registry for " + name +'-'+ version); - exit(1); + throw new MasonError("No toml file found in mason-registry for " + + name +'-'+ version); } /* Returns the Mason.toml for each dep listed as a Toml */ From ba059cc305dfcacd265739edccfa8f815874bc83 Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 30 Jan 2026 18:18:08 +0100 Subject: [PATCH 09/19] more lints Signed-off-by: Jade Abraham --- tools/mason/MasonTest.chpl | 27 ++++++++++++++------------- tools/mason/MasonUpdate.chpl | 6 +++--- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/tools/mason/MasonTest.chpl b/tools/mason/MasonTest.chpl index a3d2c4956244..492df9f7923c 100644 --- a/tools/mason/MasonTest.chpl +++ b/tools/mason/MasonTest.chpl @@ -348,8 +348,7 @@ private proc runTests(show: bool, run: bool, parallel: bool, filter: string, const testName = testNames[testIdx]; const (outputLoc, success) = compile(testName, result, testsCompiled); if success && run { - runTestBinary(projectHome, outputLoc, testName, - filter, result, show); + runTestBinary(outputLoc, testName, filter, result, show); } } } else { @@ -377,8 +376,7 @@ private proc runTests(show: bool, run: bool, parallel: bool, filter: string, } -private proc runTestBinary(projectHome: string, outputLoc: string, - testName: string, filter: string, +private proc runTestBinary(outputLoc: string, testName: string, filter: string, ref result, show: bool) { const command = outputLoc; var testNames: list(string), @@ -388,8 +386,8 @@ private proc runTestBinary(projectHome: string, outputLoc: string, skippedTestNames: list(string); var localesCountMap: map(int, int, parSafe=false); const exitCode = - runAndLog(command, testName+".chpl", filter, result, numLocales, testsPassed, - testNames, localesCountMap, + runAndLog(command, testName + ".chpl", filter, result, numLocales, + testsPassed, testNames, localesCountMap, failedTestNames, erroredTestNames, skippedTestNames, show); if exitCode != 0 { var newCommand = " ".join(command,"-nl","1"); @@ -419,7 +417,7 @@ private proc runTestBinaries(projectHome: string, testNames: list(string), const outputLoc = projectHome + "/target/test/" + stripExt(testTemp, ".chpl"); const testName = basename(stripExt(test, ".chpl")); - runTestBinary(projectHome, outputLoc, testName, filter, result, show); + runTestBinary(outputLoc, testName, filter, result, show); } } @@ -585,14 +583,17 @@ proc testFile(file, const ref compopts: list(string), testsPassed: list(string), skippedTestNames: list(string); var localesCountMap: map(int, int, parSafe=false); - const exitCode = runAndLog("./"+executable, fileName, filter, result, numLocales, testsPassed, - testNames, localesCountMap, failedTestNames, erroredTestNames, skippedTestNames, show); + const exitCode = + runAndLog("./" + executable, fileName, filter, result, + numLocales, testsPassed, testNames, localesCountMap, + failedTestNames, erroredTestNames, skippedTestNames, show); if exitCode != 0 { - var command = " ".join("./"+executable,"-nl","1"); + var command = " ".join("./" + executable,"-nl","1"); if filter != "" then command += " --filter=" + filter; const testResult = runWithStatus(command, !show); if testResult != 0 { - const errMsg = executable: string +" returned exitCode = "+testResult: string; + const errMsg = + executable:string + " returned exitCode = " + testResult:string; result.addFailure(executable, fileName, errMsg); } else { @@ -784,8 +785,8 @@ proc addTestResult(ref result, ref localesCountMap, ref testNames, testNames.pushBack(testName); } else { - var locErrMsg = "Not a MultiLocale Environment. $CHPL_COMM = " + comm + "\n"; - locErrMsg += errMsg; + const locErrMsg = + "Not a MultiLocale Environment. $CHPL_COMM = " + comm + "\n" + errMsg; result.addSkip(testName, fileName, locErrMsg); skippedTestNames.pushBack(testName); } diff --git a/tools/mason/MasonUpdate.chpl b/tools/mason/MasonUpdate.chpl index 3d538dec6132..20f09a7428c6 100644 --- a/tools/mason/MasonUpdate.chpl +++ b/tools/mason/MasonUpdate.chpl @@ -51,7 +51,7 @@ The current resolution strategy for Mason 0.1.0 is the IVRS as described below: private var failedChapelVersion: list(string); private var log = new logger("mason update"); -proc masonUpdate(args: [?d] string) { +proc masonUpdate(args: [] string) { var tf = "Mason.toml"; var lf = "Mason.lock"; var skipUpdate = MASON_OFFLINE; @@ -222,7 +222,7 @@ proc prettyVersionRange(low, hi) { proc chplVersionError(brick:borrowed Toml) { const info = verifyChapelVersion(brick); - if info(0) == false { + if !info(0) { const low = info(1); const hi = info(2); const name = brick["name"]!.s + "-" + brick["version"]!.s; @@ -325,7 +325,7 @@ private proc createDepTrees(depTree: Toml, depList.pushBack(new shared Toml(package)); - if depTree.pathExists(package) == false { + if !depTree.pathExists(package) { var dt: domain(string, parSafe=false); var depTbl: [dt] shared Toml?; depTree.set(package, depTbl); From 81e1568eda774f1163b53afd1fa3d25a729d69da Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 30 Jan 2026 18:29:38 +0100 Subject: [PATCH 10/19] more lints Signed-off-by: Jade Abraham --- tools/mason/MasonBuild.chpl | 24 +++++++++++++---------- tools/mason/MasonEnv.chpl | 32 +++++++++++++++++++------------ tools/mason/MasonExternal.chpl | 35 +++++++++++++++++++--------------- tools/mason/MasonLogger.chpl | 2 +- tools/mason/MasonModules.chpl | 18 ++++++++++------- 5 files changed, 66 insertions(+), 45 deletions(-) diff --git a/tools/mason/MasonBuild.chpl b/tools/mason/MasonBuild.chpl index 0164d20daa84..8f926a3e7383 100644 --- a/tools/mason/MasonBuild.chpl +++ b/tools/mason/MasonBuild.chpl @@ -60,7 +60,8 @@ proc masonBuild(args: [] string) throws { const projectType = getProjectType(); if projectType == "light" then - throw new owned MasonError("Mason light projects do not currently support 'mason build'"); + throw new MasonError("Mason light projects do not " + + "currently support 'mason build'"); log.debugln("Project type acquired"); @@ -103,16 +104,18 @@ proc masonBuild(args: [] string) throws { const tomlName = configNames[0]; const lockName = configNames[1]; log.debugln("About to build program"); - buildProgram(release, show, force, skipUpdate, compopts, tomlName, lockName); + buildProgram(release, show, force, skipUpdate, + compopts, tomlName, lockName); } } -private proc checkChplVersion(lockFile : borrowed Toml) throws { +private proc checkChplVersion(lockFile: borrowed Toml) throws { const root = lockFile["root"]!; const (success, low, hi) = verifyChapelVersion(root); if !success { - throw new owned MasonError("Build failure: lock file expecting chplVersion " + prettyVersionRange(low, hi)); + throw new MasonError("Build failure: lock file expecting chplVersion " + + prettyVersionRange(low, hi)); } } @@ -226,6 +229,7 @@ proc compileSrc(lockFile: borrowed Toml, binLoc: string, show: bool, // can't use _ since it will leak // see https://github.com/chapel-lang/chapel/issues/25926 + @chplcheck.ignore("UnusedLoopIndex") for (_x, name, version) in srcSource.iterList(sourceList) { const nameVer = "%s-%s".format(name, version); // version of -1 specifies a git dep @@ -246,8 +250,10 @@ proc compileSrc(lockFile: borrowed Toml, binLoc: string, show: bool, // can't use _ since it will leak // see https://github.com/chapel-lang/chapel/issues/25926 + @chplcheck.ignore("UnusedLoopIndex") for (_x, name, branch, _y) in gitSource.iterList(gitList) { - var gitDepSrc = ' ' + gitDepPath + name + "-" + branch + '/src/' + name + ".chpl"; + const gitDepSrc = Path.joinPath(gitDepPath, name + "-" + branch, + 'src', name + ".chpl"); cmd.pushBack(gitDepSrc); } @@ -263,9 +269,7 @@ proc compileSrc(lockFile: borrowed Toml, binLoc: string, show: bool, } // Confirming File Structure - if isFile(projectHome + '/target/' + binLoc + '/' + project) then - return true; - else return false; + return isFile(Path.joinPath(projectHome, 'target', binLoc, project)); } return false; } @@ -383,7 +387,7 @@ proc getTomlCompopts(lock: borrowed Toml): list(string) throws { } if const exDeps = lock.get['external'] { - for (name, depInfo) in zip(exDeps.A.keys(), exDeps.A.values()) { + for (_, depInfo) in zip(exDeps.A.keys(), exDeps.A.values()) { for (k,v) in allFields(depInfo!) { var val = v!; select k { @@ -396,7 +400,7 @@ proc getTomlCompopts(lock: borrowed Toml): list(string) throws { } } if const pkgDeps = lock.get['system'] { - for (name, dep) in zip(pkgDeps.A.keys(), pkgDeps.A.values()) { + for (_, dep) in zip(pkgDeps.A.keys(), pkgDeps.A.values()) { var depInfo = dep!; compopts.pushBack(depInfo["libs"]!.s); compopts.pushBack("-I" + depInfo["include"]!.s); diff --git a/tools/mason/MasonEnv.chpl b/tools/mason/MasonEnv.chpl index 38c7b445006a..ad21d9cbc3ff 100644 --- a/tools/mason/MasonEnv.chpl +++ b/tools/mason/MasonEnv.chpl @@ -24,6 +24,7 @@ use MasonUtils; public use MasonHelp; const regUrl: string = "https://github.com/chapel-lang/mason-registry"; +@chplcheck.ignore("CamelCaseFunctions") proc MASON_HOME : string { const envHome = getEnv("MASON_HOME"); const default = getEnv('HOME') + "/.mason"; @@ -36,6 +37,7 @@ proc MASON_HOME : string { Returns an array of directory strings corresponding to MASON_HOME/name for each name in MASON_REGISTRY. */ +@chplcheck.ignore("CamelCaseFunctions") proc MASON_CACHED_REGISTRY { const masonRegistry = MASON_REGISTRY; const masonHome = MASON_HOME; @@ -50,6 +52,7 @@ proc MASON_CACHED_REGISTRY { Returns value of MASON_OFFLINE, environment variable that disables online access. */ +@chplcheck.ignore("CamelCaseFunctions") proc MASON_OFFLINE { const offlineEnv = getEnv('MASON_OFFLINE'); const default = false; @@ -64,13 +67,15 @@ proc MASON_OFFLINE { return offline; } -/* Read the MASON_REGISTRY environment variable. It should be a comma - separated list of registry 'name|location' pairs. Returns an array of - tuples containing (name, location). If 'name|' is omitted, it defaults - to the text following the final slash in 'location' after removing any - trailing slashes. e.g. if location is "/path/to/my/local_registry//" - then the default name is "local_registry". - */ +/* + Read the MASON_REGISTRY environment variable. It should be a comma + separated list of registry 'name|location' pairs. Returns an array of + tuples containing (name, location). If 'name|' is omitted, it defaults + to the text following the final slash in 'location' after removing any + trailing slashes. e.g. if location is "/path/to/my/local_registry//" + then the default name is "local_registry". +*/ +@chplcheck.ignore("CamelCaseFunctions") proc MASON_REGISTRY throws { const env = getEnv("MASON_REGISTRY"); const default = ("mason-registry",regUrl); @@ -83,7 +88,8 @@ proc MASON_REGISTRY throws { if str.strip().isEmpty() then continue; const regArr = str.split('|'); if regArr.size > 2 || regArr.size < 1 { - const msg = "expected MASON_REGISTRY to contain a comma separated list of locations or 'name|location' pairs\n" + str; + const msg = "expected MASON_REGISTRY to contain a comma separated " + + "list of locations or 'name|location' pairs\n" + str; throw new MasonError(msg); } else { var regTup: 2*string; @@ -116,10 +122,12 @@ proc MASON_REGISTRY throws { return registries; } -/* Returns the path to use when caching the list of licenses, if provided by the - user. This is useful for systems where internet connectivity can be erratic - or slow. - */ +/* + Returns the path to use when caching the list of licenses, if provided by the + user. This is useful for systems where internet connectivity can be erratic + or slow. +*/ +@chplcheck.ignore("CamelCaseFunctions") proc MASON_LICENSE_CACHE_PATH: string { const licenseCache = getEnv("MASON_LICENSE_CACHE_PATH"); diff --git a/tools/mason/MasonExternal.chpl b/tools/mason/MasonExternal.chpl index dc9514c89482..1b2ab7566175 100644 --- a/tools/mason/MasonExternal.chpl +++ b/tools/mason/MasonExternal.chpl @@ -266,8 +266,9 @@ private proc generateYAML() { if isFile(yamlFilePath) { remove(yamlFilePath); } - const reposOverride = 'repos:\n'+ - ' - ' + MASON_HOME + '/spack-registry/var/spack/repos/builtin \n'; + const reposOverride = + 'repos:\n'+ + ' - ' + MASON_HOME + '/spack-registry/var/spack/repos/builtin \n'; var yamlFile = open(yamlFilePath,ioMode.cw); var yamlWriter = yamlFile.writer(locking=false); yamlWriter.write(reposOverride); @@ -300,8 +301,9 @@ private proc listSpkgs() { } /* Queries spack for package existence */ -private proc searchSpkgs(args: [?d] string) { - var parser = new argumentParser(helpHandler=new MasonExternalSearchHelpHandler()); +private proc searchSpkgs(args: [] string) { + var parser = new argumentParser(helpHandler= + new MasonExternalSearchHelpHandler()); var descFlag = parser.addFlag(name="description", opts=["-d","--desc"], @@ -335,8 +337,9 @@ private proc listInstalled() { /* User facing function to show packages installed on system. Takes all spack arguments ex. -df */ -private proc findSpkg(args: [?d] string) { - var parser = new argumentParser(helpHandler=new MasonExternalFindHelpHandler()); +private proc findSpkg(args: [] string) { + var parser = new argumentParser(helpHandler= + new MasonExternalFindHelpHandler()); var findArgs = parser.addArgument(name="package", numArgs=0..); @@ -349,9 +352,10 @@ private proc findSpkg(args: [?d] string) { } /* Entry point into the various info subcommands */ -private proc spkgInfo(args: [?d] string) { +private proc spkgInfo(args: [] string) { - var parser = new argumentParser(helpHandler=new MasonExternalInfoHelpHandler()); + var parser = new argumentParser(helpHandler= + new MasonExternalInfoHelpHandler()); var archFlag = parser.addFlag(name="architecture", opts=["--arch"], @@ -396,7 +400,7 @@ proc spkgInstalled(spec: string) { /* Entry point into the various compiler functions */ -private proc compiler(args: [?d] string) { +private proc compiler(args: [] string) { var parser = new argumentParser(helpHandler=new MasonCompilerHelpHandler()); @@ -536,7 +540,7 @@ proc getSpkgInfo(spec: string, ref dependencies: list(string)): shared Toml thro } } else { - throw new owned MasonError("No package installed by the name of: " + pkgName); + throw new MasonError("No package installed by the name of: " + pkgName); } } catch e: MasonError { @@ -576,7 +580,7 @@ proc getSpkgDependencies(spec: string): list(string) throws { } } if !found { - throw new owned MasonError("Mason could not find dependency: " + spec); + throw new MasonError("Mason could not find dependency: " + spec); } return dependencies; } @@ -599,7 +603,7 @@ private proc resolveSpec(spec: string): string throws { const output = getSpackResult(command, quiet=true); if output == '' { - throw new owned MasonError("Package not found: " + spec); + throw new MasonError("Package not found: " + spec); } return output; @@ -607,7 +611,7 @@ private proc resolveSpec(spec: string): string throws { /* Install an external package */ -proc installSpkg(args: [?d] string) throws { +proc installSpkg(args: [] string) throws { var parser = new argumentParser(helpHandler=new MasonInstallHelpHandler()); var quietFlag = parser.addFlag(name="quiet", defaultValue=false); @@ -631,9 +635,10 @@ proc installSpkg(args: [?d] string) throws { exit(1); } - const status = runSpackCommand(" ".join(command, spec), quietFlag.valueAsBool()); + const status = + runSpackCommand(" ".join(command, spec), quietFlag.valueAsBool()); if status != 0 { - throw new owned MasonError("Package could not be installed"); + throw new MasonError("Package could not be installed"); } } diff --git a/tools/mason/MasonLogger.chpl b/tools/mason/MasonLogger.chpl index 019948d860af..fa435bed03a5 100644 --- a/tools/mason/MasonLogger.chpl +++ b/tools/mason/MasonLogger.chpl @@ -71,7 +71,7 @@ module MasonLogger { // TODO make all variadic proc info(s: string) { - if doInfo then Safe.writef(logWriter, addPrefix("%s"), s); ; + if doInfo then Safe.writef(logWriter, addPrefix("%s"), s); } proc infoln(s: string) { diff --git a/tools/mason/MasonModules.chpl b/tools/mason/MasonModules.chpl index 9e07beaab0a1..2979e58b38cb 100644 --- a/tools/mason/MasonModules.chpl +++ b/tools/mason/MasonModules.chpl @@ -29,6 +29,7 @@ use MasonEnv; use MasonBuild; use Subprocess; use TOML; +import Path.joinPath; // A call to `mason modules` will print to screen the flags that are // required to include the mason packages specified in the TOML file @@ -54,7 +55,7 @@ proc masonModules(args: [] string) throws { skipUpdate = !updateFlag.valueAsBool(); } - if isDir(MASON_HOME) == false { + if !isDir(MASON_HOME) { mkdir(MASON_HOME, parents=true); } const configNames = updateLock(skipUpdate, show=false); @@ -70,21 +71,24 @@ proc masonModules(args: [] string) throws { getSrcCode(sourceList, skipUpdate, false); getGitCode(gitList, false); - const depPath = MASON_HOME + '/src/'; - const gitDepPath = MASON_HOME + '/git/'; + const depPath = joinPath(MASON_HOME, 'src'); + const gitDepPath = joinPath(MASON_HOME, 'git'); var modules: string; // can't use _ since it will leak // see https://github.com/chapel-lang/chapel/issues/25926 + @chplcheck.ignore("UnusedLoopIndex") for (_x, name, version) in srcSource.iterList(sourceList) { - var depM = ' ' + depPath + name + "-" + version + '/src/' + name + ".chpl";; - modules += depM; + const depM = joinPath(depPath, name + "-" + version, 'src', name + ".chpl"); + modules += ' ' + depM; } // can't use _ since it will leak // see https://github.com/chapel-lang/chapel/issues/25926 + @chplcheck.ignore("UnusedLoopIndex") for (_x, name, branch, _y) in gitSource.iterList(gitList) { - var gitDepSrc = ' ' + gitDepPath + name + "-" + branch + '/src/' + name + ".chpl"; - modules += gitDepSrc; + const gitDepSrc = + joinPath(gitDepPath, name + "-" + branch, 'src', name + ".chpl"); + modules += ' ' + gitDepSrc; } writeln(modules); From 76978e24a293eff9226952e4b42e34d60e02c039 Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 30 Jan 2026 18:31:34 +0100 Subject: [PATCH 11/19] few more lints Signed-off-by: Jade Abraham --- tools/mason/MasonPublish.chpl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/mason/MasonPublish.chpl b/tools/mason/MasonPublish.chpl index 4bcdceef4b59..e578c9b1d281 100644 --- a/tools/mason/MasonPublish.chpl +++ b/tools/mason/MasonPublish.chpl @@ -564,7 +564,8 @@ proc check(username: string, path: string, trueIfLocal: bool, ci: bool) throws { writeln(' %s'.format(field)); masonFieldsTest = false; } else if manifestResults.mismatchedTypes.size > 0 { - writeln(' Mismatched field types in manifest file (Mason.toml). (FAILED)'); + writeln(' Mismatched field types in manifest file (Mason.toml). ', + '(FAILED)'); writeln(' The fields with mismatched types are as follows: '); for field in manifestResults.mismatchedTypes do writeln(' %s'.format(field)); @@ -576,7 +577,8 @@ proc check(username: string, path: string, trueIfLocal: bool, ci: bool) throws { if package { writeln('Checking for examples:'); if exampleCheck(projectCheckHome) { - writeln(' Found examples in the package, can be published to a registry. (PASSED)'); + writeln(' Found examples in the package, ', + 'can be published to a registry. (PASSED)'); } else { writeln(' No examples found in package. (WARNING)'); exampleTest = false; @@ -838,8 +840,7 @@ private proc registryPathCheck(path: string, } } -/* Grabs the remote origin of the package - */ +/* Grabs the remote origin of the package */ private proc getRemoteOrigin() { const packageDir = here.cwd(); const gitRemoteOrigin = @@ -847,8 +848,10 @@ private proc getRemoteOrigin() { return gitRemoteOrigin; } -/* Makes sure that the directory `mason publish --check is called in is a mason package - */ +/* + Makes sure that the directory `mason publish --check` + is called in is a mason package +*/ private proc ensureMasonProject(cwd : string, tomlName="Mason.toml") : string { const (dirname, basename) = splitPath(cwd); if dirname == '/' { From 48d8c3e947ccc912b1600da86fae7aa2fa9fc5e9 Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 30 Jan 2026 18:45:41 +0100 Subject: [PATCH 12/19] more lints Signed-off-by: Jade Abraham --- tools/mason/MasonBuild.chpl | 3 ++- tools/mason/MasonExample.chpl | 20 ++++++++++++-------- tools/mason/MasonExternal.chpl | 23 +++++++++++------------ tools/mason/MasonInit.chpl | 30 +++++++++++++++--------------- 4 files changed, 40 insertions(+), 36 deletions(-) diff --git a/tools/mason/MasonBuild.chpl b/tools/mason/MasonBuild.chpl index 8f926a3e7383..853175582ba8 100644 --- a/tools/mason/MasonBuild.chpl +++ b/tools/mason/MasonBuild.chpl @@ -324,7 +324,8 @@ proc getSrcCode(sourceList: list(srcSource), skipUpdate, show) throws { const destination = baseDir + nameVers; if !depExists(nameVers) { if skipUpdate then - throw new MasonError("Dependency cannot be installed when MASON_OFFLINE is set."); + throw new MasonError("Dependency cannot be installed when " + + "MASON_OFFLINE is set."); writeln("Downloading dependency: " + nameVers); var getDependency = "git clone -qn "+ srcURL + ' ' + destination +'/'; var checkout = "git checkout -q v" + version; diff --git a/tools/mason/MasonExample.chpl b/tools/mason/MasonExample.chpl index e089d01ee519..9d5600347789 100644 --- a/tools/mason/MasonExample.chpl +++ b/tools/mason/MasonExample.chpl @@ -53,7 +53,8 @@ proc masonExample(args: [] string) throws { const projectType = getProjectType(); if projectType == "light" then - throw new owned MasonError("Mason light projects do not currently support 'mason example'"); + throw new MasonError("Mason light projects do not currently " + + "support 'mason example'"); try! { parser.parseArgs(args); @@ -263,19 +264,22 @@ private proc runExamples(show: bool, run: bool, build: bool, release: bool, } } else { // build is skipped but examples still need to be run - writeln("Skipping "+ example + ": no changes made to project or example"); + writeln("Skipping ", example, + ": no changes made to project or example"); if run then - runExampleBinary(projectHome, exampleName, release, show, exampleExecopts); + runExampleBinary(projectHome, exampleName, + release, show, exampleExecopts); } } // just running the example else { - runExampleBinary(projectHome, exampleName, release, show, exampleExecopts); + runExampleBinary(projectHome, exampleName, + release, show, exampleExecopts); } } } else { - throw new owned MasonError("No examples were found in /example"); + throw new MasonError("No examples were found in /example"); } } catch e: MasonError { @@ -300,9 +304,9 @@ private proc runExampleBinary(projectHome: string, exampleName: string, const exampleResult = runWithStatus(command.toArray()); if exampleResult != 0 { throw new MasonError( - "Example has not been compiled: " + exampleName + ".chpl\n" + - "Try running: mason build --example " + exampleName + ".chpl\n" + - " or: mason run --example " + exampleName + ".chpl --build"); + "Example has not been compiled: " + exampleName + ".chpl\n" + + "Try running: mason build --example " + exampleName + ".chpl\n" + + " or: mason run --example " + exampleName + ".chpl --build"); } } diff --git a/tools/mason/MasonExternal.chpl b/tools/mason/MasonExternal.chpl index 1b2ab7566175..0ebe35d5a086 100644 --- a/tools/mason/MasonExternal.chpl +++ b/tools/mason/MasonExternal.chpl @@ -74,10 +74,11 @@ proc masonExternal(args: [] string) { if setupFlag.valueAsBool() { // if MASON_OFFLINE is set, then cannot install spack if MASON_OFFLINE { - throw new owned MasonError('Cannot setup Spack when MASON_OFFLINE is set to true'); + throw new MasonError('Cannot setup Spack when MASON_OFFLINE ' + + 'is set to true'); } - // If spack and spack registry is present with latest version, print message + // If spack and spack registry is present with latest version, print if isDir(SPACK_ROOT) && isDir(spackRegistryDefaultPath) && getSpackVersion() == minSpackVersion && @@ -131,9 +132,10 @@ proc masonExternal(args: [] string) { } // check that after all this, the version of spack is as we expect it if getSpackVersion() <= minSpackVersion then - throw new owned MasonError("Spack update or installation failed. \ - Expected v%s, got v%s".format(minSpackVersion.str(), - getSpackVersion().str())); + throw new MasonError("Spack update or installation failed. " + + "Expected v%s, got v%s".format( + minSpackVersion.str(), + getSpackVersion().str())); exit(0); } if spackInstalled() { @@ -218,7 +220,8 @@ proc setupSpack() throws { proc cloneSpackRepository(branch : string, dest: string) { const repo = "https://github.com/spack/spack "; const depth = '--depth 1 '; - const command = 'git clone -q -c advice.detachedHead=false ' + branch + depth + repo + dest; + const command = 'git clone -q -c advice.detachedHead=false ' + + branch + depth + repo + dest; const statusPackages = runWithStatus(command); if statusPackages != 0 then return -1; else return 0; @@ -485,7 +488,7 @@ proc getExternalPackages(exDeps: Toml) /* [domain(string)] shared Toml? */ { /* Retrieves build information for MasonUpdate */ -proc getSpkgInfo(spec: string, ref dependencies: list(string)): shared Toml throws { +proc getSpkgInfo(spec: string, dependencies: list(string)): shared Toml throws { var depList: list(shared Toml); var spkgDom: domain(string, parSafe=false); @@ -516,8 +519,7 @@ proc getSpkgInfo(spec: string, ref dependencies: list(string)): shared Toml thro spkgInfo.set("libs", libs); spkgInfo.set("include", includePath); - while dependencies.size > 0 { - var dep = dependencies[0]; + for dep in dependencies { var depSpec = dep.split("@", 1); var name = depSpec[0]; @@ -530,9 +532,6 @@ proc getSpkgInfo(spec: string, ref dependencies: list(string)): shared Toml thro // get a toml that contains the dependency info and put it // in a subtable of the current dependencies table spkgInfo.set(name, getSpkgInfo(dep, depsOfDep)); - - // remove dep for recursion - dependencies.getAndRemove(0); } if depList.size > 0 { // Temporarily use toArray here to avoid supporting list. diff --git a/tools/mason/MasonInit.chpl b/tools/mason/MasonInit.chpl index c4bb9960a57c..ec926b476aab 100644 --- a/tools/mason/MasonInit.chpl +++ b/tools/mason/MasonInit.chpl @@ -95,29 +95,29 @@ proc masonInit(args: [] string) throws { if dirName != '' then if !isDir(path) then - throw new owned MasonError("Directory does not exist: " + path + - " Did you mean 'mason new' to create a " + - "new project from scratch?"); + throw new MasonError("Directory does not exist: " + path + + " Did you mean 'mason new' to create a " + + "new project from scratch?"); // If TOML file exists, send message that package is already // initialized and give some info on what they might want to // do instead. if isFile(path + '/Mason.toml') { - throw new owned MasonError("Mason.toml already exists for current project. " + - "Remove or rename the existing manifest file and rerun " + - "`mason init` to initialize a new project."); + throw new MasonError( + "Mason.toml already exists for current project. " + + "Remove or rename the existing manifest file and rerun " + + "`mason init` to initialize a new project."); } else if isDir(path + '/src/') { - throw new owned MasonError("/src/ directory already exists for current project. " + - "Remove or rename the /src/ directory and rerun " + - "`mason init` to initialize a new project. " + - "Alternatively, run `mason new --light` to add only a " + - "manifest file."); + throw new MasonError( + "/src/ directory already exists for current project. " + + "Remove or rename the /src/ directory and rerun " + + "`mason init` to initialize a new project. " + + "Alternatively, run `mason new --light` to add only a " + + "manifest file."); } else { // We can create the /src/ dir and Mason.toml - if dirName == '' then - initProject(cwd, name, vcs, show, version, chplVersion, license, packageType); - else - initProject(path, name, vcs, show, version, chplVersion, license, packageType); + initProject(cwd, name, vcs, show, version, chplVersion, + license, packageType); } writeln("Tip: To convert existing code to a mason project, " + "move the driver application to the `src/" + name + ".chpl`" + From 9b61f51d81c61ffdc3b1808f5129e8df36ce2b62 Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 30 Jan 2026 18:57:13 +0100 Subject: [PATCH 13/19] more lints Signed-off-by: Jade Abraham --- tools/mason/MasonModify.chpl | 6 ++++-- tools/mason/MasonUpdate.chpl | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/mason/MasonModify.chpl b/tools/mason/MasonModify.chpl index 86e2fc18d7a7..326d2c8ef848 100644 --- a/tools/mason/MasonModify.chpl +++ b/tools/mason/MasonModify.chpl @@ -206,10 +206,12 @@ private proc masonSystemRemove(toml: shared Toml, toRm: string) throws { } /* Add an external dependency to Mason.toml */ -private proc masonExternalAdd(toml: shared Toml, toAdd: string, spec: string) throws { +private proc masonExternalAdd(toml: shared Toml, + toAdd: string, spec: string) throws { if toml.pathExists("external") { if toml.pathExists("external." + toAdd) { - throw new owned MasonError("An external dependency by that name already exists in Mason.toml"); + throw new MasonError("An external dependency by that name " + + "already exists in Mason.toml"); } else { toml["external"]!.set(toAdd, spec); diff --git a/tools/mason/MasonUpdate.chpl b/tools/mason/MasonUpdate.chpl index 20f09a7428c6..9ecd64f4c0dd 100644 --- a/tools/mason/MasonUpdate.chpl +++ b/tools/mason/MasonUpdate.chpl @@ -112,7 +112,8 @@ proc updateLock(skipUpdate: bool, tf="Mason.toml", lf="Mason.lock", const prefix = if failedChapelVersion.size == 1 then "The following package is" else "The following packages are"; - stderr.writeln(prefix, " incompatible with your version of Chapel (", getChapelVersionStr(), ")"); + stderr.writeln(prefix, " incompatible with your version of Chapel (", + getChapelVersionStr(), ")"); for msg in failedChapelVersion do stderr.writeln(" ", msg); exit(1); @@ -480,7 +481,8 @@ private proc retrieveGitDep(name: string, branch: string) { return depToml; } - stderr.writeln("No toml file found in git dependency for " + name +'-'+ branch); + stderr.writeln("No toml file found in git dependency for " + + name + '-' + branch); exit(1); } From a52c12b8a84ede4334c79340b292f9cfe4f16c02 Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 30 Jan 2026 19:26:58 +0100 Subject: [PATCH 14/19] update help tests Signed-off-by: Jade Abraham --- .../mason-help-tests/masonHelpTests.good | 161 ++-- tools/mason/MasonHelp.chpl | 757 ++++++++++-------- 2 files changed, 522 insertions(+), 396 deletions(-) diff --git a/test/mason/mason-help-tests/masonHelpTests.good b/test/mason/mason-help-tests/masonHelpTests.good index 81063633b2ae..d94aaa49ef3c 100644 --- a/test/mason/mason-help-tests/masonHelpTests.good +++ b/test/mason/mason-help-tests/masonHelpTests.good @@ -6,13 +6,15 @@ Options: -h, --help Display this message --show Increase verbosity --no-vcs Do not initialize a git repository - --app Create a Mason "application" (package with main function) - --lib Create a Mason "library" (package without main function) - --light Create a Mason "lightweight" project (place a TOML file in current directory) - --name Specify package name different from directory name + --app Create a Mason "application" + --lib Create a Mason "library" + --light Create a Mason "lightweight" project + --name Specify package name different from directory + name ******************************************************************************** $ mason init -h Initializes a library project inside a given directory or path. + Usage: mason init [options] mason init [options] @@ -21,10 +23,11 @@ Options: -h, --help Display this message --show Increase verbosity --no-vcs Do not initialize a git repository - --app Create a Mason "application" (package with main function) - --lib Create a Mason "library" (package without main function) - --light Create a Mason "lightweight" project (place a TOML file in current directory) - --name Specify package name different from directory name + --app Create a Mason "application" + --lib Create a Mason "library" + --light Create a Mason "lightweight" project + --name Specify package name different from directory + name ******************************************************************************** $ mason add -h Modify a Mason package's Mason.toml @@ -38,8 +41,10 @@ Options: --external Add/Remove dependency from external dependencies --system Add/Remove dependency from system dependencies -Not listing an option will add/remove the dependency from the Mason [dependencies] table -Versions are necessary for adding dependencies, but not for removing dependencies +Not listing an option will add/remove the dependency from the Mason +[dependencies] table +Versions are necessary for adding dependencies, but not for removing +dependencies Manually edit the Mason.toml if multiple versions of the same package are listed Package names and versions are not validated upon adding ******************************************************************************** @@ -55,8 +60,10 @@ Options: --external Add/Remove dependency from external dependencies --system Add/Remove dependency from system dependencies -Not listing an option will add/remove the dependency from the Mason [dependencies] table -Versions are necessary for adding dependencies, but not for removing dependencies +Not listing an option will add/remove the dependency from the Mason +[dependencies] table +Versions are necessary for adding dependencies, but not for removing +dependencies Manually edit the Mason.toml if multiple versions of the same package are listed Package names and versions are not validated upon adding ******************************************************************************** @@ -69,20 +76,23 @@ Usage: Options: -h, --help Display this message --show Increase verbosity - --release Compile to target/release with optimizations (--fast) + --release Compile to target/release with optimizations + (--fast) --force Force Mason to build the project --example Build an example from the example/ directory - --[no-]update [Do not] update the mason registry before building - --dependent-modules Print the include paths to the dependent modules to be integrated into build step + --[no-]update [Do not] update the mason registry before + building + --dependent-modules Print the include paths to the dependent + modules to be integrated into build step When --example is thrown without an example, all examples will be built When no options are provided, the following will take place: - Build from mason project if Mason.lock present Compilation flags and arguments can be included after mason arguments. -To ensure compilation flags and mason arguments to not conflict, separate them with a -double dash(`--`). For example - e.g. mason build --force -- --savec tmpdir +To ensure compilation flags and mason arguments to not conflict, separate them +with a double dash(`--`). For example + mason build --force -- --savec tmpdir ******************************************************************************** $ mason run -h Run the compiled project and output to standard output @@ -96,16 +106,17 @@ Options: --show Increase verbosity --example Run an example -When --example is thrown without an example, all available examples will be listed +When --example is thrown without an example, all available examples +will be listed When no options are provided, the following will take place: - Execute binary from mason project if target/ is present - - If no target directory, build and run is Mason.toml is present + - If no target directory, build and run if Mason.toml is present Runtime arguments can be included after mason arguments. -To ensure that runtime arguments and mason arguments do not conflict, separate them -with a double dash(`--`). For example - e.g. mason run --build -- --runtimeArg=true +To ensure that runtime arguments and mason arguments do not conflict, separate +them with a double dash(`--`). For example + mason run --build -- --runtimeArg=true ******************************************************************************** $ mason search -h Search the registry for a package @@ -115,8 +126,8 @@ Usage: Options: -h, --help Display this message - --show Display the manifest of a package - --[no-]update [Do not] update the mason registry before + --show Display the manifest of a package + --[no-]update [Do not] update the mason registry before searching the registry When no query is provided, all packages in the registry will be listed. The @@ -145,7 +156,6 @@ Usage: Options: -h, --help Display this message - ******************************************************************************** $ mason doc -h Generate documentation for a mason package using chpldoc @@ -159,7 +169,6 @@ Options: Will generate documentation when ran inside a mason package. Requires that chpldoc is set up in order to work. For instructions on setting up chpldoc, please view its documentation. - ******************************************************************************** $ mason system -h Integrate a Mason package with system packages found via pkg-config @@ -185,7 +194,6 @@ Usage: Options: -h, --help Display this message - ******************************************************************************** $ mason system search -h Search for packages on system found via pkg-config @@ -196,13 +204,14 @@ Usage: Options: -h, --help Display this message --no-show-desc Only display package name - --desc Parse descriptions of package to include more search results - + --desc Parse descriptions of package to include more + search results ******************************************************************************** $ mason test -h mason test works inside and outside of mason packages. Inside a mason package: run test files found in test/ -Outside of a mason package: run test files found in the provided path (defaults to '.'). +Outside of a mason package: run test files found in the provided path + (defaults to '.'). Usage: mason test [options] @@ -212,11 +221,14 @@ Options: --show Direct output of tests to stdout --no-run Compile tests without running them --keep-binary Doesn't delete the binaries after running - --recursive Descend recursively into subdirectories of given directories - --parallel Run tests in parallel(sequential by default) + --recursive Descend recursively into subdirectories of + given directories + --parallel Run tests in parallel (sequential by default) --[no]-update [Do not] update the mason-registry when testing - --setComm Set the CHPL_COMM value for running the tests, e.g. none, gasnet, ugni - --filter=FILTER Filter the tests to run in each file by a regular expression + --setComm Set the CHPL_COMM value for running the tests + e.g. none, gasnet, ofi + --filter=FILTER Filter the tests to run in each file by a + regular expression Test configuration is up to the user Tests pass if they exit with status code 0 @@ -234,13 +246,15 @@ Options: install Install an external package uninstall Uninstall an external package info Show information about an external package - find Find information about installed external packages + find Find information about installed external + packages -V, --version Display Spack version -h, --help Display this message --setup Download and install Spack backend --spec Display Spack specification help -Please see Mason documentation for more instructions on using external packages +Please see Mason documentation for more instructions on using external +packages ******************************************************************************** Installing Spack backend ... $ mason external search -h @@ -251,8 +265,8 @@ Usage: Options: -h, --help Display this message - -d, --desc Parse descriptions of package to include more search results - + -d, --desc Parse descriptions of package to include more + search results ******************************************************************************** $ mason external compiler -h Find and view compilers on your system @@ -263,9 +277,9 @@ Usage: Options: -h, --help Display this message --find Find compilers on your system - --edit Open the compilers configuration file in $EDITOR + --edit Open the compilers configuration file in + $EDITOR --list List the compilers on your system - ******************************************************************************** $ mason external install -h Install external packages onto your system @@ -277,38 +291,50 @@ Usage: Options: -h, --help Display this message - --only {package,dependencies} Select the mode of installation. the default is to - install the package along with all its dependencies. - alternatively one can decide to install only the - package or only the dependencies - --jobs JOBS Explicitly set number of make jobs. default is #cpus - --overwrite reinstall an existing spec, even if it has dependents - --keep-prefix Don't remove the install prefix if installation fails - --keep-stage Don't remove the build stage if installation succeeds - --restage If a partial install is detected, delete prior state + --only {package,dependencies} Select the mode of installation. The default + is to install the package along with all its + dependencies. Alternatively one can decide to + install only the package or only the + dependencies + --jobs JOBS Explicitly set number of make jobs. Default + is #cpus + --overwrite Reinstall an existing spec, even if it has + dependents + --keep-prefix Don't remove the install prefix if + installation fails + --keep-stage Don't remove the build stage if installation + succeeds + --restage If a partial install is detected, delete + prior state --use-cache Check for pre-built packages in mirrors --show-log-on-error Print full build log to stderr if build fails --source Install source files in prefix --no-checksum Do not check packages against checksum --fake Fake install for debug purposes. - --file Install from file. Read specs to install from .yaml - --clean Sanitize the environment from variables that can - affect how packages find libraries or headers - --dirty Maintain the current environment without trying to + --file Install from file. Read specs to install from + .yaml + --clean Sanitize the environment from variables that + can affect how packages find libraries or + headers + --dirty Maintain the current environment without + trying to sanitize it --test {root,all} If 'root' is chosen, run package tests during - installation for top-level packages (but skip tests - for dependencies). if 'all' is chosen, run package - tests during installation for all packages. If neither - are chosen, don't run tests for any packages. - --run-tests Run package tests during installation (same as --test=all) + installation for top-level packages (but skip + tests for dependencies). If 'all' is chosen, + run package tests during installation for all + packages. If neither are chosen, don't run + tests for any packages. + --run-tests Run package tests during installation + (same as --test=all) --log-format {junit} Format to be used for log files - --log-file LOG_FILE Filename for the log file. if not passed a default will be used - --yes-to-all Assume 'yes' is the answer to every confirmation request + --log-file LOG_FILE Filename for the log file. If not passed a + default will be used + --yes-to-all Assume 'yes' is the answer to every + confirmation request External Mason packages can be installed as follows: mason external install - ******************************************************************************** $ mason external uninstall -h Uninstall external packages on your system @@ -321,12 +347,12 @@ Usage: Options: -h, --help Display this message --force Remove regardless of dependents - --all USE CAREFULLY. remove ALL installed packages that match supplied spec + --all USE CAREFULLY. remove ALL installed packages + that match supplied spec --dependents Also uninstall any dependent packages External Mason packages can be uninstalled as follows: mason external uninstall - ******************************************************************************** $ mason external info -h Get information about external packages and system architecture @@ -334,10 +360,11 @@ Get information about external packages and system architecture Usage: mason external info [options] - : a Spack spec expression indicating the package to retrieve information on + : a Spack spec expression indicating the package to retrieve + information on Options: -h, --help Display this message - --arch Print architecture information about current system - + --arch Print architecture information about current + system ******************************************************************************** diff --git a/tools/mason/MasonHelp.chpl b/tools/mason/MasonHelp.chpl index a05da886e26c..aa9662090b44 100644 --- a/tools/mason/MasonHelp.chpl +++ b/tools/mason/MasonHelp.chpl @@ -181,7 +181,7 @@ proc masonHelp() { Options: -h, --help Display this message -V, --version Print version info and exit - --no-color Do not format text printed on console + --no-color Do not format text printed on console Mason commands: new Create a new mason project @@ -205,82 +205,101 @@ proc masonHelp() { } proc masonRunHelp() { - writeln('Run the compiled project and output to standard output'); - writeln(); - writeln('Usage:'); - writeln(' mason run [options]'); - writeln(); - writeln('Options:'); - writeln(' -h, --help Display this message'); - writeln(' --build Compile before running binary'); - writeln(' --show Increase verbosity'); - writeln(' --example Run an example'); - writeln(); - writeln('When --example is thrown without an example, all available examples will be listed'); - writeln(); - writeln('When no options are provided, the following will take place:'); - writeln(' - Execute binary from mason project if target/ is present'); - writeln(' - If no target directory, build and run is Mason.toml is present'); - writeln(); - writeln('Runtime arguments can be included after mason arguments.'); - writeln('To ensure that runtime arguments and mason arguments do not conflict, separate them'); - writeln('with a double dash(`--`). For example'); - writeln(' e.g. mason run --build -- --runtimeArg=true'); + const s = """ + Run the compiled project and output to standard output + + Usage: + mason run [options] + + Options: + -h, --help Display this message + --build Compile before running binary + --show Increase verbosity + --example Run an example + + When --example is thrown without an example, all available examples + will be listed + + When no options are provided, the following will take place: + - Execute binary from mason project if target/ is present + - If no target directory, build and run if Mason.toml is present + + Runtime arguments can be included after mason arguments. + To ensure that runtime arguments and mason arguments do not conflict, separate + them with a double dash(`--`). For example + mason run --build -- --runtimeArg=true + """.dedent().strip(); + writeln(s); } proc masonBuildHelp() { - writeln('Compile a local package and all of its dependencies'); - writeln(); - writeln('Usage:'); - writeln(' mason build [options]'); - writeln(); - writeln('Options:'); - writeln(' -h, --help Display this message'); - writeln(' --show Increase verbosity'); - writeln(' --release Compile to target/release with optimizations (--fast)'); - writeln(' --force Force Mason to build the project'); - writeln(' --example Build an example from the example/ directory'); - writeln(' --[no-]update [Do not] update the mason registry before building'); - writeln(' --dependent-modules Print the include paths to the dependent modules to be integrated into build step'); - writeln(); - writeln('When --example is thrown without an example, all examples will be built'); - writeln('When no options are provided, the following will take place:'); - writeln(' - Build from mason project if Mason.lock present'); - writeln(); - writeln('Compilation flags and arguments can be included after mason arguments.'); - writeln('To ensure compilation flags and mason arguments to not conflict, separate them with a'); - writeln('double dash(`--`). For example'); - writeln(' e.g. mason build --force -- --savec tmpdir'); + const s = """ + Compile a local package and all of its dependencies + + Usage: + mason build [options] + + Options: + -h, --help Display this message + --show Increase verbosity + --release Compile to target/release with optimizations + (--fast) + --force Force Mason to build the project + --example Build an example from the example/ directory + --[no-]update [Do not] update the mason registry before + building + --dependent-modules Print the include paths to the dependent + modules to be integrated into build step + + When --example is thrown without an example, all examples will be built + When no options are provided, the following will take place: + - Build from mason project if Mason.lock present + + Compilation flags and arguments can be included after mason arguments. + To ensure compilation flags and mason arguments to not conflict, separate them + with a double dash(`--`). For example + mason build --force -- --savec tmpdir + """.dedent().strip(); + writeln(s); } proc masonNewHelp() { - writeln('Usage:'); - writeln(' mason new [options] '); - writeln(); - writeln('Options:'); - writeln(' -h, --help Display this message'); - writeln(' --show Increase verbosity'); - writeln(' --no-vcs Do not initialize a git repository'); - writeln(' --app Create a Mason "application" (package with main function)'); - writeln(' --lib Create a Mason "library" (package without main function)'); - writeln(' --light Create a Mason "lightweight" project (place a TOML file in current directory)'); - writeln(' --name Specify package name different from directory name'); + const s = """ + Usage: + mason new [options] + + Options: + -h, --help Display this message + --show Increase verbosity + --no-vcs Do not initialize a git repository + --app Create a Mason "application" + --lib Create a Mason "library" + --light Create a Mason "lightweight" project + --name Specify package name different from directory + name + """.dedent().strip(); + writeln(s); } proc masonInitHelp(){ - writeln("Initializes a library project inside a given directory or path."); - writeln('Usage:'); - writeln(' mason init [options] '); - writeln(' mason init [options]'); - writeln(); - writeln('Options:'); - writeln(' -h, --help Display this message'); - writeln(' --show Increase verbosity'); - writeln(' --no-vcs Do not initialize a git repository'); - writeln(' --app Create a Mason "application" (package with main function)'); - writeln(' --lib Create a Mason "library" (package without main function)'); - writeln(' --light Create a Mason "lightweight" project (place a TOML file in current directory)'); - writeln(' --name Specify package name different from directory name'); + const s = """ + Initializes a library project inside a given directory or path. + + Usage: + mason init [options] + mason init [options] + + Options: + -h, --help Display this message + --show Increase verbosity + --no-vcs Do not initialize a git repository + --app Create a Mason "application" + --lib Create a Mason "library" + --light Create a Mason "lightweight" project + --name Specify package name different from directory + name + """.dedent().strip(); + writeln(s); } proc masonSearchHelp() { @@ -293,8 +312,8 @@ proc masonSearchHelp() { Options: -h, --help Display this message - --show Display the manifest of a package - --[no-]update [Do not] update the mason registry before + --show Display the manifest of a package + --[no-]update [Do not] update the mason registry before searching the registry When no query is provided, all packages in the registry will be listed. The @@ -307,314 +326,394 @@ proc masonSearchHelp() { } proc masonModifyHelp() { - writeln("Modify a Mason package's Mason.toml"); - writeln(); - writeln("Usage:"); - writeln(" mason rm [options] package"); - writeln(" mason add [options] package@version"); - writeln(); - writeln("Options:"); - writeln(" -h, --help Display this message"); - writeln(" --external Add/Remove dependency from external dependencies"); - writeln(" --system Add/Remove dependency from system dependencies"); - writeln(); - writeln("Not listing an option will add/remove the dependency from the Mason [dependencies] table"); - writeln("Versions are necessary for adding dependencies, but not for removing dependencies"); - writeln("Manually edit the Mason.toml if multiple versions of the same package are listed"); - writeln("Package names and versions are not validated upon adding"); + const s = """ +Modify a Mason package's Mason.toml + +Usage: + mason rm [options] package + mason add [options] package@version + +Options: + -h, --help Display this message + --external Add/Remove dependency from external dependencies + --system Add/Remove dependency from system dependencies + +Not listing an option will add/remove the dependency from the Mason +[dependencies] table +Versions are necessary for adding dependencies, but not for removing +dependencies +Manually edit the Mason.toml if multiple versions of the same package are listed +Package names and versions are not validated upon adding + """.dedent().strip(); + writeln(s); } proc masonUpdateHelp() { - writeln("Update registries and generate Mason.lock"); - writeln("Usage:"); - writeln(" mason update [options]"); - writeln(); - writeln("Options:"); - writeln(" -h, --help Display this message"); - writeln(" --[no-]update [Do not] update the mason registry before generating the lock file"); - writeln(" --force Force an update to the cached mason registry"); + const s = """ + Update registries and generate Mason.lock + + Usage: + mason update [options] + + Options: + -h, --help Display this message + --[no-]update [Do not] update the mason registry before + generating the lock file + --force Force an update to the cached mason registry + """.dedent().strip(); + writeln(s); } proc masonEnvHelp() { - writeln("Print environment variables recognized by mason"); - writeln(); - writeln("Usage:"); - writeln(" mason env [options]"); - writeln(); - writeln("Options:"); - writeln(" -h, --help Display this message"); - writeln(); - writeln("Environment variables set by the user will be printed with an"); - writeln("asterisk at the end of the line."); + const s = """ + Print environment variables recognized by mason + + Usage: + mason env [options] + + Options: + -h, --help Display this message + + Environment variables set by the user will be printed with an + asterisk at the end of the line. + """.dedent().strip(); + writeln(s); } proc masonExternalHelp() { - writeln("Use, install and search for external packages to build Mason packages with"); - writeln(); - writeln("Usage:"); - writeln(' mason external [options] [...]'); - writeln(' mason external [options]'); - writeln(); - writeln("Options:"); - writeln(" search Search for a specific external package"); - writeln(" compiler List and search for compilers on system"); - writeln(" install Install an external package"); - writeln(" uninstall Uninstall an external package"); - writeln(" info Show information about an external package"); - writeln(" find Find information about installed external packages"); - writeln(" -V, --version Display Spack version"); - writeln(" -h, --help Display this message"); - writeln(" --setup Download and install Spack backend"); - writeln(" --spec Display Spack specification help"); - writeln(); - writeln("Please see Mason documentation for more instructions on using external packages"); + const s = """ + Use, install and search for external packages to build Mason packages with + + Usage: + mason external [options] [...] + mason external [options] + + Options: + search Search for a specific external package + compiler List and search for compilers on system + install Install an external package + uninstall Uninstall an external package + info Show information about an external package + find Find information about installed external + packages + -V, --version Display Spack version + -h, --help Display this message + --setup Download and install Spack backend + --spec Display Spack specification help + + Please see Mason documentation for more instructions on using external + packages + """.dedent().strip(); + writeln(s); } proc masonExternalFindHelp() { - writeln("Find external packages on your system and get information about them"); - writeln(); - writeln("Usage:"); - writeln(" mason external find [options]"); - writeln(" mason external find [options] "); - writeln(); - writeln(" : a Spack spec expression indicating the package to find"); - writeln(); - writeln("Options:"); - writeln(" -h, --help Display this message"); - writeln(); - writeln("Display Options:"); - writeln(" -s, --short Show only specs (default)"); - writeln(" -p, --paths Show paths to package install directories"); - writeln(" -d, --deps Show full dependency DAG of installed packages"); - writeln(" -l, --long Show dependency hashes as well as versions"); - writeln(" -L, --very-long Show full dependency hashes as well as versions"); - writeln(" -t TAGS, --tags TAGS Filter a package query by tags"); - writeln(" --show-flags Show spec compiler flags"); - writeln(" --show-full-compiler Show full compiler specs"); - writeln(" --variants Show variants in output (can be long)"); - writeln(" -e, --explicit Show only specs that were installed explicitly"); - writeln(" -E, --implicit Show only specs that were installed as dependencies"); - writeln(" -u, --unknown Show only specs Spack does not have a package for"); - writeln(" -m, --missing Show missing dependencies as well as installed specs"); - writeln(" -M, --only-missing Show only missing dependencies"); - writeln(" -N, --namespace Show fully qualified package names"); - writeln(); - writeln("When no package is listed, all installed external packages will be listed."); + const s = """ +Find external packages on your system and get information about them + +Usage: + mason external find [options] + mason external find [options] + + : a Spack spec expression indicating the package to find + +Options: + -h, --help Display this message + +Display Options: + -s, --short Show only specs (default) + -p, --paths Show paths to package install directories + -d, --deps Show full dependency DAG of installed packages + -l, --long Show dependency hashes as well as versions + -L, --very-long Show full dependency hashes as well as versions + -t TAGS, --tags TAGS Filter a package query by tags + --show-flags Show spec compiler flags + --show-full-compiler Show full compiler specs + --variants Show variants in output (can be long) + -e, --explicit Show only specs that were installed explicitly + -E, --implicit Show only specs that were installed as + dependencies + -u, --unknown Show only specs Spack does not have a package + for + -m, --missing Show missing dependencies as well as installed + specs + -M, --only-missing Show only missing dependencies + -N, --namespace Show fully qualified package names + +When no package is listed, all installed external packages will be listed. + """.dedent().strip(); + writeln(s); } proc masonExternalInfoHelp() { - writeln("Get information about external packages and system architecture"); - writeln(); - writeln("Usage:"); - writeln(" mason external info [options] "); - writeln(); - writeln(" : a Spack spec expression indicating the package to retrieve information on"); - writeln(); - writeln("Options:"); - writeln(" -h, --help Display this message"); - writeln(" --arch Print architecture information about current system"); - writeln(); + const s = """ + Get information about external packages and system architecture + + Usage: + mason external info [options] + + : a Spack spec expression indicating the package to retrieve + information on + + Options: + -h, --help Display this message + --arch Print architecture information about current + system + """.dedent().strip(); + writeln(s); } proc masonExternalSearchHelp() { - writeln("Search for external packages"); - writeln(); - writeln("Usage:"); - writeln(" mason external search [options] "); - writeln(); - writeln("Options:"); - writeln(" -h, --help Display this message"); - writeln(" -d, --desc Parse descriptions of package to include more search results"); - writeln(); + const s = """ + Search for external packages + + Usage: + mason external search [options] + + Options: + -h, --help Display this message + -d, --desc Parse descriptions of package to include more + search results + """.dedent().strip(); + writeln(s); } proc masonInstallHelp() { - writeln("Install external packages onto your system"); - writeln(); - writeln("Usage:"); - writeln(" mason external install [options] "); - writeln(); - writeln(" : a Spack spec expression indicating the package to install"); - writeln(); - writeln("Options:"); - writeln(" -h, --help Display this message"); - writeln(" --only {package,dependencies} Select the mode of installation. the default is to"); - writeln(" install the package along with all its dependencies."); - writeln(" alternatively one can decide to install only the"); - writeln(" package or only the dependencies"); - writeln(" --jobs JOBS Explicitly set number of make jobs. default is #cpus"); - writeln(" --overwrite reinstall an existing spec, even if it has dependents"); - writeln(" --keep-prefix Don't remove the install prefix if installation fails"); - writeln(" --keep-stage Don't remove the build stage if installation succeeds"); - writeln(" --restage If a partial install is detected, delete prior state"); - writeln(" --use-cache Check for pre-built packages in mirrors"); - writeln(" --show-log-on-error Print full build log to stderr if build fails"); - writeln(" --source Install source files in prefix"); - writeln(" --no-checksum Do not check packages against checksum"); - // writeln(" -v, --verbose Display verbose build output while installing"); #10622 - writeln(" --fake Fake install for debug purposes."); - writeln(" --file Install from file. Read specs to install from .yaml"); - writeln(" --clean Sanitize the environment from variables that can"); - writeln(" affect how packages find libraries or headers"); - writeln(" --dirty Maintain the current environment without trying to"); - writeln(" sanitize it"); - writeln(" --test {root,all} If 'root' is chosen, run package tests during"); - writeln(" installation for top-level packages (but skip tests"); - writeln(" for dependencies). if 'all' is chosen, run package"); - writeln(" tests during installation for all packages. If neither"); - writeln(" are chosen, don't run tests for any packages."); - writeln(" --run-tests Run package tests during installation (same as --test=all)"); - writeln(" --log-format {junit} Format to be used for log files"); - writeln(" --log-file LOG_FILE Filename for the log file. if not passed a default will be used"); - writeln(" --yes-to-all Assume 'yes' is the answer to every confirmation request"); - writeln(); - writeln("External Mason packages can be installed as follows:"); - writeln(" mason external install "); - writeln(); + const s = """ +Install external packages onto your system + +Usage: + mason external install [options] + + : a Spack spec expression indicating the package to install + +Options: + -h, --help Display this message + --only {package,dependencies} Select the mode of installation. The default + is to install the package along with all its + dependencies. Alternatively one can decide to + install only the package or only the + dependencies + --jobs JOBS Explicitly set number of make jobs. Default + is #cpus + --overwrite Reinstall an existing spec, even if it has + dependents + --keep-prefix Don't remove the install prefix if + installation fails + --keep-stage Don't remove the build stage if installation + succeeds + --restage If a partial install is detected, delete + prior state + --use-cache Check for pre-built packages in mirrors + --show-log-on-error Print full build log to stderr if build fails + --source Install source files in prefix + --no-checksum Do not check packages against checksum + --fake Fake install for debug purposes. + --file Install from file. Read specs to install from + .yaml + --clean Sanitize the environment from variables that + can affect how packages find libraries or + headers + --dirty Maintain the current environment without + trying to + sanitize it + --test {root,all} If 'root' is chosen, run package tests during + installation for top-level packages (but skip + tests for dependencies). If 'all' is chosen, + run package tests during installation for all + packages. If neither are chosen, don't run + tests for any packages. + --run-tests Run package tests during installation + (same as --test=all) + --log-format {junit} Format to be used for log files + --log-file LOG_FILE Filename for the log file. If not passed a + default will be used + --yes-to-all Assume 'yes' is the answer to every + confirmation request + +External Mason packages can be installed as follows: + mason external install + """.dedent().strip(); + writeln(s); } proc masonUninstallHelp() { - writeln("Uninstall external packages on your system"); - writeln(); - writeln("Usage:"); - writeln(" mason external uninstall [options] "); - writeln(); - writeln(" : a Spack spec expression indicating the package to install"); - writeln(); - writeln("Options:"); - writeln(" -h, --help Display this message"); - writeln(" --force Remove regardless of dependents"); - writeln(" --all USE CAREFULLY. remove ALL installed packages that match supplied spec"); - writeln(" --dependents Also uninstall any dependent packages"); - writeln(); - writeln("External Mason packages can be uninstalled as follows:"); - writeln(" mason external uninstall "); - writeln(); + const s = """ + Uninstall external packages on your system + + Usage: + mason external uninstall [options] + + : a Spack spec expression indicating the package to install + + Options: + -h, --help Display this message + --force Remove regardless of dependents + --all USE CAREFULLY. remove ALL installed packages + that match supplied spec + --dependents Also uninstall any dependent packages + + External Mason packages can be uninstalled as follows: + mason external uninstall + """.dedent().strip(); + writeln(s); } proc masonCompilerHelp() { - writeln("Find and view compilers on your system"); - writeln(); - writeln("Usage:"); - writeln(" mason external compiler [options]"); - writeln(); - writeln("Options:"); - writeln(" -h, --help Display this message"); - writeln(" --find Find compilers on your system"); - writeln(" --edit Open the compilers configuration file in $EDITOR"); - writeln(" --list List the compilers on your system"); - writeln(); - } + const s = """ + Find and view compilers on your system + + Usage: + mason external compiler [options] + + Options: + -h, --help Display this message + --find Find compilers on your system + --edit Open the compilers configuration file in + $EDITOR + --list List the compilers on your system + """.dedent().strip(); + writeln(s); +} proc masonTestHelp() { - writeln("mason test works inside and outside of mason packages."); - writeln("Inside a mason package: run test files found in test/"); - writeln("Outside of a mason package: run test files found in the provided path (defaults to '.')."); - writeln(); - writeln("Usage:"); - writeln(" mason test [options] "); - writeln(); - writeln("Options:"); - writeln(" -h, --help Display this message"); - writeln(" --show Direct output of tests to stdout"); - writeln(" --no-run Compile tests without running them"); - writeln(" --keep-binary Doesn't delete the binaries after running"); - writeln(" --recursive Descend recursively into subdirectories of given directories"); - writeln(" --parallel Run tests in parallel(sequential by default)"); - writeln(" --[no]-update [Do not] update the mason-registry when testing"); - writeln(" --setComm Set the CHPL_COMM value for running the tests, e.g. none, gasnet, ugni"); - writeln(" --filter=FILTER Filter the tests to run in each file by a regular expression"); - writeln(); - writeln("Test configuration is up to the user"); - writeln("Tests pass if they exit with status code 0"); + const s = """ +mason test works inside and outside of mason packages. +Inside a mason package: run test files found in test/ +Outside of a mason package: run test files found in the provided path + (defaults to '.'). + +Usage: + mason test [options] + +Options: + -h, --help Display this message + --show Direct output of tests to stdout + --no-run Compile tests without running them + --keep-binary Doesn't delete the binaries after running + --recursive Descend recursively into subdirectories of + given directories + --parallel Run tests in parallel (sequential by default) + --[no]-update [Do not] update the mason-registry when testing + --setComm Set the CHPL_COMM value for running the tests + e.g. none, gasnet, ofi + --filter=FILTER Filter the tests to run in each file by a + regular expression + +Test configuration is up to the user +Tests pass if they exit with status code 0 + """.dedent().strip(); + writeln(s); } proc masonSystemHelp() { - writeln("Integrate a Mason package with system packages found via pkg-config"); - writeln(); - writeln("Usage:"); - writeln(' mason system [options] [...]'); - writeln(" mason system [options]"); - writeln(); - writeln("Options:"); - writeln(" pc Print a system package's .pc file"); - writeln(" search Search all packages available on the system"); - writeln(" -h, --help Display this message"); - writeln(); - writeln("The pc command sometimes has trouble finding a .pc file if the file is named"); - writeln("something other than .pc Use -i to ensure package exists"); - writeln("For more information on using system dependencies see Mason documentation"); + const s = """ + Integrate a Mason package with system packages found via pkg-config + + Usage: + mason system [options] [...] + mason system [options] + + Options: + pc Print a system package's .pc file + search Search all packages available on the system + -h, --help Display this message + + The pc command sometimes has trouble finding a .pc file if the file is named + something other than .pc Use -i to ensure package exists + For more information on using system dependencies see Mason documentation + """.dedent().strip(); + writeln(s); } proc masonSystemSearchHelp() { - writeln("Search for packages on system found via pkg-config"); - writeln(); - writeln("Usage:"); - writeln(" mason system search [options]"); - writeln(); - writeln("Options:"); - writeln(" -h, --help Display this message"); - writeln(" --no-show-desc Only display package name"); - writeln(" --desc Parse descriptions of package to include more search results"); - writeln(); + const s = """ + Search for packages on system found via pkg-config + + Usage: + mason system search [options] + + Options: + -h, --help Display this message + --no-show-desc Only display package name + --desc Parse descriptions of package to include more + search results + """.dedent().strip(); + writeln(s); } proc masonSystemPcHelp() { - writeln("Print a package's .pc file (pkg-config file)"); - writeln(); - writeln("Usage:"); - writeln(" mason system pc [options]"); - writeln(); - writeln("Options:"); - writeln(" -h, --help Display this message"); - writeln(); + const s = """ + Print a package's .pc file (pkg-config file) + + Usage: + mason system pc [options] + + Options: + -h, --help Display this message + """.dedent().strip(); + writeln(s); } proc masonCleanHelp() { - writeln("Cleans the target directory of the mason directory"); - writeln(); - writeln("Usage:"); - writeln(" mason clean [options]"); - writeln(); - writeln("Options:"); - writeln(" -h, --help Display this message"); - writeln(); + const s = """ + Cleans the target directory of the mason directory + + Usage: + mason clean [options] + + Options: + -h, --help Display this message + """.dedent().strip(); + writeln(s); } proc masonPublishHelp(){ - writeln("Publish a package to the mason-registry repository"); - writeln(); - writeln("Usage:"); - writeln(" mason publish [options] "); - writeln(); - writeln("Options:"); - writeln(' Positional argument indicates the target registry. Defaults to chapel-lang/mason-registry'); - writeln(" -h, --help Display this message"); - writeln(" -c, --create-registry Creates a local registry at path"); - writeln(' --dry-run Check to see if package is ready to be published'); - writeln(' --check Runs check to see if package can be published successfully to '); - writeln(' --ci-check Same as --check, except omits git origin checks'); - writeln(' --[no-]update [Do not] Prevent registries from being updated when a package is published'); - writeln(' --refresh-licenses Force-update the list of valid license names and immediately exit without publishing'); - writeln(); - writeln('Publishing requires the mason-registry to be forked and the package to have a remote origin.'); + const s = """ +Publish a package to the mason-registry repository + +Usage: + mason publish [options] + +Options: + Positional argument indicates the target + registry. + Defaults to chapel-lang/mason-registry + -h, --help Display this message + -c, --create-registry Creates a local registry at path + --dry-run Check to see if package is ready to be + published + --check Runs check to see if package can be published + successfully to + --ci-check Same as --check, except omits git origin checks + --[no-]update [Do not] Prevent registries from being updated + when a package is published + --refresh-licenses Force-update the list of valid license names + and immediately exit without publishing + +Publishing requires the mason-registry to be forked and the package to have a +remote origin. + """.dedent().strip(); + writeln(s); } proc masonDocHelp() { - writeln("Generate documentation for a mason package using chpldoc"); - writeln(); - writeln('Usage:'); - writeln(' mason doc [options]'); - writeln(); - writeln('Options:'); - writeln(" -h, --help Display this message"); - writeln(); - writeln("Will generate documentation when ran inside a mason package."); - writeln("Requires that chpldoc is set up in order to work."); - writeln("For instructions on setting up chpldoc, please view its documentation."); - writeln(); + const s = """ + Generate documentation for a mason package using chpldoc + + Usage: + mason doc [options] + + Options: + -h, --help Display this message + + Will generate documentation when ran inside a mason package. + Requires that chpldoc is set up in order to work. + For instructions on setting up chpldoc, please view its documentation. + """.dedent().strip(); + writeln(s); } proc masonModulesHelp() { From d1f92b87d0e3609a73ab00185f90da6ec9e2852e Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 30 Jan 2026 19:47:37 +0100 Subject: [PATCH 15/19] refactor regex for clarity Signed-off-by: Jade Abraham --- tools/mason/MasonModify.chpl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/mason/MasonModify.chpl b/tools/mason/MasonModify.chpl index 326d2c8ef848..aa8121f085f4 100644 --- a/tools/mason/MasonModify.chpl +++ b/tools/mason/MasonModify.chpl @@ -253,9 +253,10 @@ proc generateToml(toml: borrowed Toml, tomlPath: string) { } proc checkVersion(version: string) throws { - -// const pattern = compile("([0-9].[0-9].[0-9][a-zA-Z]?)"); - const pattern = new regex("""^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$"""); + const BASENUMS = "([0-9]+)\\.([0-9]+)\\.([0-9]+)"; + const DASH = "(?:-([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)"; + const PLUS = "(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*)?)"; + const pattern = new regex("^" + BASENUMS + DASH + PLUS + "$"); if !pattern.match(version) { throw new owned MasonError("Version formatting incorrect. ex. 1.2.3"); } From b112b5bc592bf4643db3f385f50ea6d911513746 Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 30 Jan 2026 19:50:25 +0100 Subject: [PATCH 16/19] more lints Signed-off-by: Jade Abraham --- tools/mason/MasonBuild.chpl | 17 ++++----- tools/mason/MasonExternal.chpl | 6 ++-- tools/mason/MasonModify.chpl | 65 +++++++++++++++++----------------- tools/mason/MasonPublish.chpl | 10 ++---- tools/mason/MasonUpdate.chpl | 7 ++-- 5 files changed, 49 insertions(+), 56 deletions(-) diff --git a/tools/mason/MasonBuild.chpl b/tools/mason/MasonBuild.chpl index 853175582ba8..fde52e578e5b 100644 --- a/tools/mason/MasonBuild.chpl +++ b/tools/mason/MasonBuild.chpl @@ -170,14 +170,12 @@ proc buildProgram(release: bool, show: bool, force: bool, skipUpdate: bool, var compopts = cmdLineCompopts; compopts.pushBack(getTomlCompopts(lockFile)); // Compile Program - if compileSrc(lockFile, binLoc, show, release, compopts, projectHome) { + if compileSrc(lockFile, binLoc, release, compopts, projectHome) { writeln("Build Successful\n"); + } else { + throw new MasonError("Build Failed"); } - else { - throw new owned MasonError("Build Failed"); - } - } - else { + } else { writeln("Skipping Build... No changes to project"); } } @@ -187,7 +185,7 @@ proc buildProgram(release: bool, show: bool, force: bool, skipUpdate: bool, folder. Requires that the main library file be named after the project folder in which it is contained */ -proc compileSrc(lockFile: borrowed Toml, binLoc: string, show: bool, +proc compileSrc(lockFile: borrowed Toml, binLoc: string, release: bool, compopts: list(string), projectHome: string) : bool throws { @@ -202,9 +200,8 @@ proc compileSrc(lockFile: borrowed Toml, binLoc: string, show: bool, const moveTo = Path.joinPath(projectHome, 'target', binLoc, project); if !isFile(pathToProj) { - throw new owned MasonError("Mason could not find your project"); - } - else { + throw new MasonError("Mason could not find your project"); + } else { log.debugln("Starting to create compilation command"); var cmd: list(string); diff --git a/tools/mason/MasonExternal.chpl b/tools/mason/MasonExternal.chpl index 0ebe35d5a086..3875e499569a 100644 --- a/tools/mason/MasonExternal.chpl +++ b/tools/mason/MasonExternal.chpl @@ -180,15 +180,15 @@ private proc specHelp() { /* Checks if updated spack and spack registry is installed*/ proc spackInstalled() throws { if !isDir(SPACK_ROOT) { - throw new owned MasonError("To use mason external, call: mason external --setup"); + throw new MasonError("To use mason external, call: mason external --setup"); } if !isDir(getSpackRegistry) { - throw new owned MasonError("Mason has been updated. To use mason external, " + throw new MasonError("Mason has been updated. To use mason external, " + "call: mason external --setup"); } // if local spack version is lower than required version if getSpackVersion() < minSpackVersion && SPACK_ROOT == spackDefaultPath { - throw new owned MasonError("Mason has been updated and requires a newer " + + throw new MasonError("Mason has been updated and requires a newer " + "version of Spack (%s).".format(minSpackVersion.str()) + "\nTo use mason external, call: mason external --setup"); } diff --git a/tools/mason/MasonModify.chpl b/tools/mason/MasonModify.chpl index aa8121f085f4..a18c841e43f8 100644 --- a/tools/mason/MasonModify.chpl +++ b/tools/mason/MasonModify.chpl @@ -71,7 +71,8 @@ proc modifyToml(add: bool, spec: string, external: bool, system: bool, // Adding a dependency if add { if spec.find("@") == -1 { - throw new owned MasonError("Dependency formatted incorrectly.\nFormat: package@version"); + throw new MasonError("Dependency formatted incorrectly.\n"+ + "Format: package@version"); } const split = spec.split('@'); const dependency = split[0]; @@ -84,11 +85,12 @@ proc modifyToml(add: bool, spec: string, external: bool, system: bool, } if system && add { - writeln(" ".join("Adding system dependency", dependency, "version", version)); + writeln("Adding system dependency", dependency, + "version", version, sep=" "); newToml = masonSystemAdd(toml, dependency, version); } else if external && add { - writeln(" ".join("Adding external dependency with spec", spec)); + writeln("Adding external dependency with spec", spec, sep=" "); newToml = masonExternalAdd(toml, dependency, spec); } else { @@ -99,14 +101,15 @@ proc modifyToml(add: bool, spec: string, external: bool, system: bool, // Ensure path exists to maintain compatibility with old // versions of TOML files which did not require the type tag. - if depToml.pathExists("brick.type") { - if depToml["brick.type"]!.s != "library" { - throw new owned MasonError("Only mason libraries can be added as dependencies"); - } + if depToml.pathExists("brick.type") && + depToml["brick.type"]!.s != "library" { + throw new MasonError("Only mason libraries can be " + + "added as dependencies"); } } - writeln(" ".join("Adding Mason dependency", dependency, "version", version)); + writeln("Adding Mason dependency", dependency, + "version", version, sep=" "); newToml = masonAdd(toml, dependency, version); } } @@ -139,12 +142,13 @@ proc modifyToml(add: bool, spec: string, external: bool, system: bool, } /* Add a mason dependency to Mason.toml */ -private proc masonAdd(toml: shared Toml, toAdd: string, version: string) throws { +private proc masonAdd(toml: shared Toml, + toAdd: string, version: string) throws { if toml.pathExists("dependencies") { if toml.pathExists("dependencies." + toAdd) { - throw new owned MasonError("A dependency by that name already exists in Mason.toml"); - } - else { + throw new MasonError("A dependency by that name already " + + "exists in Mason.toml"); + } else { toml["dependencies"]!.set(toAdd, version); } } @@ -169,13 +173,14 @@ private proc masonRemove(toml: shared Toml, toRm: string) throws { } /* Add a system dependency to Mason.toml */ -private proc masonSystemAdd(toml: shared Toml, toAdd: string, version: string) throws { +private proc masonSystemAdd(toml: shared Toml, + toAdd: string, version: string) throws { if toml.pathExists("system") { if toml.pathExists("system." + toAdd) { - throw new MasonError("A dependency by that name already exists in Mason.toml"); - } - else { + throw new MasonError("A dependency by that name already " + + "exists in Mason.toml"); + } else { toml["system"]!.set(toAdd, version); } } @@ -194,13 +199,11 @@ private proc masonSystemRemove(toml: shared Toml, toRm: string) throws { if toml.pathExists("system." + toRm) { var old = toml["system"]![toRm]!; toml["system"]!.A.remove(toRm); + } else { + throw new MasonError("No system dependency exists by " + toRm); } - else { - throw new owned MasonError("No system dependency exists by " + toRm); - } - } - else { - throw new owned MasonError("No system dependency exists by " + toRm); + } else { + throw new MasonError("No system dependency exists by " + toRm); } return toml; } @@ -212,12 +215,10 @@ private proc masonExternalAdd(toml: shared Toml, if toml.pathExists("external." + toAdd) { throw new MasonError("An external dependency by that name " + "already exists in Mason.toml"); - } - else { + } else { toml["external"]!.set(toAdd, spec); } - } - else { + } else { var exdom: domain(string, parSafe=false); var exdeps: [exdom] shared Toml?; toml.set("external", exdeps); @@ -232,12 +233,10 @@ private proc masonExternalRemove(toml: shared Toml, toRm: string) throws { if toml.pathExists("external." + toRm) { var old = toml["external"]![toRm]!; toml["external"]!.A.remove(toRm); - } - else { + } else { throw new owned MasonError("No external dependency exists by that name"); } - } - else { + } else { throw new owned MasonError("No external dependency exists by that name"); } return toml; @@ -258,13 +257,13 @@ proc checkVersion(version: string) throws { const PLUS = "(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*)?)"; const pattern = new regex("^" + BASENUMS + DASH + PLUS + "$"); if !pattern.match(version) { - throw new owned MasonError("Version formatting incorrect. ex. 1.2.3"); + throw new MasonError("Version formatting incorrect. ex. 1.2.3"); } } private proc checkDepName(dep: string) throws { if !isIdentifier(dep) { - throw new owned MasonError("Bad package name '" + dep + - "' - only Chapel identifiers are legal package names"); + throw new MasonError("Bad package name '" + dep + + "' - only Chapel identifiers are legal package names"); } } diff --git a/tools/mason/MasonPublish.chpl b/tools/mason/MasonPublish.chpl index e578c9b1d281..c6aabf6c4111 100644 --- a/tools/mason/MasonPublish.chpl +++ b/tools/mason/MasonPublish.chpl @@ -38,14 +38,8 @@ import Path; from command line. If --dry-run is passed then it checks to see if the package is able to be published. Takes in the username of the package owner as an argument - */ -proc masonPublish(args: [] string) { - var listArgs: list(string); - for x in args do listArgs.pushBack(x); - masonPublish(listArgs); -} - -proc masonPublish(ref args: list(string)) throws { +*/ +proc masonPublish(args: [] string) throws { var parser = new argumentParser(helpHandler=new MasonPublishHelpHandler()); diff --git a/tools/mason/MasonUpdate.chpl b/tools/mason/MasonUpdate.chpl index 9ecd64f4c0dd..5da41b0c9e32 100644 --- a/tools/mason/MasonUpdate.chpl +++ b/tools/mason/MasonUpdate.chpl @@ -152,7 +152,8 @@ proc checkRegistryChanged() { return; } - const oldRegistry = gitC(cached, "git config --get remote.origin.url", quiet=true).strip(); + const oldRegistry = + gitC(cached, "git config --get remote.origin.url", quiet=true).strip(); if oldRegistry != registry { writeln("MASON_REGISTRY changed since last update:"); @@ -285,7 +286,9 @@ private proc createDepTree(root: Toml) throws { if brick.pathExists("dependencies") { for item in brick["dependencies"]!.arr { const brick = depTree[item!.s]!; - item!.s = brick["name"]!.s + " " + brick["version"]!.s + " " + brick["source"]!.s; + item!.s = brick["name"]!.s + " " + + brick["version"]!.s + " " + + brick["source"]!.s; } } } From e6ba892c59bba5ced0d71bf1f76a2a57b4c6bdc5 Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 30 Jan 2026 19:56:04 +0100 Subject: [PATCH 17/19] change name of versionInfo Signed-off-by: Jade Abraham --- tools/mason/MasonExternal.chpl | 6 ++-- tools/mason/MasonNew.chpl | 8 ++--- tools/mason/MasonUpdate.chpl | 11 +++--- tools/mason/MasonUtils.chpl | 62 +++++++++++++++++----------------- 4 files changed, 41 insertions(+), 46 deletions(-) diff --git a/tools/mason/MasonExternal.chpl b/tools/mason/MasonExternal.chpl index 3875e499569a..513780b43db1 100644 --- a/tools/mason/MasonExternal.chpl +++ b/tools/mason/MasonExternal.chpl @@ -33,7 +33,7 @@ use TOML; var log = new logger("mason external"); // We could consider bumping this version up as needed. -const minSpackVersion = new VersionInfo('1.0.0'); +const minSpackVersion = new versionInfo('1.0.0'); const major = minSpackVersion.major:string; const minor = minSpackVersion.minor:string; const spackBranch = 'releases/v' + '.'.join(major, minor); @@ -285,7 +285,7 @@ private proc printSpackVersion() { } /* Returns spack version */ -proc getSpackVersion() : VersionInfo { +proc getSpackVersion(): versionInfo { const command = "spack --version"; @functionStatic ref tmpVersion = getSpackResult(command,true).strip(); @@ -294,7 +294,7 @@ proc getSpackVersion() : VersionInfo { // partitioning the string allows us to separate the major.minor.bug // from the remaining values const version = tmpVersion.partition(" "); - return new VersionInfo(version[0]); + return new versionInfo(version[0]); } /* Lists available spack packages */ diff --git a/tools/mason/MasonNew.chpl b/tools/mason/MasonNew.chpl index 123c7d8f2210..959734ba4bf1 100644 --- a/tools/mason/MasonNew.chpl +++ b/tools/mason/MasonNew.chpl @@ -115,13 +115,11 @@ proc previewMasonFile(packageName, version, chapelVersion, license) { // TODO: this function is completely unused - remove or use it? /* Perform validation checks on Chapel Version */ proc validateChplVersion(chapelVersion) throws { - var low, hi : VersionInfo; + var low, hi: versionInfo; const tInfo = getChapelVersionInfo(); - const current = new VersionInfo(tInfo(0), tInfo(1), tInfo(2)); - var ret = false; + const current = new versionInfo(tInfo(0), tInfo(1), tInfo(2)); (low, hi) = checkChplVersion(chapelVersion, low, hi); - ret = low <= current && current <= hi; - if !ret { + if !(low <= current && current <= hi) { throw new MasonError("Your current Chapel version ( " + getChapelVersionStr() + " ) is not compatible with this chplVersion."); diff --git a/tools/mason/MasonUpdate.chpl b/tools/mason/MasonUpdate.chpl index 5da41b0c9e32..de95314997fd 100644 --- a/tools/mason/MasonUpdate.chpl +++ b/tools/mason/MasonUpdate.chpl @@ -202,13 +202,10 @@ proc updateRegistry(skipUpdate: bool, show=true) throws { proc verifyChapelVersion(brick:borrowed Toml) { const tupInfo = getChapelVersionInfo(); - const current = new VersionInfo(tupInfo(0), tupInfo(1), tupInfo(2)); - var low, hi : VersionInfo; - - var ret = false; - - (low, hi) = parseChplVersion(brick); - ret = low <= current && current <= hi; + const current = new versionInfo(tupInfo(0), tupInfo(1), tupInfo(2)); + + var (low, hi) = parseChplVersion(brick); + var ret = low <= current && current <= hi; return (ret, low, hi); } diff --git a/tools/mason/MasonUtils.chpl b/tools/mason/MasonUtils.chpl index ef448c0972ef..eb23c91dc06a 100644 --- a/tools/mason/MasonUtils.chpl +++ b/tools/mason/MasonUtils.chpl @@ -287,7 +287,7 @@ proc runSpackCommand(command, quiet=false) { } // TODO: Can we get away with the Chapel Version object instead? -record VersionInfo { +record versionInfo { var major = -1, minor = -1, bug = 0; proc init() { @@ -296,20 +296,20 @@ record VersionInfo { bug = 0; } - proc init=(other:VersionInfo) { + proc init=(other: versionInfo) { this.major = other.major; this.minor = other.minor; this.bug = other.bug; } - proc init(maj : int, min : int, bug: int) { + proc init(maj: int, min: int, bug: int) { this.major = maj; this.minor = min; this.bug = bug; } - proc init(str:string) { - const s : [1..3] string = str.split("."); + proc init(str: string) { + const s: [1..3] string = str.split("."); assert(s.size == 3); major = s[1]:int; @@ -321,7 +321,7 @@ record VersionInfo { return major:string + "." + minor:string + "." + bug:string; } - proc cmp(other:VersionInfo) { + proc cmp(other: versionInfo) { const A = (major, minor, bug); const B = (other.major, other.minor, other.bug); for i in 0..2 { @@ -340,7 +340,7 @@ record VersionInfo { when 2 do return this.bug; otherwise - halt('Out of bounds access of VersionInfo'); + halt('Out of bounds access of versionInfo'); } } @@ -350,7 +350,7 @@ record VersionInfo { this.bug == max(int); } - proc isCompatible(other:VersionInfo) : bool { + proc isCompatible(other: versionInfo) : bool { // checks that a version is compatible with this version // versions are assumed compatible if major and minor versions match // and patch/bug level is the same or greater @@ -359,41 +359,41 @@ record VersionInfo { && this.bug <= other.bug; } - proc type zero() : VersionInfo { - return new VersionInfo(0, 0, 0); + proc type zero(): versionInfo { + return new versionInfo(0, 0, 0); } } -operator VersionInfo.=(ref lhs:VersionInfo, const ref rhs:VersionInfo) { +operator versionInfo.=(ref lhs: versionInfo, const ref rhs: versionInfo) { lhs.major = rhs.major; lhs.minor = rhs.minor; lhs.bug = rhs.bug; } -operator VersionInfo.>=(a:VersionInfo, b:VersionInfo) : bool { +operator versionInfo.>=(a: versionInfo, b: versionInfo) : bool { return a.cmp(b) >= 0; } -operator VersionInfo.<=(a:VersionInfo, b:VersionInfo) : bool { +operator versionInfo.<=(a: versionInfo, b: versionInfo) : bool { return a.cmp(b) <= 0; } -operator ==(a:VersionInfo, b:VersionInfo) : bool { +operator ==(a: versionInfo, b: versionInfo) : bool { return a.cmp(b) == 0; } -operator VersionInfo.>(a:VersionInfo, b:VersionInfo) : bool { +operator versionInfo.>(a: versionInfo, b: versionInfo) : bool { return a.cmp(b) > 0; } -operator VersionInfo.<(a:VersionInfo, b:VersionInfo) : bool { +operator versionInfo.<(a: versionInfo, b: versionInfo) : bool { return a.cmp(b) < 0; } -private var chplVersionInfo = new VersionInfo(-1, -1, -1); +private var chplVersionInfo = new versionInfo(-1, -1, -1); /* Returns a tuple containing information about the `chpl --version`: (major, minor, bugFix, isMain) */ -proc getChapelVersionInfo(): VersionInfo throws { +proc getChapelVersionInfo(): versionInfo throws { use Regex; if chplVersionInfo(0) == -1 { @@ -421,7 +421,7 @@ proc getChapelVersionInfo(): VersionInfo throws { } const split = semver.split("."); - chplVersionInfo = new VersionInfo(split[0]:int, split[1]:int, split[2]:int); + chplVersionInfo = new versionInfo(split[0]:int, split[1]:int, split[2]:int); } return chplVersionInfo; @@ -626,7 +626,7 @@ proc getProjectType(): string throws { record package { var name: string; - var version: VersionInfo; + var version: versionInfo; var registry: string; proc brickPath() { @@ -635,7 +635,7 @@ record package { } proc type nullPackage() { - return new package("", VersionInfo.zero(), ""); + return new package("", versionInfo.zero(), ""); } operator <(a: package, b: package) : bool { @@ -690,7 +690,7 @@ proc searchDependencies(pattern: regex(string)): list(package) throws { log.debugln("found hidden package: " + name); } else { const ver = findLatest(joinPath(searchDir, dir)); - if ver != VersionInfo.zero() { + if ver != versionInfo.zero() { pkgs.pushBack(new package(name, ver, registry)); } } @@ -731,10 +731,10 @@ proc getDepToml(depName: string, depVersion: string) throws { /* Search TOML files within a package directory to find the latest package version number that is supported with current Chapel version */ -proc findLatest(packageDir: string): VersionInfo { +proc findLatest(packageDir: string): versionInfo { use Path; - var ret = VersionInfo.zero(); + var ret = versionInfo.zero(); const suffix = ".toml"; const packageName = basename(packageDir); for manifest in listDir(packageDir, files=true, dirs=false) { @@ -757,7 +757,7 @@ proc findLatest(packageDir: string): VersionInfo { // Check that Chapel version is supported const end = manifest.size - suffix.size; - const ver = new VersionInfo(manifest[0.. ret then ret = ver; } return ret; @@ -765,7 +765,7 @@ proc findLatest(packageDir: string): VersionInfo { /* Reads the Chapel version specified by a mason project's TOML file and returns the min and max compatible versions */ -proc parseChplVersion(brick: borrowed Toml?): (VersionInfo, VersionInfo) { +proc parseChplVersion(brick: borrowed Toml?): (versionInfo, versionInfo) { use Regex; if brick == nil { @@ -786,7 +786,7 @@ proc parseChplVersion(brick: borrowed Toml?): (VersionInfo, VersionInfo) { } const chplVersion = brick!["chplVersion"]!.s; - var low, high: VersionInfo; + var low, high: versionInfo; try { (low, high) = checkChplVersion(chplVersion); @@ -805,7 +805,7 @@ proc parseChplVersion(brick: borrowed Toml?): (VersionInfo, VersionInfo) { a tuple of the low, high supported verisons.*/ proc checkChplVersion(chplVersion) throws { use Regex; - var lo, hi : VersionInfo; + var lo, hi : versionInfo; const formatMessage = "\n\n" + "chplVersion format must be '..' or ''\n" + "A must be in one of the following formats:\n" + @@ -825,8 +825,8 @@ proc checkChplVersion(chplVersion) throws { formatMessage); } - proc parseString(ver:string): VersionInfo throws { - var ret : VersionInfo; + proc parseString(ver:string): versionInfo throws { + var ret : versionInfo; // Finds 'x.x' or 'x.x.x' where x is a positive number const pattern = new regex("^(\\d+\\.\\d+(\\.\\d+)?)$"); @@ -846,7 +846,7 @@ proc checkChplVersion(chplVersion) throws { lo = parseString(versions[0]); if versions.size == 1 { - hi = new VersionInfo(max(int), max(int), max(int)); + hi = new versionInfo(max(int), max(int), max(int)); } else { hi = parseString(versions[1]); } From 1d68e56e1efe6297ed05d0fe89dc3e6f9318272e Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 30 Jan 2026 19:59:29 +0100 Subject: [PATCH 18/19] cleanup unused formals Signed-off-by: Jade Abraham --- tools/mason/MasonPublish.chpl | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/tools/mason/MasonPublish.chpl b/tools/mason/MasonPublish.chpl index c6aabf6c4111..1cd4aedbb841 100644 --- a/tools/mason/MasonPublish.chpl +++ b/tools/mason/MasonPublish.chpl @@ -123,9 +123,9 @@ proc masonPublish(args: [] string) throws { } if checkFlag || ci { - if ci then check(username, registryPath, isLocal, ci); + if ci then check(registryPath, ci); else { - check(username, registryPath, isLocal, ci); + check(registryPath, ci); } } @@ -242,7 +242,7 @@ proc publishPackage(username: string, if !isLocal { cloneMasonReg(username, safeDir, registryPath); - branchMasonReg(username, name, safeDir, registryPath); + branchMasonReg(name, safeDir); } const version = addPackageToBricks(packageLocation, safeDir, name, isLocal); @@ -406,8 +406,7 @@ private proc gitUrl() { Takes the git username and creates a new branch of the mason registry users fork, name or branch is taken from the Mason.toml of the mason package. */ -proc branchMasonReg(username: string, name: string, - safeDir: string, registryPath : string) throws { +proc branchMasonReg(name: string, safeDir: string) throws { try! { const branchCommand = "git checkout --quiet -b "+ name: string; var ret = gitC(safeDir + '/mason-registry', branchCommand, false); @@ -506,7 +505,7 @@ private proc addPackageToBricks(projectLocal: string, safeDir: string, registry path, and other issues that may prevent a package from being published to a registry. */ -proc check(username: string, path: string, trueIfLocal: bool, ci: bool) throws { +proc check(path: string, ci: bool) throws { const spacer = '------------------------------------------------------'; const package = (ensureMasonProject(here.cwd(), 'Mason.toml') == 'true'); const projectCheckHome = here.cwd(); @@ -525,8 +524,7 @@ proc check(username: string, path: string, trueIfLocal: bool, ci: bool) throws { writeln(' Could not find your configuration file (Mason.toml) (FAILED)'); writeln(' Ensure your project is a mason package'); packageTest = false; - } - else { + } else { writeln(' Package is a Mason package and has a Mason.toml (PASSED)'); } writeln(spacer); @@ -536,8 +534,7 @@ proc check(username: string, path: string, trueIfLocal: bool, ci: bool) throws { if moduleCheck(projectCheckHome) { writeln(' Your package has one main module whose name matches ' + 'the package name. (PASSED)'); - } - else { + } else { writeln(' Packages must have a single main module whose name matches ' + 'the package name. (FAILED)'); moduleTest = false; @@ -630,8 +627,7 @@ proc check(username: string, path: string, trueIfLocal: bool, ci: bool) throws { writeln(' Package has a git remote origin and can be published ' + 'to a remote registry (PASSED)'); writeln(' Remote Origin: ' + getRemoteOrigin()); - } - else { + } else { writeln(' Package has no remote origin and cannot be publish to a ' + 'registry with path:' + path + ' (FAILED)'); remoteTest = false; @@ -666,8 +662,7 @@ proc check(username: string, path: string, trueIfLocal: bool, ci: bool) throws { if packageTest && remoteTest && moduleTest && testTest && licenseTest && gitTagTest && masonFieldsTest { writeln('(PASSED) Your package is ready to publish'); - } - else { + } else { if !packageTest { writeln( '(FAILED) Your package does not have to proper package structure'); From 19dc6c6817b7deb9d2931316d8bb278179a2e52d Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Fri, 30 Jan 2026 20:04:42 +0100 Subject: [PATCH 19/19] remove space Signed-off-by: Jade Abraham --- tools/mason/MasonUpdate.chpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/mason/MasonUpdate.chpl b/tools/mason/MasonUpdate.chpl index de95314997fd..aec42f396776 100644 --- a/tools/mason/MasonUpdate.chpl +++ b/tools/mason/MasonUpdate.chpl @@ -203,7 +203,7 @@ proc updateRegistry(skipUpdate: bool, show=true) throws { proc verifyChapelVersion(brick:borrowed Toml) { const tupInfo = getChapelVersionInfo(); const current = new versionInfo(tupInfo(0), tupInfo(1), tupInfo(2)); - + var (low, hi) = parseChplVersion(brick); var ret = low <= current && current <= hi;