Hello, I had a question about project file structure for a Chapel library. I’m confident I have the src directory structure working, per the great discussion in Importing files from subfolders . I’m assuming:
As a quick response, I wouldn't be surprised at all if UnitTest or mason test has some gaps w.r.t. walking a directory tree the same way our compiler does.
is that best practice?
Today, that's the case. In my Mason packages, I have flat structure and that line in all of the files. That's not to say that we should be satisfied with that, though.
Thank you Engin. I also noticed with the VSCode extension, where you can run the tests directly in the editor, I believe it needs UnitTest.main in each file or it can’t run the tests (it could “Run All” from my MyLibraryTest.chpl but not individual tests from the submodule tests).
Hmm, that could be the extension inheriting the behavior from UnitTest. But I'll tag @jabraham to make sure that they see it and in case there is an issue with the extension.
That's correct, each file needs its own UnitTest.main. If you have a single UnitTest.main and include multiple files with tests of their own, mason should understand that fine, but the VSCode extension won't. But this is definitely on the roadmap as future work
Thanks you both, flattening the test structure allows VS code tests to run individually. Structured now like:
module MyLibrary {
include module Submodule1;
include module Submodule2;
public import this.Submodule1;
public import this.Submodule2;
}
with
module Submodule1Test {
use UnitTest;
import MyLibrary.Submodule1;
// ...
}
allowed tests to run in both the editor and with mason test. But the import MyLibrary.Submodule1Test still had a red squiggly saying MyLibrary couldn’t be found, but guess it’s not a problem.
Thats due to chpl-language-server in VSCode not being able to understand your project structure, whereas mason understands it out of the box. Its not a problem, its just a visual thing. But you can resolve it.