Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gnattest: Issues with --ignore argument #17

Open
tobiasbrunner opened this issue Jun 1, 2021 · 0 comments
Open

gnattest: Issues with --ignore argument #17

tobiasbrunner opened this issue Jun 1, 2021 · 0 comments

Comments

@tobiasbrunner
Copy link

I noticed two issues with the --ignore argument:

  • The code here doesn't correctly determine the number of files and sets the counter to a potentially too low number:
    N_File_Names : constant Natural :=
    Num_File_Names (Cmd) - Arg_Length (Cmd, Ignore);
    Counter : Natural := N_File_Names;

    Which can trigger a CONSTRAINT_ERROR here:
    Counter := Counter - 1;

    Arg_Length (Cmd, Ignore) returns the number of files passed via --ignore arguments, not the number of files listed in those files, which might have been the intention. The exception is triggered if more --ignore arguments are passed than files are eventually ignored (can be reproduced by e.g. passing an empty ignore file or one that lists files that don't exist, or by passing the same file that lists a single existing file twice). What's more, if the code were to actually reduce the number of files by the number of those listed in all ignore files, it could still trigger the same error as it assumes all the ignored files actually exist and can be skipped in the loop.
  • I didn't realize this before, but apparently gnattest always only compared the file name of ignored files, never the path. However, in previous versions, the base name/directory of all paths listed in files passed via --ignore was stripped, so the list/set of ignored files only contained the file names. Therefore, even if a relative path was listed, this worked correctly. The problem is that this version of gnattest doesn't remove the base name anymore, so if a relative path is listed, there won't be a match (which in my case triggered the above error as only a single file was ignored via its relative path).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant