r-lib / debugme

Easy and efficient debugging for R packages
https://r-lib.github.io/debugme/
Other
149 stars 10 forks source link

added debug call stack indent formatting. #21

Closed kforner closed 6 years ago

kforner commented 7 years ago

I had to change a bit the format output, and to import data.table.

I also intend (and I think you might too) to make a package for drawing pretty trees in a terminal, that could be used here.

On a package of mine, it looks like this:

qbdev test_one_pkg("qbexpress") +73ms 
qbdev +-load_pkg("qbexpress") +1ms 
qbdev   +-fetch_pkg_db() +1ms 
qbdev   +-load_pkg_and_deps("qbexpress") +2ms 
qbdev     +-find_srcpkgs("/home/karl/workspace/qbr") +1ms 
qbdev     +-load_pkg_and_deps("qbutils") +46ms 
qbdev       +-load_one_pkg_if_needed pkg="qbutils" +1ms 
qbdev         +-md5sum_pkg - pkg="qbutils" dir="/home/karl/workspace/qbr/pkg/qbutils_proj/qbutils" +1ms 
qbdev           +-hook_runner(hook_name="hook_loadNamespace") +1ms 
qbdev             +-my_qbdev_loader(pkg_name="withr", hooked="loadNamespace") DISABLED +2ms 
qbdev           +-hook_runner(hook_name="hook_loadNamespace") +4ms 
qbdev             +-my_qbdev_loader(pkg_name="tools", hooked="loadNamespace") DISABLED +2ms 
qbdev         +-pkg_need_reload(qbutils) +25ms 
qbdev         +-load_one_pkg pkg="qbutils" +1ms 
qbdev           +-roxygenise_pkg("qbutils") +1ms 
qbdev             +-need_roxygen("qbutils") +1ms 
qbdev           +-roxygenise_pkg --> not needed!! +1ms 
qbdev           +-load_all_wrapper pkg="qbutils" attach=FALSE export_all=FALSE +1ms 
qbdev             +-fix_imports_for_devtools(): patching namespaceImportFrom +1ms 
qbdev               +-replace_binding(name="namespaceImportFrom") +1ms 

What do you think ?

gaborcsardi commented 7 years ago

Thanks! It looks pretty good!

It would be indeed nice to have good-looking trees. If you need unicode characters with fallback, I can put them in the clisymbols package.

I am afraid that data.table is a no-go, though, because debugme needs to stay lightweight.

codecov-io commented 7 years ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (master@e65ce04). Click here to learn what that means. The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##             master    #21   +/-   ##
=======================================
  Coverage          ?   100%           
=======================================
  Files             ?      5           
  Lines             ?    113           
  Branches          ?      0           
=======================================
  Hits              ?    113           
  Misses            ?      0           
  Partials          ?      0
Impacted Files Coverage Δ
R/package.R 100% <ø> (ø)
R/debug.R 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update e65ce04...400ac11. Read the comment docs.

kforner commented 7 years ago

It seems that the Travis build failed for other reasons:

+Rscript -e 'if (!("remotes" %in% rownames(installed.packages()))) q(status=1)'

/home/travis/R-bin/R-3.3.3/lib/R/bin/exec/R: error while loading shared libraries: libicuuc.so.48: cannot open shared object file: No such file or directory

+RInstall testthat curl

+[[ '' == \t\e\s\t\t\h\a\t\ \c\u\r\l ]]

+echo 'Installing R package(s): testthat' curl

Installing R package(s): testthat curl

+Rscript -e 'install.packages(commandArgs(TRUE), repos="http://cran.rstudio.com")' testthat curl

/home/travis/R-bin/R-3.3.3/lib/R/bin/exec/R: error while loading shared libraries: libicuuc.so.48: cannot open shared object file: No such file or directory
kforner commented 7 years ago

Hi Gabor, What about this PR status ? Could you check the Travis CI, it seems that it fails prior to checking the package... ? A+ Karl

kforner commented 7 years ago

any news on that ?

gaborcsardi commented 6 years ago

Sorry, I somehow thought that it still needs data.table. I do like the idea a lot! I will probably do some modifications to it, though. I'll make it optional, so you can turn it on and off.

And maybe I'll change the format a bit. The +- does not look that great, and it is sometimes not easy to follow the long branches of the tree. I am not sure what we can do about that, because we don't know about future branches. Maybe we can just have a table of contents format, like this:

qbdev 1 test_one_pkg("qbexpress") +73ms 
qbdev 1.1 load_pkg("qbexpress") +1ms 
qbdev 1.1.1 fetch_pkg_db() +1ms 
qbdev 1.1.2 load_pkg_and_deps("qbexpress") +2ms 
qbdev 1.1.2.1 find_srcpkgs("/home/karl/workspace/qbr") +1ms 
qbdev 1.1.2.2 load_pkg_and_deps("qbutils") +46ms
...

