Skip to content
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

Add the toc function with the test failure. #154

Closed
wants to merge 4 commits into from

Conversation

JiaxiangBU
Copy link
Contributor

Hi @jdblischak, feedback the issue #151, I write a quick function wflow_toc. It helps users like me to add a table of content.
However, something blocks me.
Before I add the new function, I do a pre-test using devtools::test(). This test takes a long time. And I get this error.

Test failture.
> devtools::test()
Loading workflowr
This is workflowr version 1.2.0
Run ?workflowr for help getting started
Testing workflowr
√ | OK F W S | Context
√ | 13       | build_rmd [15.8 s]
√ | 22     1 | build_rmd_external [56.9 s]
--------------------------------------------------------------------------------
test-build_rmd_external.R:76: skip: An error stops execution, does not create file,
          and provides informative error message
callr 3.0.0 doesn't write the error message to stderr
--------------------------------------------------------------------------------
√ | 16       | fig_path_ext [43.7 s]
√ |  9       | git [1.3 s]
√ | 33       | git2r [1.5 s]
√ | 30       | glob [3.9 s]
√ | 30     1 | obtain_existing_path [0.4 s]
--------------------------------------------------------------------------------
test-obtain_existing_path.R:62: skip: obtain_existing_paths works when the root is the upstream existing directory (unix-like)
Only relevant on Unix-like
--------------------------------------------------------------------------------
√ | 83       | report [62.9 s]
√ | 66       | subdirectories [30.3 s]
√ | 97     2 | utility [11.3 s]
--------------------------------------------------------------------------------
test-utility.R:520: skip: file_executable returns FALSE for non-executable file
File permissions are different on Windows

test-utility.R:532: skip: file_executable returns TRUE for executable file
File permissions are different on Windows
--------------------------------------------------------------------------------
√ | 23       | vig-getting-started [81.3 s]
√ | 16       | vig-gitlab [75.6 s]
x | 78 11     | wflow_build [299.5 s]
--------------------------------------------------------------------------------
test-wflow_build.R:57: failure: wflow_build can run in 'make' mode
actual$built not identical to `rmd`.
Lengths differ: 0 is not 3

test-wflow_build.R:59: failure: wflow_build can run in 'make' mode
`actual <- wflow_build(view = FALSE, project = site_dir)` did not produce any messages.

test-wflow_build.R:61: failure: wflow_build can run in 'make' mode
actual$built not identical to `rmd`.
Lengths differ: 0 is not 3

test-wflow_build.R:71: failure: wflow_build can run in 'make' mode
`actual <- wflow_build(view = FALSE, project = site_dir)` did not produce any messages.

test-wflow_build.R:73: failure: wflow_build can run in 'make' mode
actual$built not identical to rmd[1].
Lengths differ: 0 is not 1

test-wflow_build.R:93: failure: wflow_build can run in 'make' mode from within project
actual$built not identical to `rmd_local`.
Lengths differ: 0 is not 3

test-wflow_build.R:95: failure: wflow_build can run in 'make' mode from within project
`actual <- wflow_build(view = FALSE)` did not produce any messages.

test-wflow_build.R:96: failure: wflow_build can run in 'make' mode from within project
actual$built not identical to `rmd_local`.
Lengths differ: 0 is not 3

test-wflow_build.R:106: failure: wflow_build can run in 'make' mode from within project
`actual <- wflow_build(view = FALSE)` did not produce any messages.

test-wflow_build.R:107: failure: wflow_build can run in 'make' mode from within project
actual$built not identical to rmd_local[1].
Lengths differ: 0 is not 1

test-wflow_build.R:164: failure: Only locally built files can access variables in the global environment
`utils::capture.output(wflow_build(rmd_local, view = FALSE, project = site_dir))` threw an error with unexpected message.
Expected match: "object 'global_variable' not found"
Actual message: "找不到对象'global_variable'"
--------------------------------------------------------------------------------

== Terminating early ===========================================================
Too many failures

The function is very simple (R/wflow_toc.R). I am still working on this test failture, just let you know.

jdblischak and others added 2 commits February 14, 2019 14:34
Both stringi and knitr have source versions that are more recent than
their corresponding binary versions. When the remotes package tries to
install them from source, it attempts to install knitr first. Since
knitr depends on stringi (via stringr), the installation fails.

r-lib/remotes#296

install.packages() installs the source packages in the correct order.
@JiaxiangBU
Copy link
Contributor Author

Here is my session information.

"Session Information"
#> [1] "Session Information"

Created on 2019-03-25 by the reprex package (v0.2.1)

