nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
107.88k stars 29.73k forks source link

make test fails with header_guard error in cpplint #2693

Closed hmage closed 9 years ago

hmage commented 9 years ago

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:

(squeeze) bujak_e@wraith:~/compile/node-v0.12.7$ make test
make -C out BUILDTYPE=Release V=1
make[1]: Entering directory `/home/bujak_e/compile/node-v0.12.7/out'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/bujak_e/compile/node-v0.12.7/out'
ln -fs out/Release/node node
/usr/bin/python tools/test.py --mode=release simple message
[02:53|% 100|+ 792|-   0]: Done                                                
make jslint
make[1]: Entering directory `/home/bujak_e/compile/node-v0.12.7'
PYTHONPATH=tools/closure_linter/ /usr/bin/python tools/closure_linter/closure_linter/gjslint.py --unix_mode --strict --nojsdoc -r lib/ -r src/ --exclude_files lib/punycode.js
Skipping 1 file(s).
50 files checked, no errors found.
make[1]: Leaving directory `/home/bujak_e/compile/node-v0.12.7'
make cpplint
make[1]: Entering directory `/home/bujak_e/compile/node-v0.12.7'
Done processing src/async-wrap.cc
Done processing src/cares_wrap.cc
Done processing src/fs_event_wrap.cc
Done processing src/handle_wrap.cc
Done processing src/node_buffer.cc
Done processing src/node.cc
Done processing src/node_constants.cc
Done processing src/node_contextify.cc
Done processing src/node_counters.cc
Done processing src/node_crypto_bio.cc
Done processing src/node_crypto.cc
Done processing src/node_crypto_clienthello.cc
Done processing src/node_dtrace.cc
Done processing src/node_file.cc
Done processing src/node_http_parser.cc
Done processing src/node_i18n.cc
Done processing src/node_javascript.cc
Done processing src/node_main.cc
Done processing src/node_os.cc
Done processing src/node_stat_watcher.cc
Done processing src/node_v8.cc
Done processing src/node_watchdog.cc
Done processing src/node_win32_etw_provider.cc
Done processing src/node_zlib.cc
Done processing src/pipe_wrap.cc
Done processing src/process_wrap.cc
Done processing src/signal_wrap.cc
Done processing src/smalloc.cc
Done processing src/spawn_sync.cc
Done processing src/stream_wrap.cc
Done processing src/string_bytes.cc
Done processing src/tcp_wrap.cc
Done processing src/timer_wrap.cc
Done processing src/tls_wrap.cc
Done processing src/tty_wrap.cc
Done processing src/udp_wrap.cc
Done processing src/util.cc
Done processing src/uv.cc
src/async-wrap.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_ASYNC_WRAP_H_  [build/header_guard] [5]
src/async-wrap.h:97:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_ASYNC_WRAP_H_"  [build/header_guard] [5]
Done processing src/async-wrap.h
src/async-wrap-inl.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_ASYNC_WRAP_INL_H_  [build/header_guard] [5]
src/async-wrap-inl.h:114:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_ASYNC_WRAP_INL_H_"  [build/header_guard] [5]
Done processing src/async-wrap-inl.h
src/base-object.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_BASE_OBJECT_H_  [build/header_guard] [5]
src/base-object.h:71:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_BASE_OBJECT_H_"  [build/header_guard] [5]
Done processing src/base-object.h
src/base-object-inl.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_BASE_OBJECT_INL_H_  [build/header_guard] [5]
src/base-object-inl.h:87:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_BASE_OBJECT_INL_H_"  [build/header_guard] [5]
Done processing src/base-object-inl.h
src/env.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_ENV_H_  [build/header_guard] [5]
src/env.h:593:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_ENV_H_"  [build/header_guard] [5]
Done processing src/env.h
src/env-inl.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_ENV_INL_H_  [build/header_guard] [5]
src/env-inl.h:470:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_ENV_INL_H_"  [build/header_guard] [5]
Done processing src/env-inl.h
src/handle_wrap.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_HANDLE_WRAP_H_  [build/header_guard] [5]
src/handle_wrap.h:87:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_HANDLE_WRAP_H_"  [build/header_guard] [5]
Done processing src/handle_wrap.h
src/node_buffer.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_BUFFER_H_  [build/header_guard] [5]
src/node_buffer.h:125:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_BUFFER_H_"  [build/header_guard] [5]
Done processing src/node_buffer.h
src/node_constants.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_CONSTANTS_H_  [build/header_guard] [5]
src/node_constants.h:32:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_CONSTANTS_H_"  [build/header_guard] [5]
Done processing src/node_constants.h
src/node_counters.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_COUNTERS_H_  [build/header_guard] [5]
src/node_counters.h:55:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_COUNTERS_H_"  [build/header_guard] [5]
Done processing src/node_counters.h
src/node_crypto_bio.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_CRYPTO_BIO_H_  [build/header_guard] [5]
src/node_crypto_bio.h:138:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_CRYPTO_BIO_H_"  [build/header_guard] [5]
Done processing src/node_crypto_bio.h
src/node_crypto_clienthello.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_CRYPTO_CLIENTHELLO_H_  [build/header_guard] [5]
src/node_crypto_clienthello.h:145:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_CRYPTO_CLIENTHELLO_H_"  [build/header_guard] [5]
Done processing src/node_crypto_clienthello.h
src/node_crypto_clienthello-inl.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_CRYPTO_CLIENTHELLO_INL_H_  [build/header_guard] [5]
src/node_crypto_clienthello-inl.h:76:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_CRYPTO_CLIENTHELLO_INL_H_"  [build/header_guard] [5]
Done processing src/node_crypto_clienthello-inl.h
src/node_crypto_groups.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_CRYPTO_GROUPS_H_  [build/header_guard] [5]
src/node_crypto_groups.h:412:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_CRYPTO_GROUPS_H_"  [build/header_guard] [5]
Done processing src/node_crypto_groups.h
src/node_crypto.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_CRYPTO_H_  [build/header_guard] [5]
src/node_crypto.h:715:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_CRYPTO_H_"  [build/header_guard] [5]
Done processing src/node_crypto.h
src/node_dtrace.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_DTRACE_H_  [build/header_guard] [5]
src/node_dtrace.h:82:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_DTRACE_H_"  [build/header_guard] [5]
Done processing src/node_dtrace.h
src/node_file.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_FILE_H_  [build/header_guard] [5]
src/node_file.h:34:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_FILE_H_"  [build/header_guard] [5]
Done processing src/node_file.h
src/node.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_H_  [build/header_guard] [5]
src/node.h:447:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_H_"  [build/header_guard] [5]
Done processing src/node.h
src/node_http_parser.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_HTTP_PARSER_H_  [build/header_guard] [5]
src/node_http_parser.h:35:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_HTTP_PARSER_H_"  [build/header_guard] [5]
Done processing src/node_http_parser.h
src/node_i18n.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_I18N_H_  [build/header_guard] [5]
src/node_i18n.h:39:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_I18N_H_"  [build/header_guard] [5]
Done processing src/node_i18n.h
src/node_internals.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_INTERNALS_H_  [build/header_guard] [5]
src/node_internals.h:236:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_INTERNALS_H_"  [build/header_guard] [5]
Done processing src/node_internals.h
src/node_javascript.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_JAVASCRIPT_H_  [build/header_guard] [5]
src/node_javascript.h:35:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_JAVASCRIPT_H_"  [build/header_guard] [5]
Done processing src/node_javascript.h
src/node_object_wrap.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_OBJECT_WRAP_H_  [build/header_guard] [5]
src/node_object_wrap.h:137:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_OBJECT_WRAP_H_"  [build/header_guard] [5]
Done processing src/node_object_wrap.h
src/node_stat_watcher.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_STAT_WATCHER_H_  [build/header_guard] [5]
src/node_stat_watcher.h:57:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_STAT_WATCHER_H_"  [build/header_guard] [5]
Done processing src/node_stat_watcher.h
src/node_version.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_VERSION_H_  [build/header_guard] [5]
src/node_version.h:69:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_VERSION_H_"  [build/header_guard] [5]
Done processing src/node_version.h
src/node_watchdog.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_WATCHDOG_H_  [build/header_guard] [5]
src/node_watchdog.h:58:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_WATCHDOG_H_"  [build/header_guard] [5]
Done processing src/node_watchdog.h
src/node_win32_etw_provider.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_WIN32_ETW_PROVIDER_H_  [build/header_guard] [5]
src/node_win32_etw_provider.h:99:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_WIN32_ETW_PROVIDER_H_"  [build/header_guard] [5]
Done processing src/node_win32_etw_provider.h
src/node_win32_etw_provider-inl.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_WIN32_ETW_PROVIDER_INL_H_  [build/header_guard] [5]
src/node_win32_etw_provider-inl.h:281:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_WIN32_ETW_PROVIDER_INL_H_"  [build/header_guard] [5]
Done processing src/node_win32_etw_provider-inl.h
src/node_win32_perfctr_provider.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_WIN32_PERFCTR_PROVIDER_H_  [build/header_guard] [5]
src/node_win32_perfctr_provider.h:54:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_WIN32_PERFCTR_PROVIDER_H_"  [build/header_guard] [5]
Done processing src/node_win32_perfctr_provider.h
src/node_wrap.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_WRAP_H_  [build/header_guard] [5]
src/node_wrap.h:68:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_NODE_WRAP_H_"  [build/header_guard] [5]
Done processing src/node_wrap.h
src/pipe_wrap.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_PIPE_WRAP_H_  [build/header_guard] [5]
src/pipe_wrap.h:67:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_PIPE_WRAP_H_"  [build/header_guard] [5]
Done processing src/pipe_wrap.h
src/req_wrap.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_REQ_WRAP_H_  [build/header_guard] [5]
src/req_wrap.h:70:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_REQ_WRAP_H_"  [build/header_guard] [5]
Done processing src/req_wrap.h
src/smalloc.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_SMALLOC_H_  [build/header_guard] [5]
src/smalloc.h:153:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_SMALLOC_H_"  [build/header_guard] [5]
Done processing src/smalloc.h
src/spawn_sync.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_SPAWN_SYNC_H_  [build/header_guard] [5]
src/spawn_sync.h:247:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_SPAWN_SYNC_H_"  [build/header_guard] [5]
Done processing src/spawn_sync.h
src/stream_wrap.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_STREAM_WRAP_H_  [build/header_guard] [5]
src/stream_wrap.h:226:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_STREAM_WRAP_H_"  [build/header_guard] [5]
Done processing src/stream_wrap.h
src/string_bytes.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_STRING_BYTES_H_  [build/header_guard] [5]
src/string_bytes.h:128:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_STRING_BYTES_H_"  [build/header_guard] [5]
Done processing src/string_bytes.h
src/tcp_wrap.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_TCP_WRAP_H_  [build/header_guard] [5]
src/tcp_wrap.h:71:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_TCP_WRAP_H_"  [build/header_guard] [5]
Done processing src/tcp_wrap.h
src/tls_wrap.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_TLS_WRAP_H_  [build/header_guard] [5]
src/tls_wrap.h:178:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_TLS_WRAP_H_"  [build/header_guard] [5]
Done processing src/tls_wrap.h
src/tty_wrap.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_TTY_WRAP_H_  [build/header_guard] [5]
src/tty_wrap.h:56:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_TTY_WRAP_H_"  [build/header_guard] [5]
Done processing src/tty_wrap.h
src/udp_wrap.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_UDP_WRAP_H_  [build/header_guard] [5]
src/udp_wrap.h:86:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_UDP_WRAP_H_"  [build/header_guard] [5]
Done processing src/udp_wrap.h
src/util.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_UTIL_H_  [build/header_guard] [5]
src/util.h:147:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_UTIL_H_"  [build/header_guard] [5]
Done processing src/util.h
src/util-inl.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_UTIL_INL_H_  [build/header_guard] [5]
src/util-inl.h:124:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_SRC_UTIL_INL_H_"  [build/header_guard] [5]
Done processing src/util-inl.h
Done processing tools/icu/iculslocs.cc
Done processing tools/icu/no-op.cc
deps/debugger-agent/include/debugger-agent.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_DEPS_DEBUGGER_AGENT_INCLUDE_DEBUGGER_AGENT_H_  [build/header_guard] [5]
deps/debugger-agent/include/debugger-agent.h:109:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_DEPS_DEBUGGER_AGENT_INCLUDE_DEBUGGER_AGENT_H_"  [build/header_guard] [5]
Done processing deps/debugger-agent/include/debugger-agent.h
Done processing deps/debugger-agent/src/agent.cc
deps/debugger-agent/src/agent.h:22:  #ifndef header guard has wrong style, please use: _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_DEPS_DEBUGGER_AGENT_SRC_AGENT_H_  [build/header_guard] [5]
deps/debugger-agent/src/agent.h:64:  #endif line should be "#endif  // _HOME_BUJAK_E_COMPILE_NODE_V0_12_7_DEPS_DEBUGGER_AGENT_SRC_AGENT_H_"  [build/header_guard] [5]
Done processing deps/debugger-agent/src/agent.h
Total errors found: 88
make[1]: *** [cpplint] Error 1
make[1]: Leaving directory `/home/bujak_e/compile/node-v0.12.7'
make: *** [test] Error 2
bnoordhuis commented 9 years ago

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.
hmage commented 9 years ago

Will try later today and come back with results. Most likely it will judging by what I see in the patch.

mscdex commented 9 years ago

+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 make lint.

hmage commented 9 years ago

Yes, the patch fixes the problem.

bnoordhuis commented 9 years ago

Fixed by a493dab.