This is not so great, either, but maybe better?

gaborcsardi commented 6 years ago

Some other possibilities, none of them are great, still.

qbdev test_one_pkg("qbexpress") +73ms 
qbdev 1·load_pkg("qbexpress") +1ms 
qbdev 2··fetch_pkg_db() +1ms 
qbdev 2··load_pkg_and_deps("qbexpress") +2ms 
qbdev 3···find_srcpkgs("/home/karl/workspace/qbr") +1ms 
qbdev 3···load_pkg_and_deps("qbutils") +46ms 
qbdev 4····load_one_pkg_if_needed pkg="qbutils" +1ms 
qbdev 5·····md5sum_pkg - pkg="qbutils" dir="/home/karl/workspace/qbr/pkg/qbutils_proj/qbutils" +1ms 
qbdev 6······hook_runner(hook_name="hook_loadNamespace") +1ms 
qbdev 7·······my_qbdev_loader(pkg_name="withr", hooked="loadNamespace") DISABLED +2ms 
qbdev 6······hook_runner(hook_name="hook_loadNamespace") +4ms 
qbdev 7·······my_qbdev_loader(pkg_name="tools", hooked="loadNamespace") DISABLED +2ms 
qbdev 5·····pkg_need_reload(qbutils) +25ms 
qbdev 5·····load_one_pkg pkg="qbutils" +1ms 
qbdev 6······roxygenise_pkg("qbutils") +1ms 
qbdev 7·······need_roxygen("qbutils") +1ms 
qbdev 6······roxygenise_pkg --> not needed!! +1ms 
qbdev 6······load_all_wrapper pkg="qbutils" attach=FALSE export_all=FALSE +1ms 
qbdev 7·······fix_imports_for_devtools(): patching namespaceImportFrom +1ms 
qbdev 8········replace_binding(name="namespaceImportFrom") +1ms
qbdev test_one_pkg("qbexpress") +73ms 
qbdev 1 load_pkg("qbexpress") +1ms 
qbdev └2 fetch_pkg_db() +1ms 
qbdev  2  load_pkg_and_deps("qbexpress") +2ms 
qbdev  └3 find_srcpkgs("/home/karl/workspace/qbr") +1ms 
qbdev  └3 load_pkg_and_deps("qbutils") +46ms 
qbdev   └4 load_one_pkg_if_needed pkg="qbutils" +1ms 
qbdev    └5 md5sum_pkg - pkg="qbutils" dir="/home/karl/workspace/qbr/pkg/qbutils_proj/qbutils" +1ms 
qbdev     └6 hook_runner(hook_name="hook_loadNamespace") +1ms 
qbdev      └7 my_qbdev_loader(pkg_name="withr", hooked="loadNamespace") DISABLED +2ms 
qbdev     └6 hook_runner(hook_name="hook_loadNamespace") +4ms 
qbdev      └7 my_qbdev_loader(pkg_name="tools", hooked="loadNamespace") DISABLED +2ms 
qbdev    └5 pkg_need_reload(qbutils) +25ms 
qbdev    └5 load_one_pkg pkg="qbutils" +1ms 
qbdev     └6 roxygenise_pkg("qbutils") +1ms 
qbdev      └7 need_roxygen("qbutils") +1ms 
qbdev     └6 roxygenise_pkg --> not needed!! +1ms 
qbdev     └6 load_all_wrapper pkg="qbutils" attach=FALSE export_all=FALSE +1ms 
qbdev      └7 fix_imports_for_devtools(): patching namespaceImportFrom +1ms 
qbdev       └8 replace_binding(name="namespaceImportFrom") +1ms
qbdev test_one_pkg("qbexpress") +73ms 
qbdev ⑴ load_pkg("qbexpress") +1ms 
qbdev  ⑵ fetch_pkg_db() +1ms 
qbdev  ⑵ load_pkg_and_deps("qbexpress") +2ms 
qbdev   ⑶ find_srcpkgs("/home/karl/workspace/qbr") +1ms 
qbdev   ⑶ load_pkg_and_deps("qbutils") +46ms 
qbdev    ⑷ load_one_pkg_if_needed pkg="qbutils" +1ms 
qbdev     ⑸ md5sum_pkg - pkg="qbutils" dir="/home/karl/workspace/qbr/pkg/qbutils_proj/qbutils" +1ms 
qbdev      ⑹ hook_runner(hook_name="hook_loadNamespace") +1ms 
qbdev       ⑺ my_qbdev_loader(pkg_name="withr", hooked="loadNamespace") DISABLED +2ms 
qbdev      ⑹ hook_runner(hook_name="hook_loadNamespace") +4ms 
qbdev       ⑺ my_qbdev_loader(pkg_name="tools", hooked="loadNamespace") DISABLED +2ms 
qbdev     ⑸ pkg_need_reload(qbutils) +25ms 
qbdev     ⑸ load_one_pkg pkg="qbutils" +1ms 
qbdev      ⑹ roxygenise_pkg("qbutils") +1ms 
qbdev       ⑺ need_roxygen("qbutils") +1ms 
qbdev      ⑹ roxygenise_pkg --> not needed!! +1ms 
qbdev      ⑹ load_all_wrapper pkg="qbutils" attach=FALSE export_all=FALSE +1ms 
qbdev       ⑺ fix_imports_for_devtools(): patching namespaceImportFrom +1ms 
qbdev        ⑻ replace_binding(name="namespaceImportFrom") +1ms
qbdev test_one_pkg("qbexpress") +73ms 
qbdev ⒈ load_pkg("qbexpress") +1ms 
qbdev  ⒉ fetch_pkg_db() +1ms 
qbdev  ⒉ load_pkg_and_deps("qbexpress") +2ms 
qbdev   ⒊ find_srcpkgs("/home/karl/workspace/qbr") +1ms 
qbdev   ⒊ load_pkg_and_deps("qbutils") +46ms 
qbdev    ⒋ load_one_pkg_if_needed pkg="qbutils" +1ms 
qbdev     ⒌ md5sum_pkg - pkg="qbutils" dir="/home/karl/workspace/qbr/pkg/qbutils_proj/qbutils" +1ms 
qbdev      ⒍ hook_runner(hook_name="hook_loadNamespace") +1ms 
qbdev       ⒎ my_qbdev_loader(pkg_name="withr", hooked="loadNamespace") DISABLED +2ms 
qbdev      ⒍ hook_runner(hook_name="hook_loadNamespace") +4ms 
qbdev       ⒎ my_qbdev_loader(pkg_name="tools", hooked="loadNamespace") DISABLED +2ms 
qbdev     ⒌ pkg_need_reload(qbutils) +25ms 
qbdev     ⒌ load_one_pkg pkg="qbutils" +1ms 
qbdev      ⒍ roxygenise_pkg("qbutils") +1ms 
qbdev       ⒎ need_roxygen("qbutils") +1ms 
qbdev      ⒍ roxygenise_pkg --> not needed!! +1ms 
qbdev      ⒍ load_all_wrapper pkg="qbutils" attach=FALSE export_all=FALSE +1ms 
qbdev       ⒎ fix_imports_for_devtools(): patching namespaceImportFrom +1ms 
qbdev        ⒏ replace_binding(name="namespaceImportFrom") +1ms
gaborcsardi commented 6 years ago

