vppapigen: handle new api file for crcchekcer 37/27137/1
authorOle Troan <ot@cisco.com>
Tue, 19 May 2020 10:33:00 +0000 (12:33 +0200)
committerOle Troan <ot@cisco.com>
Tue, 19 May 2020 11:32:47 +0000 (13:32 +0200)
Type: fix
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: I1b3ae8b348eb3cba628a55ea3e72e85b9a4288d5

extras/scripts/tests/test_crcchecker.sh
src/tools/vppapigen/vppapigen.py

index 7cfda08..e275bd9 100755 (executable)
@@ -129,6 +129,17 @@ verify_check_patchset_fails
 # get rid of the "erroneous" commit in the previous test
 git reset --hard HEAD~1
 
+echo "TEST14: Verify we handle new .api file"
+cat >crccheck3.api <<EOL
+autoreply define foo
+{
+  bool bar;
+};
+EOL
+git add crccheck3.api
+git commit -m "a new message in new file";
+extras/scripts/crcchecker.py --check-patchset
+
 echo "TEST: All tests got the expected result, cleaning up."
 
 # done with all the tests - clean up
index 2d20979..06bfbff 100755 (executable)
@@ -753,8 +753,15 @@ class VPPAPI(object):
     def parse_filename(self, filename, debug=0):
         if self.revision:
             git_show = f'git show  {self.revision}:{filename}'
-            with Popen(git_show.split(), stdout=PIPE, encoding='utf-8') as git:
-                return self.parse_fd(git.stdout, None)
+            proc = Popen(git_show.split(), stdout=PIPE, encoding='utf-8')
+            try:
+                data, errs = proc.communicate()
+                if proc.returncode != 0:
+                    print(f'File not found: {self.revision}:{filename}', file=sys.stderr)
+                    sys.exit(2)
+                return self.parse_string(data, debug=debug)
+            except Exception as e:
+                sys.exit(3)
         else:
             try:
                 with open(filename, encoding='utf-8') as fd: