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

Identical files show non-visible diff #133

Closed
noamross opened this issue Apr 21, 2019 · 2 comments
Closed

Identical files show non-visible diff #133

noamross opened this issue Apr 21, 2019 · 2 comments

Comments

@noamross
Copy link

When I compare two files that should have the same contents, diffFile reports a non-visible difference. Is this expected behavior? Is there a way to suppress reporting of this invisible difference, if it represents something real?

library(diffobj)
#> Warning: package 'diffobj' was built under R version 3.5.2
x <- tempfile()
cat("Hello\nthere\n", file = x)
diffFile(x, x, format = "raw")
#> No visible differences between objects.
#> < x              
#> > x              
#> @@ 1,2 / 1,2 @@  
#>   Hello          
#>   there
y <- tempfile()
file.copy(x, y)
#> [1] TRUE
diffFile(x, y, format = "raw")
#> No visible differences between objects, but objects are *not* `all.equal`:
#> - 1 string mismatch
#> < x              
#> > y              
#> @@ 1,2 / 1,2 @@  
#>   Hello          
#>   there

Created on 2019-04-21 by the reprex package (v0.2.1)

Session info
devtools::session_info()
#> ─ Session info ──────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.5.1 (2018-07-02)
#>  os       macOS  10.14.3              
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       America/New_York            
#>  date     2019-04-21                  
#> 
#> ─ Packages ──────────────────────────────────────────────────────────────
#>  package     * version    date       lib source                         
#>  assertthat    0.2.1      2019-03-21 [1] CRAN (R 3.5.1)                 
#>  backports     1.1.3      2018-12-14 [1] CRAN (R 3.5.0)                 
#>  callr         3.2.0      2019-03-15 [1] CRAN (R 3.5.2)                 
#>  cli           1.1.0      2019-03-19 [1] CRAN (R 3.5.2)                 
#>  crayon        1.3.4      2017-09-16 [1] CRAN (R 3.5.0)                 
#>  desc          1.2.0      2018-05-01 [1] CRAN (R 3.5.0)                 
#>  devtools      2.0.1      2018-10-26 [1] CRAN (R 3.5.1)                 
#>  diffobj     * 0.2.2      2019-03-15 [1] CRAN (R 3.5.2)                 
#>  digest        0.6.18     2018-10-10 [1] CRAN (R 3.5.0)                 
#>  evaluate      0.13       2019-02-12 [1] CRAN (R 3.5.2)                 
#>  fs            1.2.7      2019-03-19 [1] CRAN (R 3.5.1)                 
#>  glue          1.3.1      2019-03-12 [1] CRAN (R 3.5.1)                 
#>  highr         0.8        2019-03-20 [1] CRAN (R 3.5.1)                 
#>  htmltools     0.3.6      2017-04-28 [1] CRAN (R 3.5.0)                 
#>  knitr         1.22       2019-03-08 [1] CRAN (R 3.5.2)                 
#>  magrittr      1.5        2014-11-22 [1] CRAN (R 3.5.0)                 
#>  memoise       1.1.0.9000 2018-11-17 [1] Github (hadley/memoise@1650ad7)
#>  pkgbuild      1.0.3      2019-03-20 [1] CRAN (R 3.5.1)                 
#>  pkgload       1.0.2      2018-10-29 [1] CRAN (R 3.5.0)                 
#>  prettyunits   1.0.2      2015-07-13 [1] CRAN (R 3.5.0)                 
#>  processx      3.3.0      2019-03-10 [1] CRAN (R 3.5.2)                 
#>  ps            1.3.0      2018-12-21 [1] CRAN (R 3.5.0)                 
#>  R6            2.4.0      2019-02-14 [1] CRAN (R 3.5.1)                 
#>  Rcpp          1.0.1      2019-03-17 [1] CRAN (R 3.5.1)                 
#>  remotes       2.0.2      2018-10-30 [1] CRAN (R 3.5.0)                 
#>  rlang         0.3.3      2019-03-29 [1] CRAN (R 3.5.1)                 
#>  rmarkdown     1.12       2019-03-14 [1] CRAN (R 3.5.2)                 
#>  rprojroot     1.3-2      2018-01-03 [1] CRAN (R 3.5.0)                 
#>  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 3.5.0)                 
#>  stringi       1.4.3      2019-03-12 [1] CRAN (R 3.5.2)                 
#>  stringr       1.4.0      2019-02-10 [1] CRAN (R 3.5.2)                 
#>  testthat      2.0.1      2018-10-13 [1] CRAN (R 3.5.0)                 
#>  usethis       1.4.0.9000 2019-04-01 [1] Github (r-lib/usethis@fb57048) 
#>  withr         2.1.2      2018-03-15 [1] CRAN (R 3.5.0)                 
#>  xfun          0.5        2019-02-20 [1] CRAN (R 3.5.2)                 
#>  yaml          2.2.0      2018-07-25 [1] CRAN (R 3.5.0)                 
#> 
#> [1] /Library/Frameworks/R.framework/Versions/3.5/Resources/library
@noamross
Copy link
Author

Oh, I note that this doesn't seem to have anything to do with white space:

diffFile(x, y, format = "raw", trim = FALSE, ignore.white.space = TRUE,
         convert.hz.white.space = FALSE)
#> No visible differences between objects, but objects are *not* `all.equal`:
#> - 1 string mismatch
#> < x              
#> > y              
#> @@ 1,2 / 1,2 @@  
#>   Hello          
#>   there

@brodieG brodieG added the bug label Apr 22, 2019
@brodieG brodieG added this to the 0.2.3 milestone Apr 22, 2019
@brodieG
Copy link
Owner

brodieG commented Apr 22, 2019

This is a bug, diffFile is passing the file names instead of the contents to all.equal for the backup verification step.

Browse[3]> target
[1] "/var/folders/47/5by_gx_x4wncdt46pzcb9bcr0000gq/T//RtmpAJCYjp/file9c95661fdfc9"
Browse[3]> current
[1] "/var/folders/47/5by_gx_x4wncdt46pzcb9bcr0000gq/T//RtmpAJCYjp/file9c95369d3980"

Thanks for reporting with reprex. I'll look into fixing it over the next couple of weeks.

brodieG added a commit that referenced this issue May 13, 2019
Fix #135, Fix #134, Fix #136, Fix #133, Fix #132
see NEWS for details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants