test: Make lint-includes.sh work from any directory #16768

pull kristapsk wants to merge 1 commits into bitcoin:master from kristapsk:lint-includes-anydir changing 1 files +3 −0
  1. kristapsk commented at 9:28 PM on August 30, 2019: contributor

    Before this change it works from root folder of bitcoin git repo, but if you do cd test/lint; ./test-includes.sh, you will have a lot of false positive messages like this:

    Good job! The circular dependency "chainparamsbase -> util/system -> chainparamsbase" is no longer present.
    Please remove it from EXPECTED_CIRCULAR_DEPENDENCIES in ./lint-circular-dependencies.sh
    to make sure this circular dependency is not accidentally reintroduced.
    
    Good job! The circular dependency "index/txindex -> validation -> index/txindex" is no longer present.
    Please remove it from EXPECTED_CIRCULAR_DEPENDENCIES in ./lint-circular-dependencies.sh
    to make sure this circular dependency is not accidentally reintroduced.
    
    
  2. fanquake added the label Tests on Aug 30, 2019
  3. kristapsk force-pushed on Aug 30, 2019
  4. kristapsk commented at 10:17 PM on August 30, 2019: contributor

    Changed push/popd to cd, Travis CI didn't like it.

    In test/lint/lint-includes.sh line 15:
    pushd "$(dirname $0)/../.." > /dev/null
    ^-- SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
    In test/lint/lint-includes.sh line 114:
    popd > /dev/null
    ^--------------^ SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
    
  5. fanquake commented at 6:23 AM on August 31, 2019: member

    Rebooted the test to be sure, and Travis still doesn't like it:

    In test/lint/lint-includes.sh line 15:
    cd "$(dirname $0)/../.." > /dev/null
    ^-- SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
    In test/lint/lint-includes.sh line 114:
    cd - > /dev/null
    ^--------------^ SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
    ^--------------^ SC2103: Use a ( subshell ) to avoid having to cd back.
    For more information:
      https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |...
      https://www.shellcheck.net/wiki/SC2103 -- Use a ( subshell ) to avoid havin...
    ^---- failure generated from test/lint/lint-shell.sh
    
  6. kristapsk force-pushed on Aug 31, 2019
  7. kristapsk commented at 11:45 AM on August 31, 2019: contributor

    It wants the check of exist status of cd, should be fine now.

  8. fanquake requested review from practicalswift on Sep 1, 2019
  9. in test/lint/lint-includes.sh:114 in 01825553fd outdated
     110 | @@ -108,4 +111,6 @@ if [[ ${QUOTE_SYNTAX_INCLUDES} != "" ]]; then
     111 |      EXIT_CODE=1
     112 |  fi
     113 |  
     114 | +cd - > /dev/null || exit 1
    


    practicalswift commented at 1:50 PM on September 3, 2019:

    Nit: You can do cd ~- to avoid echoing. Or even better cd $OLDPWD to make it readable :-)


    kristapsk commented at 9:52 PM on September 3, 2019:

    Ohh, that's nice one, I didn't know about cd ~-! :)

  10. practicalswift commented at 2:12 PM on September 3, 2019: contributor

    Tested ACK 01825553fd1e10d95c8b1539b8d0245ede39fd74

    Nice developer ergonomics fix! @kristapsk, you might want to apply this fix to the other git based linters as well to allow for running them from any directory. Perhaps in a follow-up PR? :-)

    These linters invoke git:

    $ git grep -lE "[^a-z]git[^a-z]" -- test/lint/ ":(exclude)*.md"
    test/lint/check-doc.py
    test/lint/commit-script-check.sh
    test/lint/extended-lint-cppcheck.sh
    test/lint/git-subtree-check.sh
    test/lint/lint-assertions.sh
    test/lint/lint-filenames.sh
    test/lint/lint-format-strings.sh
    test/lint/lint-include-guards.sh
    test/lint/lint-includes.sh
    test/lint/lint-locale-dependence.sh
    test/lint/lint-logs.sh
    test/lint/lint-python-dead-code.sh
    test/lint/lint-python-mutable-default-parameters.sh
    test/lint/lint-python-utf8-encoding.sh
    test/lint/lint-python.sh
    test/lint/lint-qt.sh
    test/lint/lint-rpc-help.sh
    test/lint/lint-shebang.sh
    test/lint/lint-shell-locale.sh
    test/lint/lint-shell.sh
    test/lint/lint-spelling.sh
    test/lint/lint-tests.sh
    test/lint/lint-whitespace.sh
    
  11. practicalswift approved
  12. MarcoFalke commented at 2:43 PM on September 3, 2019: member

    I'd rather not change all the linter scripts to provide maximum flexibility. This is all code that needs to be reviewed and maintained. And changing one script to be flexible, but keeping the others doesn't really help.

    So -0 from me.

  13. kristapsk commented at 9:56 PM on September 3, 2019: contributor

    So, as I understand, @MarcoFalke is against merging this, but @practicalswift things it's good idea to modify other scripts too. What do others think? I will not stand and fight for this too hard, does not seem to be of high importance, just think it's not good that script gives false positive outputs just because it's ran from the wrong directory.

  14. practicalswift commented at 10:12 PM on September 3, 2019: contributor

    @kristapsk @MarcoFalke Even if the other scripts are left unchanged I think this specific change is worth doing: lint-includes.sh gives very misleading output if not run from the repo root.

  15. MarcoFalke commented at 11:38 PM on September 3, 2019: member

    Ok, fair enough

  16. kristapsk force-pushed on Sep 4, 2019
  17. in test/lint/lint-includes.sh:114 in 9d518b5f0f outdated
     110 | @@ -108,4 +111,6 @@ if [[ ${QUOTE_SYNTAX_INCLUDES} != "" ]]; then
     111 |      EXIT_CODE=1
     112 |  fi
     113 |  
     114 | +cd $OLDPWD || exit 1
    


    promag commented at 12:33 AM on September 4, 2019:

    nit, unnecessary, first cd happens in the sub shell - calling shell isn't affected.


    kristapsk commented at 7:36 PM on September 4, 2019:

    Ohh, yes, you're right!

  18. promag commented at 12:34 AM on September 4, 2019: member

    ACK 9d518b5f0ffedc79b98dba7aed35637d11e7f736, tested.

  19. Make lint-includes.sh work from any directory 490da639cb
  20. kristapsk force-pushed on Sep 4, 2019
  21. MarcoFalke referenced this in commit 761fe07ba9 on Sep 5, 2019
  22. MarcoFalke merged this on Sep 5, 2019
  23. MarcoFalke closed this on Sep 5, 2019

  24. kristapsk deleted the branch on Sep 7, 2019
  25. zkbot referenced this in commit 43ac2062f9 on Oct 28, 2020
  26. zkbot referenced this in commit 84a5830aaa on Nov 9, 2020
  27. PastaPastaPasta referenced this in commit 874f154866 on Jun 27, 2021
  28. PastaPastaPasta referenced this in commit 00396c7ced on Jun 28, 2021
  29. PastaPastaPasta referenced this in commit 47b89c7578 on Jun 29, 2021
  30. PastaPastaPasta referenced this in commit f2b43807f1 on Jul 1, 2021
  31. PastaPastaPasta referenced this in commit 92e18e90c0 on Jul 1, 2021
  32. PastaPastaPasta referenced this in commit 599a98e97a on Jul 12, 2021
  33. PastaPastaPasta referenced this in commit d36d5efee5 on Jul 13, 2021
  34. DrahtBot locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-02 03:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me