Session info
devtools::session_info()
#> - Session info ----------------------------------------------------------
#>  setting  value                                              
#>  version  R version 3.5.3 (2019-03-11)                       
#>  os       Windows 7 x64 SP 1                                 
#>  system   x86_64, mingw32                                    
#>  ui       RTerm                                              
#>  language (EN)                                               
#>  collate  Chinese (Simplified)_People's Republic of China.936
#>  ctype    Chinese (Simplified)_People's Republic of China.936
#>  tz       Asia/Taipei                                        
#>  date     2019-03-25                                         
#> 
#> - Packages --------------------------------------------------------------
#>  package     * version date       lib source        
#>  assertthat    0.2.0   2017-04-11 [1] CRAN (R 3.5.2)
#>  backports     1.1.3   2018-12-14 [1] CRAN (R 3.5.2)
#>  callr         3.1.1   2018-12-21 [1] CRAN (R 3.5.2)
#>  cli           1.0.1   2018-09-25 [1] CRAN (R 3.5.2)
#>  crayon        1.3.4   2017-09-16 [1] CRAN (R 3.5.2)
#>  desc          1.2.0   2018-05-01 [1] CRAN (R 3.5.2)
#>  devtools      2.0.1   2018-10-26 [1] CRAN (R 3.5.2)
#>  digest        0.6.18  2018-10-10 [1] CRAN (R 3.5.2)
#>  evaluate      0.12    2018-10-09 [1] CRAN (R 3.5.2)
#>  fs            1.2.6   2018-08-23 [1] CRAN (R 3.5.2)
#>  glue          1.3.0   2018-07-17 [1] CRAN (R 3.5.2)
#>  highr         0.7     2018-06-09 [1] CRAN (R 3.5.2)
#>  htmltools     0.3.6   2017-04-28 [1] CRAN (R 3.5.2)
#>  knitr         1.21    2018-12-10 [1] CRAN (R 3.5.2)
#>  magrittr      1.5     2014-11-22 [1] CRAN (R 3.5.2)
#>  memoise       1.1.0   2017-04-21 [1] CRAN (R 3.5.2)
#>  pkgbuild      1.0.2   2018-10-16 [1] CRAN (R 3.5.2)
#>  pkgload       1.0.2   2018-10-29 [1] CRAN (R 3.5.2)
#>  prettyunits   1.0.2   2015-07-13 [1] CRAN (R 3.5.2)
#>  processx      3.2.1   2018-12-05 [1] CRAN (R 3.5.2)
#>  ps            1.3.0   2018-12-21 [1] CRAN (R 3.5.2)
#>  R6            2.3.0   2018-10-04 [1] CRAN (R 3.5.2)
#>  Rcpp          1.0.0   2018-11-07 [1] CRAN (R 3.5.2)
#>  remotes       2.0.2   2018-10-30 [1] CRAN (R 3.5.2)
#>  rlang         0.3.1   2019-01-08 [1] CRAN (R 3.5.2)
#>  rmarkdown     1.11    2018-12-08 [1] CRAN (R 3.5.3)
#>  rprojroot     1.3-2   2018-01-03 [1] CRAN (R 3.5.2)
#>  sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 3.5.2)
#>  stringi       1.2.4   2018-07-20 [1] CRAN (R 3.5.2)
#>  stringr       1.3.1   2018-05-10 [1] CRAN (R 3.5.2)
#>  testthat      2.0.1   2018-10-13 [1] CRAN (R 3.5.2)
#>  usethis       1.4.0   2018-08-14 [1] CRAN (R 3.5.2)
#>  withr         2.1.2   2018-03-15 [1] CRAN (R 3.5.2)
#>  xfun          0.4     2018-10-23 [1] CRAN (R 3.5.2)
#>  yaml          2.2.0   2018-07-25 [1] CRAN (R 3.5.2)
#> 
#> [1] C:/Users/lijiaxiang/Documents/R/win-library/3.5
#> [2] C:/Program Files/R/R-3.5.3/library

@jdblischak
Copy link
Member

I am still working on this test failture

@JiaxiangBU Don't worry about those test failures for now. I'm curious how they are happening since I don't see those on my Windows machine or on AppVeyor. But for your purposes, they are unrelated to your new function.

@jdblischak
Copy link
Member

For quicker feedback on your function, you can run the following:

devtools::check(build_args = "--no-build-vignettes", args = c("--no-tests", "--ignore-vignettes"))

This ignores the vignettes and the unit tests. These require running Pandoc, which can be quite slow, especially on Windows.

@JiaxiangBU
Copy link
Contributor Author

I am still working on this test failure

@JiaxiangBU Don't worry about those test failures for now. I'm curious how they are happening since I don't see those on my Windows machine or on AppVeyor. But for your purposes, they are unrelated to your new function.

