summaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-08 17:48:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-08 17:49:10 +0000
commit84c011ae6133fb007046d8eb66c01d0de80b3500 (patch)
tree60b2be37885c99f0bf69434223b01cc5a2b92203 /testing
parentReleasing debian version 2.10.1-1. (diff)
downloadpre-commit-84c011ae6133fb007046d8eb66c01d0de80b3500.tar.xz
pre-commit-84c011ae6133fb007046d8eb66c01d0de80b3500.zip
Merging upstream version 2.11.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing')
-rwxr-xr-xtesting/gen-languages-all6
-rw-r--r--testing/get-r.ps16
-rwxr-xr-xtesting/get-r.sh9
-rw-r--r--testing/resources/golang_hooks_repo/go.mod1
-rw-r--r--testing/resources/r_hooks_repo/.pre-commit-hooks.yaml48
-rw-r--r--testing/resources/r_hooks_repo/DESCRIPTION19
-rwxr-xr-xtesting/resources/r_hooks_repo/additional-deps.R2
-rwxr-xr-xtesting/resources/r_hooks_repo/hello-world.R5
-rw-r--r--testing/resources/r_hooks_repo/renv.lock27
-rw-r--r--testing/util.py2
10 files changed, 122 insertions, 3 deletions
diff --git a/testing/gen-languages-all b/testing/gen-languages-all
index d9b01bd..eb7cd70 100755
--- a/testing/gen-languages-all
+++ b/testing/gen-languages-all
@@ -2,9 +2,9 @@
import sys
LANGUAGES = [
- 'conda', 'coursier', 'docker', 'dotnet', 'docker_image', 'fail', 'golang',
- 'node', 'perl', 'pygrep', 'python', 'ruby', 'rust', 'script', 'swift',
- 'system',
+ 'conda', 'coursier', 'docker', 'docker_image', 'dotnet', 'fail', 'golang',
+ 'node', 'perl', 'pygrep', 'python', 'r', 'ruby', 'rust', 'script',
+ 'swift', 'system',
]
FIELDS = [
'ENVIRONMENT_DIR', 'get_default_version', 'healthy', 'install_environment',
diff --git a/testing/get-r.ps1 b/testing/get-r.ps1
new file mode 100644
index 0000000..e7b7b61
--- /dev/null
+++ b/testing/get-r.ps1
@@ -0,0 +1,6 @@
+$dir = $Env:Temp
+$urlR = "https://cran.r-project.org/bin/windows/base/old/4.0.4/R-4.0.4-win.exe"
+$outputR = "$dir\R-win.exe"
+$wcR = New-Object System.Net.WebClient
+$wcR.DownloadFile($urlR, $outputR)
+Start-Process -FilePath $outputR -ArgumentList "/S /v/qn"
diff --git a/testing/get-r.sh b/testing/get-r.sh
new file mode 100755
index 0000000..5d09828
--- /dev/null
+++ b/testing/get-r.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+sudo apt install r-base
+# create empty folder for user library.
+# necessary for non-root users who have
+# never installed an R package before.
+# Alternatively, we require the renv
+# package to be installed already, then we can
+# omit that.
+Rscript -e 'dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE)'
diff --git a/testing/resources/golang_hooks_repo/go.mod b/testing/resources/golang_hooks_repo/go.mod
new file mode 100644
index 0000000..523bfc9
--- /dev/null
+++ b/testing/resources/golang_hooks_repo/go.mod
@@ -0,0 +1 @@
+module golang-hello-world
diff --git a/testing/resources/r_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/r_hooks_repo/.pre-commit-hooks.yaml
new file mode 100644
index 0000000..b3545d9
--- /dev/null
+++ b/testing/resources/r_hooks_repo/.pre-commit-hooks.yaml
@@ -0,0 +1,48 @@
+# parsing file
+- id: parse-file-no-opts-no-args
+ name: Say hi
+ entry: Rscript parse-file-no-opts-no-args.R
+ language: r
+ types: [r]
+- id: parse-file-no-opts-args
+ name: Say hi
+ entry: Rscript parse-file-no-opts-args.R
+ args: [--no-cache]
+ language: r
+ types: [r]
+## parsing expr
+- id: parse-expr-no-opts-no-args-1
+ name: Say hi
+ entry: Rscript -e '1+1'
+ language: r
+ types: [r]
+- id: parse-expr-args-in-entry-2
+ name: Say hi
+ entry: Rscript -e '1+1' -e '3' --no-cache3
+ language: r
+ types: [r]
+# real world
+- id: hello-world
+ name: Say hi
+ entry: Rscript hello-world.R
+ args: [blibla]
+ language: r
+ types: [r]
+- id: hello-world-inline
+ name: Say hi
+ entry: |
+ Rscript -e
+ 'stopifnot(
+ packageVersion("rprojroot") == "1.0",
+ packageVersion("gli.clu") == "0.0.0.9000"
+ )
+ cat(commandArgs(trailingOnly = TRUE), "from R!\n", sep = ", ")
+ '
+ args: ['Hi-there']
+ language: r
+ types: [r]
+- id: additional-deps
+ name: Check additional deps
+ entry: Rscript additional-deps.R
+ language: r
+ types: [r]
diff --git a/testing/resources/r_hooks_repo/DESCRIPTION b/testing/resources/r_hooks_repo/DESCRIPTION
new file mode 100644
index 0000000..0e597a8
--- /dev/null
+++ b/testing/resources/r_hooks_repo/DESCRIPTION
@@ -0,0 +1,19 @@
+Package: gli.clu
+Title: What the Package Does (One Line, Title Case)
+Type: Package
+Version: 0.0.0.9000
+Authors@R:
+ person(given = "First",
+ family = "Last",
+ role = c("aut", "cre"),
+ email = "first.last@example.com",
+ comment = c(ORCID = "YOUR-ORCID-ID"))
+Description: What the package does (one paragraph).
+License: `use_mit_license()`, `use_gpl3_license()` or friends to
+ pick a license
+Encoding: UTF-8
+LazyData: true
+Roxygen: list(markdown = TRUE)
+RoxygenNote: 7.1.1
+Imports:
+ rprojroot
diff --git a/testing/resources/r_hooks_repo/additional-deps.R b/testing/resources/r_hooks_repo/additional-deps.R
new file mode 100755
index 0000000..bc14595
--- /dev/null
+++ b/testing/resources/r_hooks_repo/additional-deps.R
@@ -0,0 +1,2 @@
+suppressPackageStartupMessages(library("cachem"))
+cat("OK\n")
diff --git a/testing/resources/r_hooks_repo/hello-world.R b/testing/resources/r_hooks_repo/hello-world.R
new file mode 100755
index 0000000..bf8d92f
--- /dev/null
+++ b/testing/resources/r_hooks_repo/hello-world.R
@@ -0,0 +1,5 @@
+stopifnot(
+ packageVersion('rprojroot') == '1.0',
+ packageVersion('gli.clu') == '0.0.0.9000'
+)
+cat("Hello, World, from R!\n")
diff --git a/testing/resources/r_hooks_repo/renv.lock b/testing/resources/r_hooks_repo/renv.lock
new file mode 100644
index 0000000..d7d5fdc
--- /dev/null
+++ b/testing/resources/r_hooks_repo/renv.lock
@@ -0,0 +1,27 @@
+{
+ "R": {
+ "Version": "4.0.3",
+ "Repositories": [
+ {
+ "Name": "CRAN",
+ "URL": "https://cloud.r-project.org"
+ }
+ ]
+ },
+ "Packages": {
+ "renv": {
+ "Package": "renv",
+ "Version": "0.12.5",
+ "Source": "Repository",
+ "Repository": "CRAN",
+ "Hash": "5c0cdb37f063c58cdab3c7e9fbb8bd2c"
+ },
+ "rprojroot": {
+ "Package": "rprojroot",
+ "Version": "1.0",
+ "Source": "Repository",
+ "Repository": "CRAN",
+ "Hash": "86704667fe0860e4fec35afdfec137f3"
+ }
+ }
+}
diff --git a/testing/util.py b/testing/util.py
index 1f8cb35..1364453 100644
--- a/testing/util.py
+++ b/testing/util.py
@@ -70,6 +70,7 @@ def run_opts(
show_diff_on_failure=False,
commit_msg_filename='',
checkout_type='',
+ is_squash_merge='',
):
# These are mutually exclusive
assert not (all_files and files)
@@ -88,6 +89,7 @@ def run_opts(
show_diff_on_failure=show_diff_on_failure,
commit_msg_filename=commit_msg_filename,
checkout_type=checkout_type,
+ is_squash_merge=is_squash_merge,
)