New Rule: Check that filename matches module/interface/package/program identifier.
Modules, interfaces, packages, and programs are often requried to be declared in their own file.
A new set of rules should check, for example, that module Foo; ... endmodule lives in some/path/to/Foo.sv.
Hello, I was trying to work on this issue but I ran into an issue with grabbing the file names. As far as I can find, none of the nodes seem to contain the filename information.
I was wondering if you have any pointers/know where I should look?
let path = if let Some(x) = unwrap_locate!(node.clone()) {
if let Some((path, _)) = syntax_tree.get_origin(&x) {
Some(path)
} else {
None
}
I got the file path from the Syntax tree, however, I am unable to get Cargo Test to pass the testcases.
As far as my understanding goes, Cargo Test modifies the input file name that is passed to the syntax rule checker. Printing out the file name:
./svlint/target/debug/build/svlint-0484465ec2310bbe/out/syntaxrules.identifier_matches_filename.pass.1of1.sv
For the pass testcase (in pass/identifier_matches_filename.sv), I have
module identifier_matches_filename;
endmodule
However, this fails, due to the editing of the filename prior to running by cargo test. Furthermore, it doesn't seem like I can edit the filename in any way for it to pass due to the periods (.) in the filename. That is to say, I cannot modify the pass testcase to be
module syntaxrules.identifier_matches_filename.pass.1of1;
endmodule
due to this being an invalid module name.
I modified build.rs (Line :380) to change the periods in the filename to underscores. This makes syntaxrules_identifier_matches_filename_pass_1of1 a valid module name and cargo test now passes for all testcases.
This is one option. Alternatively, I could turn off that specific testcase, if there is a reason for wanting to keep the periods in the test suite filenames.