On Wed, 17 May 2023, Luca Fancellu wrote: > > On 17 May 2023, at 02:33, Stefano Stabellini <sstabell...@kernel.org> wrote: > > > > On Thu, 4 May 2023, Luca Fancellu wrote: > >> Add a feature to the diff-report.py script that improves the comparison > >> between two analysis report, one from a baseline codebase and the other > >> from the changes applied to the baseline. > >> > >> The comparison between reports of different codebase is an issue because > >> entries in the baseline could have been moved in position due to addition > >> or deletion of unrelated lines or can disappear because of deletion of > >> the interested line, making the comparison between two revisions of the > >> code harder. > >> > >> Having a baseline report, a report of the codebase with the changes > >> called "new report" and a git diff format file that describes the > >> changes happened to the code from the baseline, this feature can > >> understand which entries from the baseline report are deleted or shifted > >> in position due to changes to unrelated lines and can modify them as > >> they will appear in the "new report". > >> > >> Having the "patched baseline" and the "new report", now it's simple > >> to make the diff between them and print only the entry that are new. > >> > >> Signed-off-by: Luca Fancellu <luca.fance...@arm.com> > > > > This is an amazing work!! Thanks Luca! > > > > I am having issues trying the new patch feature. After applying this > > patch I get: > > > > sstabellini@ubuntu-linux-20-04-desktop:/local/repos/xen-upstream/xen$ > > ./scripts/diff-report.py > > Traceback (most recent call last): > > File "./scripts/diff-report.py", line 5, in <module> > > from xen_analysis.diff_tool.debug import Debug > > File > > "/local/repos/xen-upstream/xen/scripts/xen_analysis/diff_tool/debug.py", > > line 4, in <module> > > from .report import Report > > File > > "/local/repos/xen-upstream/xen/scripts/xen_analysis/diff_tool/report.py", > > line 4, in <module> > > from .unified_format_parser import UnifiedFormatParser, ChangeSet > > File > > "/local/repos/xen-upstream/xen/scripts/xen_analysis/diff_tool/unified_format_parser.py", > > line 56, in <module> > > class UnifiedFormatParser: > > File > > "/local/repos/xen-upstream/xen/scripts/xen_analysis/diff_tool/unified_format_parser.py", > > line 57, in UnifiedFormatParser > > def __init__(self, args: str | list) -> None: > > TypeError: unsupported operand type(s) for |: 'type' and 'type' > > > > Also got a similar error elsewhere: > > > > sstabellini@ubuntu-linux-20-04-desktop:/local/repos/xen-upstream/xen$ > > ./scripts/diff-report.py --patch ~/p/1 -b /tmp/1 -r /tmp/1 > > Traceback (most recent call last): > > File "./scripts/diff-report.py", line 127, in <module> > > main(sys.argv[1:]) > > File "./scripts/diff-report.py", line 102, in main > > diffs = UnifiedFormatParser(diff_source) > > File > > "/local/repos/xen-upstream/xen/scripts/xen_analysis/diff_tool/unified_format_parser.py", > > line 79, in __init__ > > self.__parse() > > File > > "/local/repos/xen-upstream/xen/scripts/xen_analysis/diff_tool/unified_format_parser.py", > > line 94, in __parse > > def parse_diff_header(line: str) -> ChangeSet | None: > > TypeError: unsupported operand type(s) for |: 'type' and 'NoneType' > > > > My Python is 2.7.18 > > > > > > Am I understanding correctly that one should run the scan for the > > baseline (saving the result somewhere), then apply the patch, run the > > scan again. Finally, one should call diff-report.py passing -b > > baseline-report -r new-report --patch the-patch-applied? > > Hi Stefano, > > Yes indeed, that procedure is correct, I think the error you are seeing comes > from the python version, > I am using python 3, version 3.10.6. > > The error seems to come from python annotations, I’m surprised you didn’t hit > it when testing the first patch, > did you use python2 for that? > > Is it a problem if I developed the tool having in mind its usage with python3?
Hi Luca, It is not a problem per se if the script requires python3 but then we should check for the python version at the beginning of the script to fail explictly with a nice error message if python < 3. I am fine if you want to proceed that way, but if the only issue are the annotations, I suggest it might be easier to remove them and then you also get the benefit of python2 compatibility. I'll leave the choice to you. Either way, if you are OK with it, I think you should add a new entry to the MAINTAINERS file to cover the xen analysis scripts if you are OK with it: xen/scripts/xen_analysis xen/scripts/xen-analysis.py xen/scripts/diff-report.py