-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
make test fails with header_guard error in cpplint #2693
Comments
cpplint expects to be run in a git checkout, it uses the top-level .git directory as the include root. If it doesn't find one, it walks up all the way to the root directory and then you get the errors you're getting. Am I right that the patch below fixes the issue? diff --git a/tools/cpplint.py b/tools/cpplint.py
index 5ab1561..4c4f577 100644
--- a/tools/cpplint.py
+++ b/tools/cpplint.py
@@ -695,37 +695,10 @@ class FileInfo:
locations won't see bogus errors.
"""
fullname = self.FullName()
-
- if os.path.exists(fullname):
- project_dir = os.path.dirname(fullname)
-
- if os.path.exists(os.path.join(project_dir, ".svn")):
- # If there's a .svn file in the current directory, we recursively look
- # up the directory tree for the top of the SVN checkout
- root_dir = project_dir
- one_up_dir = os.path.dirname(root_dir)
- while os.path.exists(os.path.join(one_up_dir, ".svn")):
- root_dir = os.path.dirname(root_dir)
- one_up_dir = os.path.dirname(one_up_dir)
-
- prefix = os.path.commonprefix([root_dir, project_dir])
- return fullname[len(prefix) + 1:]
-
- # Not SVN? Try to find a git or hg top level directory by searching up
- # from the current path.
- root_dir = os.path.dirname(fullname)
- while (root_dir != os.path.dirname(root_dir) and
- not os.path.exists(os.path.join(root_dir, ".git")) and
- not os.path.exists(os.path.join(root_dir, ".hg"))):
- root_dir = os.path.dirname(root_dir)
-
- if (os.path.exists(os.path.join(root_dir, ".git")) or
- os.path.exists(os.path.join(root_dir, ".hg"))):
- prefix = os.path.commonprefix([root_dir, project_dir])
- return fullname[len(prefix) + 1:]
-
- # Don't know what to do; header guard warnings may be wrong...
- return fullname
+ # XXX(bnoordhuis) Expects that cpplint.py lives in the tools/ directory.
+ toplevel = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
+ prefix = os.path.commonprefix([fullname, toplevel])
+ return fullname[len(prefix) + 1:]
def Split(self):
"""Splits the file into the directory, basename, and extension. |
Will try later today and come back with results. Most likely it will judging by what I see in the patch. |
+1 to solving this. I often use the github/release tarballs if I don't have the git repo checked out already and I always run into this during |
Yes, the patch fixes the problem. |
cpplint uses the top-level .git directory to determine what the root is for #include guards. If it doesn't find a .git directory, it walks up all the way to the system root and subsequently complains that guards must be written as HOME_USER_SRC_NODE_SRC_FILENAME_H_. This commit replaces the .git-based path munging with a fixed root path relative to the location of the cpplint script, making it possible to successfully run `make test` from an extracted tarball. Fixes: nodejs#2693 PR-URL: nodejs#2710 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Fixed by a493dab. |
cpplint uses the top-level .git directory to determine what the root is for #include guards. If it doesn't find a .git directory, it walks up all the way to the system root and subsequently complains that guards must be written as HOME_USER_SRC_NODE_SRC_FILENAME_H_. This commit replaces the .git-based path munging with a fixed root path relative to the location of the cpplint script, making it possible to successfully run `make test` from an extracted tarball. Fixes: #2693 PR-URL: #2710 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
cpplint uses the top-level .git directory to determine what the root is for #include guards. If it doesn't find a .git directory, it walks up all the way to the system root and subsequently complains that guards must be written as HOME_USER_SRC_NODE_SRC_FILENAME_H_. This commit replaces the .git-based path munging with a fixed root path relative to the location of the cpplint script, making it possible to successfully run `make test` from an extracted tarball. Fixes: #2693 PR-URL: #2710 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
cpplint uses the top-level .git directory to determine what the root is for #include guards. If it doesn't find a .git directory, it walks up all the way to the system root and subsequently complains that guards must be written as HOME_USER_SRC_NODE_SRC_FILENAME_H_. This commit replaces the .git-based path munging with a fixed root path relative to the location of the cpplint script, making it possible to successfully run `make test` from an extracted tarball. Fixes: #2693 PR-URL: #2710 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
cpplint uses the top-level .git directory to determine what the root is for #include guards. If it doesn't find a .git directory, it walks up all the way to the system root and subsequently complains that guards must be written as HOME_USER_SRC_NODE_SRC_FILENAME_H_. This commit replaces the .git-based path munging with a fixed root path relative to the location of the cpplint script, making it possible to successfully run `make test` from an extracted tarball. Fixes: #2693 PR-URL: #2710 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This reapplies commit a493dab ("cpplint: make it possible to run outside git repo") from September 2015, this time with a proper status line. PR-URL: nodejs#7462 Refs: nodejs#2693 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This reapplies commit a493dab ("cpplint: make it possible to run outside git repo") from September 2015, this time with a proper status line. PR-URL: nodejs#7462 Refs: nodejs#2693 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
When adding node.js formula into norm, I found out that, for some reason, cpplint in
make test
insists that header guards must include full pathname to the file where header is located. This pretty much breaks the tests and I had to disable them.Tested on 32-bit debian squeeze chroot.
I have no solution at the moment, but it seems like you're passing full pathname to cpplint and it blindly converts it to
_FULL_PATHNAME_TO_FILE_H_
, then compares it against the existing guard and fails.make test output:
The text was updated successfully, but these errors were encountered: