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

Fix tests #351

Merged
merged 12 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@ name: coverage
on: [push, pull_request]

jobs:
linux:
macos:
if: contains(github.event.head_commit.message, '[ci skip]') == false
strategy:
matrix:
r: [latest]
# r: [3.5, latest, devel]
runs-on: ubuntu-latest
container:
image: rocker/tidyverse:${{ matrix.r }}
# r: [3.5, 3.6, devel]
runs-on: macOS-latest
env:
NOT_CRAN: true
R_LANGSVR_LOG: /tmp/languageserver/log
R_LANGSVR_POOL_SIZE: 1
R_LANGSVR_TEST_FAST: NO
steps:
- uses: actions/checkout@v1
- name: Install apt-get dependencies
run: |
apt-get update
apt-get install git ssh curl bzip2 libffi-dev -y
- uses: r-lib/actions/setup-r@v1
with:
r-version: ${{ matrix.r }}
- name: Install languagesever
run: |
Rscript -e "install.packages(c('remotes'), repos = 'https://cloud.r-project.org')"
Rscript -e "remotes::install_deps(dependencies = TRUE)"
Rscript -e "remotes::install_local()"
- name: Codecov
run: Rscript -e "covr::codecov()"
run: |
mkdir -p /tmp/languageserver
Rscript -e "covr::codecov(quiet = FALSE, clean = FALSE)"
env:
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ env:
- NOT_CRAN=true R_LANGSVR_POOL_SIZE=1 R_LANGSVR_TEST_FAST=NO