We can maybe also use some background color to denote entries at the same level.

kforner commented 6 years ago

cool, I did not understand your silence, thought you were too busy at rstudio...

I think the background colors combined with a tree-like display could be quite readable:

│   │   │   │   │   │   ├── r_etc
│   │   │   │   │   │   │   └── Rprofile.site
│   │   │   │   │   │   ├── samples
│   │   │   │   │   │   │   ├── buggy_knit_child
│   │   │   │   │   │   │   │   ├── child.Rnw
│   │   │   │   │   │   │   │   ├── parent2.Rnw
│   │   │   │   │   │   │   │   └── parent.Rnw
│   │   │   │   │   │   │   ├── sample_child_rmarkdown.Rmd
│   │   │   │   │   │   │   ├── sample_child_rmd_report.Rmd
│   │   │   │   │   │   │   ├── sample_log_file.txt
│   │   │   │   │   │   │   ├── sample_rmarkdown_forbeamer.Rmd
│   │   │   │   │   │   │   ├── sample_rmarkdown.Rmd
│   │   │   │   │   │   │   ├── sample_rmd_preamble.tex
│   │   │   │   │   │   │   ├── sample_rmd_report_title.Rmd
│   │   │   │   │   │   │   └── test_resolutions.Rmd
│   │   │   │   │   │   └── templates
│   │   │   │   │   │       ├── article
gaborcsardi commented 6 years ago

Yeah, of course the lines on the left might lead to nowhere. Is that a problem?

The updated package is on CRAN, btw.

kforner commented 6 years ago

Yeah, of course the lines on the left might lead to nowhere. Is that a problem?

I don't think so. And we can count them quite easily to get the level.

The updated package is on CRAN, btw.

Neat.

gaborcsardi commented 6 years ago

The background color could be too much, though, especially because the text is already colored according to packages.

screen shot 2017-10-23 at 11 05 56 am