OK, I am not very familiar with this field. I trust you, haha. And I am trying the function you give.

devtools::check(build_args = "--no-build-vignettes", args = c("--no-tests", "--ignore-vignettes"))

@JiaxiangBU
Copy link
Contributor Author

JiaxiangBU commented Mar 25, 2019

@jdblischak After this quick check,

I find there are one warning and one error here.
> devtools::check(build_args = "--no-build-vignettes", args = c("--no-tests", "--ignore-vignettes"))
Updating workflowr documentation
Writing NAMESPACE
Loading workflowr
Warning: replacing previous import ‘dplyr::collapse’ by ‘glue::collapse’ when loading ‘workflowr’
This is workflowr version 1.2.0
Run ?workflowr for help getting started
Writing NAMESPACE
-- Building ------------------------------------------------------- workflowr --
  Setting env vars:
  * CFLAGS    : -Wall -pedantic
* CXXFLAGS  : -Wall -pedantic
* CXX11FLAGS: -Wall -pedantic
--------------------------------------------------------------------------------
  √  checking for file 'D:\work\workflowr/DESCRIPTION' (1.9s)
-  preparing 'workflowr': (4.7s)
√  checking DESCRIPTION meta-information ... 
-  checking for LF line-endings in source and make files and shell scripts (787ms)
-  checking for empty or unneeded directories
Removed empty directory 'workflowr/docs/news'
Removed empty directory 'workflowr/docs'
-  building 'workflowr_1.2.0.tar.gz'

-- Checking ------------------------------------------------------- workflowr --
  Setting env vars:
  * _R_CHECK_CRAN_INCOMING_REMOTE_: FALSE
* _R_CHECK_CRAN_INCOMING_       : FALSE
* _R_CHECK_FORCE_SUGGESTS_      : FALSE
-- R CMD check ------------------------------------------------------------------------------------------
  -  using log directory 'C:/Users/lijiaxiang/AppData/Local/Temp/RtmpaAxl6k/workflowr.Rcheck' (1.7s)
-  using R version 3.5.3 (2019-03-11)
-  using platform: x86_64-w64-mingw32 (64-bit)
-  using session charset: CP936
-  using options '--no-tests --no-manual --ignore-vignettes --as-cran' (1.5s)
√  checking for file 'workflowr/DESCRIPTION'
-  checking extension type ... Package
-  this is package 'workflowr' version '1.2.0'
-  package encoding: UTF-8
√  checking package namespace information ...
√  checking package dependencies (8.2s)
√  checking if this is a source package ... 
√  checking if there is a namespace
√  checking for .dll and .exe files
√  checking for hidden files and directories ... 
√  checking for portable file names ... 
√  checking serialization versions ...
W  checking whether package 'workflowr' can be installed (18s)
Found the following significant warnings:
  Warning: 无法重新编码'wflow_html.R'行287
Warning: replacing previous import 'dplyr::collapse' by 'glue::collapse' when loading 'workflowr'
See 'C:/Users/lijiaxiang/AppData/Local/Temp/RtmpaAxl6k/workflowr.Rcheck/00install.out' for details.
√  checking package directory (1.3s)
√  checking DESCRIPTION meta-information (2s)
√  checking top-level files ...
√  checking for left-over files ... 
√  checking index information ...
√  checking package subdirectories (665ms)
√  checking R files for non-ASCII characters (606ms)
√  checking R files for syntax errors (704ms)
√  checking whether the package can be loaded (2s)
√  checking whether the package can be loaded with stated dependencies (1.7s)
√  checking whether the package can be unloaded cleanly (1.7s)
√  checking whether the namespace can be loaded with stated dependencies (1.7s)
√  checking whether the namespace can be unloaded cleanly (2.3s)
√  checking loading without being on the library search path (4.5s)
√  checking dependencies in R code (2.5s)
√  checking S3 generic/method consistency (3.3s)
√  checking replacement functions (1.8s)
√  checking foreign function calls (2.1s)
N  checking R code for possible problems (24.7s)
wflow_toc: no visible binding for global variable 'name'
wflow_toc: no visible binding for global variable '.'
Undefined global functions or variables:
  . name
√  checking Rd files (1.7s)
√  checking Rd metadata (1s)
√  checking Rd line widths (1.2s)
√  checking Rd cross-references (1.8s)
√  checking for missing documentation entries (2.7s)
√  checking for code/documentation mismatches (7.2s)
√  checking Rd \usage sections (5.6s)
√  checking Rd contents (1.7s)
√  checking for unstated dependencies in examples (1.8s)
-  checking files in 'vignettes' ... SKIPPED
√  checking examples (6.2s)
√  checking for unstated dependencies in 'tests' (703ms)
-  checking tests ... SKIPPED

