Commit c656cbb9 by Zachary Snow

fix package and interface warnings in verbose mode

- warnings were skipped because verbose about was technically not empty
- add test suite for these warnings in both modes
parent 5aea0ee9
......@@ -30,15 +30,19 @@ isPackage :: Description -> Bool
isPackage Package{} = True
isPackage _ = False
emptyWarnings :: [AST] -> [AST] -> IO ()
isComment :: Description -> Bool
isComment (PackageItem (Decl CommentDecl{})) = True
isComment _ = False
emptyWarnings :: AST -> AST -> IO ()
emptyWarnings before after =
if all null before || any (not . null) after then
if all isComment before || not (all isComment after) then
return ()
else if any (any isInterface) before then
else if any isInterface before then
hPutStrLn stderr $ "Warning: Source includes an interface but output is"
++ " empty because there is no top-level module which has no ports"
++ " which are interfaces."
else if any (any isPackage) before then
else if any isPackage before then
hPutStrLn stderr $ "Warning: Source includes packages but no modules."
++ " Please convert packages alongside the modules that use them."
else
......@@ -82,7 +86,7 @@ main = do
Right asts -> do
-- convert the files
let asts' = convert (exclude job) asts
emptyWarnings asts asts'
emptyWarnings (concat asts) (concat asts')
-- write the converted files out
writeOutput (write job) (files job) asts'
exitSuccess
interface Interface;
logic x;
endinterface
module Module;
Interface intf();
assign intf.x = Package::X;
endmodule
package Package;
localparam X = 1;
endpackage
#!/bin/bash
PACKAGE_WARNING="Warning: Source includes packages but no modules. Please convert packages alongside the modules that use them."
INTERFACE_WARNING="Warning: Source includes an interface but output is empty because there is no top-level module which has no ports which are interfaces."
test_default() {
runAndCapture *.sv
assertTrue "default conversion should succeed" $result
assertNotNull "stdout should not be empty" "$stdout"
assertNull "stderr should be empty" "$stderr"
}
test_only_package() {
runAndCapture package.sv
assertTrue "conversion should succeed" $result
assertNull "stdout should be empty" "$stdout"
assertEquals "stderr should have warning" "$PACKAGE_WARNING" "$stderr"
}
test_only_package_verbose() {
runAndCapture -v package.sv
assertTrue "conversion should succeed" $result
assertNotNull "stdout should not be empty" "$stdout"
assertEquals "stderr should have warning" "$PACKAGE_WARNING" "$stderr"
}
test_only_interface() {
runAndCapture interface.sv
assertTrue "conversion should succeed" $result
assertNull "stdout should be empty" "$stdout"
assertEquals "stderr should have warning" "$INTERFACE_WARNING" "$stderr"
}
test_only_interface_verbose() {
runAndCapture -v interface.sv
assertTrue "conversion should succeed" $result
assertNotNull "stdout should not be empty" "$stdout"
assertEquals "stderr should have warning" "$INTERFACE_WARNING" "$stderr"
}
source ../lib/functions.sh
. shunit2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment