Skip to content

Commit

Permalink
Merge pull request #16602 from ben-albrecht/mason-no-deps-bug-fix
Browse files Browse the repository at this point in the history
Fix mason bug that occurred Mason.toml has no dependencies table

Fix a regression where lacking a `[dependencies]` table produced an error during `mason update` (called by `mason build`, `mason test`, etc.)

Also, added a test for this behavior.

- [x] local testing of `test/mason`

[Reviewed by @daviditen]
  • Loading branch information
ben-albrecht committed Oct 20, 2020
2 parents 6867568 + d410936 commit 5a3d7ab
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 2 deletions.
1 change: 1 addition & 0 deletions test/mason/build/CLEANFILES
1 change: 1 addition & 0 deletions test/mason/build/COMPOPTS
1 change: 1 addition & 0 deletions test/mason/build/EXECENV
1 change: 1 addition & 0 deletions test/mason/build/SKIPIF
Empty file added test/mason/build/_noDeps.notest
Empty file.
2 changes: 2 additions & 0 deletions test/mason/build/_noDeps/.gitignore
@@ -0,0 +1,2 @@
target/
Mason.lock
6 changes: 6 additions & 0 deletions test/mason/build/_noDeps/Mason.toml
@@ -0,0 +1,6 @@
[brick]
name = "noDeps"
version = "0.1.0"
chplVersion = "1.24.0"
license = "None"

4 changes: 4 additions & 0 deletions test/mason/build/_noDeps/src/noDeps.chpl
@@ -0,0 +1,4 @@
/* Documentation for noDeps */
module noDeps {
writeln("New library: noDeps");
}
24 changes: 24 additions & 0 deletions test/mason/build/noDeps.chpl
@@ -0,0 +1,24 @@
/* Test a package with Manifest.toml without [dependencies] table */
use MasonBuild;
use MasonNew;
use MasonUtils;

use FileSystem;
use SysCTypes;

extern proc setenv(name : c_string, envval : c_string, overwrite : c_int) : c_int;

// chdir and reset PWD env (some mason internals rely on this)
proc changeDir(relPath: string) {
const oldPWD = getEnv('PWD');
here.chdir(relPath);
const newPWD = '/'.join(oldPWD, relPath);
setenv("PWD", newPWD.c_str(), 1);
}

proc main() {
const package = '_noDeps';
changeDir(package);
const args = ["mason", "build"];
masonBuild(args);
}
1 change: 1 addition & 0 deletions test/mason/build/noDeps.cleanfiles
@@ -0,0 +1 @@
_noDeps/target
4 changes: 4 additions & 0 deletions test/mason/build/noDeps.good
@@ -0,0 +1,4 @@
Skipping registry update since no dependency found in manifest file.
Compiling [debug] target: noDeps
Build Successful

12 changes: 10 additions & 2 deletions tools/mason/MasonUpdate.chpl
Expand Up @@ -86,9 +86,17 @@ proc updateLock(skipUpdate: bool, tf="Mason.toml", lf="Mason.lock") {
const lockPath = projectHome + "/" + lf;
const openFile = openreader(tomlPath);
const TomlFile = parseToml(openFile);
var updated = false;
if isFile(tomlPath) {
if TomlFile['dependencies']!.A.size > 0 then updateRegistry(skipUpdate);
else writeln("Skipping registry update since no dependency found in manifest file.");
if TomlFile.pathExists('dependencies') {
if TomlFile['dependencies']!.A.size > 0 {
updateRegistry(skipUpdate);
updated = true;
}
}
if !updated {
writeln("Skipping registry update since no dependency found in manifest file.");
}
}
if isDir(SPACK_ROOT) && TomlFile.pathExists('external') {
if getSpackVersion != spackVersion then
Expand Down

0 comments on commit 5a3d7ab

Please sign in to comment.