after_success:
- Rscript -e 'covr::codecov()'
- travis_wait 30 Rscript -e 'covr::codecov()'
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: languageserver
Title: Language Server Protocol
Version: 0.3.7
Version: 0.3.7.9999
Date: 2020-9-12
Authors@R:
c(person(given = "Randy",
Expand Down Expand Up @@ -44,7 +44,7 @@ Suggests:
processx (>= 3.4.1),
purrr (>= 0.3.3),
testthat (>= 2.1.0),
withr (>= 2.1.2)
withr (>= 2.3.0)
ByteCompile: yes
Encoding: UTF-8
LazyData: true
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/helper-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ respond <- function(client, method, params, timeout, allow_error = FALSE,
start_time <- Sys.time()
remaining <- timeout
client$deliver(client$request(method, params), callback = cb)
if (method == "shutdown") {
# do not expect the server returns anything
return(NULL)
}
while (!isTRUE(storage$done)) {
if (remaining < 0) {
fail("timeout when obtaining response")
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-color.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test_that("Document color works", {
skip_on_cran()
client <- language_client()

withr::local_tempfile("temp_file", fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(
c(
"plot(rnorm(100), col = \"red\")",
Expand Down Expand Up @@ -50,7 +50,7 @@ test_that("Document color works in Rmarkdown", {
skip_on_cran()
client <- language_client()

withr::local_tempfile("temp_file", fileext = ".Rmd")
temp_file <- withr::local_tempfile(fileext = ".Rmd")
writeLines(
c(
"---",
Expand Down
30 changes: 15 additions & 15 deletions tests/testthat/test-completion.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test_that("Simple completion works", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(
c(
"str",
Expand Down Expand Up @@ -64,7 +64,7 @@ test_that("Completion of function arguments works", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(
c(
"str(obj",
Expand Down Expand Up @@ -92,7 +92,7 @@ test_that("Completion of local function arguments works", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(
c(
"local({",
Expand Down Expand Up @@ -122,7 +122,7 @@ test_that("Completion of user function works", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(
c(
"my_fun <- function(x) {}",
Expand All @@ -146,7 +146,7 @@ test_that("Completion of user function contains no duplicate symbols", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(
c(
"my_fun <- function(x) {}",
Expand All @@ -171,7 +171,7 @@ test_that("Completion of symbols in scope works", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(
c(
"xvar0 <- rnorm(10)",
Expand Down Expand Up @@ -216,7 +216,7 @@ test_that("Completion inside a package works", {
wd <- path_real(path_package("languageserver", "projects", "mypackage"))
client <- language_client(working_dir = wd)

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(c("noth"), temp_file)

# client %>% did_save(path(wd, "R", "mypackage.R"))
Expand All @@ -233,7 +233,7 @@ test_that("Completion of imported objects works inside a package", {
wd <- path_real(path_package("languageserver", "projects", "mypackage"))
client <- language_client(working_dir = wd)

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(c("dic"), temp_file)

# client %>% did_save(path(wd, "R", "mypackage.R"))
Expand All @@ -244,7 +244,7 @@ test_that("Completion of imported objects works inside a package", {

expect_length(result$items %>% keep(~.$label == "dict"), 1)

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(c("lint_p"), temp_file)

# client %>% did_save(path(wd, "R", "mypackage.R"))
Expand All @@ -260,7 +260,7 @@ test_that("Completion of tokens in document works", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(
c(
"df1 <- data.frame(var1 = 1:10, var2 = 10:1)",
Expand All @@ -286,7 +286,7 @@ test_that("Completion item resolve works", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(
c(
"bas", # package: base
Expand Down Expand Up @@ -346,7 +346,7 @@ test_that("Completion item resolve extracts symbol documentation", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(
c(
"# comment",
Expand All @@ -373,7 +373,7 @@ test_that("Completion item resolve extracts function documentation", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(
c(
"#' test",
Expand Down Expand Up @@ -415,7 +415,7 @@ test_that("Completion item resolve extracts local function documentation", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(
c(
"local({",
Expand Down Expand Up @@ -459,7 +459,7 @@ test_that("Completion in Rmarkdown works", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".Rmd")
temp_file <- withr::local_tempfile(fileext = ".Rmd")
writeLines(
c(
"Title",
Expand Down
17 changes: 10 additions & 7 deletions tests/testthat/test-definition.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ test_that("Go to Definition works for functions in files", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("defn_file", "defn2_file", "query_file"), fileext = ".R")
defn_file <- withr::local_tempfile(fileext = ".R")
defn2_file <- withr::local_tempfile(fileext = ".R")
query_file <- withr::local_tempfile(fileext = ".R")
writeLines(c("my_fn <- function(x) {", " x + 1", "}"), defn_file)
writeLines(c("my_fn"), query_file)

Expand Down Expand Up @@ -53,7 +55,7 @@ test_that("Go to Definition works for functions in packages", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("query_file"), fileext = ".R")
query_file <- withr::local_tempfile(fileext = ".R")
writeLines(c("print"), query_file)

client %>% did_save(query_file)
Expand All @@ -67,7 +69,7 @@ test_that("Go to Definition works in single file", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("single_file"), fileext = ".R")
single_file <- withr::local_tempfile(fileext = ".R")
writeLines(
c("my_fn <- function(x) {x + 1}", "my_fn", ".nonexistent"),
single_file)
Expand All @@ -90,7 +92,7 @@ test_that("Go to Definition works in scope with different assignment operators",
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("single_file"), fileext = ".R")
single_file <- withr::local_tempfile(fileext = ".R")
writeLines(c(
"my_fn <- function(var1) {",
" var2 <- 1",
Expand Down Expand Up @@ -142,7 +144,7 @@ test_that("Go to Definition works on both sides of assignment", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("single_file"), fileext = ".R")
single_file <- withr::local_tempfile(fileext = ".R")
writeLines(c(
"var1 <- 1",
"var1 <- var1 + 1",
Expand Down Expand Up @@ -208,7 +210,8 @@ test_that("Go to Definition works when package is specified", {

client <- language_client()

withr::local_tempfile(c("defn_file", "query_file"), fileext = ".R")
defn_file <- withr::local_tempfile(fileext = ".R")
query_file <- withr::local_tempfile(fileext = ".R")
writeLines(c("print <- function(x) {", "# Not base::print", "}"), defn_file)
writeLines(c("print", "base::print"), query_file)

Expand All @@ -232,7 +235,7 @@ test_that("Go to Definition in Rmarkdown works", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("single_file"), fileext = ".Rmd")
single_file <- withr::local_tempfile(fileext = ".Rmd")
writeLines(
c(
"```{r}",
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-folding.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test_that("Expression folding rage works", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("defn_file"), fileext = ".R")
defn_file <- withr::local_tempfile(fileext = ".R")
writeLines(c(
"f <- function(x) {",
" x + 1",
Expand All @@ -25,7 +25,7 @@ test_that("Section folding range works", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("defn_file"), fileext = ".R")
defn_file <- withr::local_tempfile(fileext = ".R")
writeLines(c(
"# section1 ####",
"f <- function(x) {",
Expand Down Expand Up @@ -57,7 +57,7 @@ test_that("Comment folding range works", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("defn_file"), fileext = ".R")
defn_file <- withr::local_tempfile(fileext = ".R")
writeLines(c(
"# test 1",
"# test 2",
Expand Down Expand Up @@ -90,7 +90,7 @@ test_that("Folding range works in Rmarkdown", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("defn_file"), fileext = ".Rmd")
defn_file <- withr::local_tempfile(fileext = ".Rmd")
writeLines(c(
"## section1",
"Some text here",
Expand Down
14 changes: 7 additions & 7 deletions tests/testthat/test-formatting.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test_that("Formatting document works", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(c(
"my_fn<-function(x){", # nolint
"f(x+1,x-1)+x",
Expand All @@ -30,7 +30,7 @@ test_that("Formatting selection works for complete line", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(c(
"my_fn <- function(x) {",
" y =x+ 1",
Expand All @@ -53,7 +53,7 @@ test_that("Formatting selection works for partial line", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(c(
"my_fn <- function(x) {",
" y =x+ 1",
Expand All @@ -75,7 +75,7 @@ test_that("Formatting selection preserves initial indentation", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(c(
" my_fn <- function(x) {",
" y =x+ 1",
Expand All @@ -99,7 +99,7 @@ test_that("Formatting selection does not add indentation to multi-line string",
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(c(
"my_fun <- function() {",
" query(con,\"select group, date, time",
Expand All @@ -123,7 +123,7 @@ test_that("On type formatting works", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("temp_file"), fileext = ".R")
temp_file <- withr::local_tempfile(fileext = ".R")
writeLines(c(
"my_fn<-function(x){", # nolint
"f(x+1,x-1)",
Expand Down Expand Up @@ -157,7 +157,7 @@ test_that("Formatting in Rmarkdown works", {
skip_on_cran()
client <- language_client()

withr::local_tempfile(c("single_file"), fileext = ".Rmd")
single_file <- withr::local_tempfile(fileext = ".Rmd")
writeLines(
c(
"```{r}",
Expand Down
Loading