See
'C:/Users/lijiaxiang/AppData/Local/Temp/RtmpaAxl6k/workflowr.Rcheck/00check.log'
for details.


Warning in readChar(path, nchars = file.info(path)$size, ...) :
  can only read in bytes in a non-UTF-8 MBCS locale
-- R CMD check results ------------------------------------------------------------- workflowr 1.2.0 ----
  Duration: 1m 57.9s

> checking whether package 'workflowr' can be installed ... WARNING
See below...

> checking R code for possible problems ... NOTE
wflow_toc: no visible binding for global variable 'name'
wflow_toc: no visible binding for global variable '.'
Undefined global functions or variables:
  . name

0 errors √ | 1 warning x | 1 note x

I will change the two namings to avoid the conflict between the local function and global environment.

@jdblischak
Copy link
Member

@JiaxiangBU This is a great start! I was able to get wflow_toc() to work locally on my computer.

OK, I am not very familiar with this field.

No worries! This is how you learn :-)

Before you start working on addressing those specific warnings/errors, we need to step back and address some larger issues.

The first issue to fix is that your commit is on the master branch, not the dev branch. If you look at the top of the Pull Request, it says that it is merging your master branch into my dev branch:

image

We need to merge your dev branch into my dev branch. How comfortable are you with Git? Have you ever used Git branches before? Do you run your Git commands in a terminal (e.g. Git Bash) or do you use a GUI?

@jdblischak
Copy link
Member

Another piece of advice. The links should be relative. This will ensure they will work on GitHub Pages, locally, or anywhere they may be hosted.

In other words, instead of

1. [About](https://jdblischak.github.io/workflowr/about.html)

It should be

1. [About](about.html)

Also, I'd recommend pull the title from the YAML header of the R Markdown file (code example below). This is more straightforward than a regex of the HTML file:

> rmarkdown::yaml_front_matter("analysis/about.Rmd")$title
[1] "About"

@JiaxiangBU
Copy link
Contributor Author

JiaxiangBU commented Mar 25, 2019

@JiaxiangBU This is a great start! I was able to get wflow_toc() to work locally on my computer.

OK, I am not very familiar with this field.

No worries! This is how you learn :-)

Before you start working on addressing those specific warnings/errors, we need to step back and address some larger issues.

The first issue to fix is that your commit is on the master branch, not the dev branch. If you look at the top of the Pull Request, it says that it is merging your master branch into my dev branch:

image

We need to merge your dev branch into my dev branch. How comfortable are you with Git? Have you ever used Git branches before? Do you run your Git commands in a terminal (e.g. Git Bash) or do you use a GUI?

My bad. I misunderstand the point on the contribution.md. So what I need to do is to pull my dev branch to your dev branch.
I just use git and GitHub for several months. All git commands are done in the RStudio Terminal, but I am not familiar with the branch. I will do some searching for it.

@JiaxiangBU
Copy link
Contributor Author

JiaxiangBU commented Mar 25, 2019

yaml_front_matter

I think your recommendation, the function yaml_front_matter is a better option. I will edit the function I write before, and pull it in the dev branch.

By the way, I agree with you, the relative URL is a better choice, I will fix this.

@jdblischak
Copy link
Member

Here's my recommendation for how to update your branches. The commands below are meant to be run in the RStudio Terminal unless otherwise stated:

  1. Switch to the dev branch:

    git checkout dev
    

    You can confirm you are on the dev branch by running git branch.

  2. Copy your main commit to the dev branch:

    git cherry-pick 4b1dbd7b42406898e71839c4f980ad956f5b3a09
    

    You can confirm you copied the commit by running git log -n 1.

  3. Update the documentation by running document() in the R console (don't run document.R, since that also rebuilds the website, which is not needed for your PR)

  4. Commit NAMESPACE

    git add NAMESPACE
    git commit -m "Export wflow_toc()."
    
  5. Push your dev branch to GitHub.

    git push origin dev
    
  6. Open a new Pull Request on GitHub, from your dev branch to my dev branch

@jdblischak
Copy link
Member

Also, here is an easier strategy for getting the list of published analyses to create the toc:

s <- wflow_status()
rmd <- rownames(s$status)[s$status$published]
html <- to_html(rmd, outdir = s$docs)
html <- fs::path_file(html)

@JiaxiangBU
Copy link
Contributor Author

JiaxiangBU commented Apr 1, 2019

Seemingly if I want to pull my dev branch to yours, I have to create a new pull request and close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants