summaryrefslogtreecommitdiffstats
path: root/testing/resources
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 18:05:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 18:05:20 +0000
commitc86df75ab11643fa4649cfe6ed5c4692d4ee342b (patch)
treede847f47ec2669e74b9a3459319579346b7c99df /testing/resources
parentInitial commit. (diff)
downloadpre-commit-c86df75ab11643fa4649cfe6ed5c4692d4ee342b.tar.xz
pre-commit-c86df75ab11643fa4649cfe6ed5c4692d4ee342b.zip
Adding upstream version 3.6.2.upstream/3.6.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--testing/resources/arbitrary_bytes_repo/.pre-commit-hooks.yaml5
-rwxr-xr-xtesting/resources/arbitrary_bytes_repo/hook.sh7
-rw-r--r--testing/resources/arg_per_line_hooks_repo/.pre-commit-hooks.yaml6
-rwxr-xr-xtesting/resources/arg_per_line_hooks_repo/bin/hook.sh5
-rw-r--r--testing/resources/exclude_types_repo/.pre-commit-hooks.yaml6
-rwxr-xr-xtesting/resources/exclude_types_repo/bin/hook.sh3
-rw-r--r--testing/resources/failing_hook_repo/.pre-commit-hooks.yaml5
-rwxr-xr-xtesting/resources/failing_hook_repo/bin/hook.sh4
-rw-r--r--testing/resources/img1.jpgbin0 -> 843 bytes
-rw-r--r--testing/resources/img2.jpgbin0 -> 891 bytes
-rw-r--r--testing/resources/img3.jpgbin0 -> 859 bytes
-rw-r--r--testing/resources/logfile_repo/.pre-commit-hooks.yaml6
-rwxr-xr-xtesting/resources/logfile_repo/bin/hook.sh5
-rw-r--r--testing/resources/modified_file_returns_zero_repo/.pre-commit-hooks.yaml15
-rwxr-xr-xtesting/resources/modified_file_returns_zero_repo/bin/hook.sh7
-rwxr-xr-xtesting/resources/modified_file_returns_zero_repo/bin/hook2.sh2
-rwxr-xr-xtesting/resources/modified_file_returns_zero_repo/bin/hook3.sh6
-rw-r--r--testing/resources/not_found_exe/.pre-commit-hooks.yaml5
-rw-r--r--testing/resources/prints_cwd_repo/.pre-commit-hooks.yaml5
-rw-r--r--testing/resources/python3_hooks_repo/.pre-commit-hooks.yaml6
-rw-r--r--testing/resources/python3_hooks_repo/py3_hook.py8
-rw-r--r--testing/resources/python3_hooks_repo/setup.py8
-rw-r--r--testing/resources/python_hooks_repo/.pre-commit-hooks.yaml5
-rw-r--r--testing/resources/python_hooks_repo/foo.py9
-rw-r--r--testing/resources/python_hooks_repo/setup.py10
-rw-r--r--testing/resources/script_hooks_repo/.pre-commit-hooks.yaml5
-rwxr-xr-xtesting/resources/script_hooks_repo/bin/hook.sh4
-rw-r--r--testing/resources/stdout_stderr_repo/.pre-commit-hooks.yaml8
-rwxr-xr-xtesting/resources/stdout_stderr_repo/stdout-stderr-entry7
-rwxr-xr-xtesting/resources/stdout_stderr_repo/tty-check-entry11
-rw-r--r--testing/resources/system_hook_with_spaces_repo/.pre-commit-hooks.yaml5
-rw-r--r--testing/resources/types_or_repo/.pre-commit-hooks.yaml6
-rwxr-xr-xtesting/resources/types_or_repo/bin/hook.sh3
-rw-r--r--testing/resources/types_repo/.pre-commit-hooks.yaml5
-rwxr-xr-xtesting/resources/types_repo/bin/hook.sh3
35 files changed, 195 insertions, 0 deletions
diff --git a/testing/resources/arbitrary_bytes_repo/.pre-commit-hooks.yaml b/testing/resources/arbitrary_bytes_repo/.pre-commit-hooks.yaml
new file mode 100644
index 0000000..c2aec9b
--- /dev/null
+++ b/testing/resources/arbitrary_bytes_repo/.pre-commit-hooks.yaml
@@ -0,0 +1,5 @@
+- id: hook
+ name: hook
+ entry: ./hook.sh
+ language: script
+ files: \.py$
diff --git a/testing/resources/arbitrary_bytes_repo/hook.sh b/testing/resources/arbitrary_bytes_repo/hook.sh
new file mode 100755
index 0000000..9df0c5a
--- /dev/null
+++ b/testing/resources/arbitrary_bytes_repo/hook.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+# Intentionally write mixed encoding to the output. This should not crash
+# pre-commit and should write bytes to the output.
+# '☃'.encode() + '²'.encode('latin1')
+echo -e '\xe2\x98\x83\xb2'
+# exit 1 to trigger printing
+exit 1
diff --git a/testing/resources/arg_per_line_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/arg_per_line_hooks_repo/.pre-commit-hooks.yaml
new file mode 100644
index 0000000..4c101db
--- /dev/null
+++ b/testing/resources/arg_per_line_hooks_repo/.pre-commit-hooks.yaml
@@ -0,0 +1,6 @@
+- id: arg-per-line
+ name: Args per line hook
+ entry: bin/hook.sh
+ language: script
+ files: ''
+ args: [hello, world]
diff --git a/testing/resources/arg_per_line_hooks_repo/bin/hook.sh b/testing/resources/arg_per_line_hooks_repo/bin/hook.sh
new file mode 100755
index 0000000..47fd21d
--- /dev/null
+++ b/testing/resources/arg_per_line_hooks_repo/bin/hook.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+for i in "$@"; do
+ echo "arg: $i"
+done
diff --git a/testing/resources/exclude_types_repo/.pre-commit-hooks.yaml b/testing/resources/exclude_types_repo/.pre-commit-hooks.yaml
new file mode 100644
index 0000000..ed8794f
--- /dev/null
+++ b/testing/resources/exclude_types_repo/.pre-commit-hooks.yaml
@@ -0,0 +1,6 @@
+- id: python-files
+ name: Python files
+ entry: bin/hook.sh
+ language: script
+ types: [python]
+ exclude_types: [python3]
diff --git a/testing/resources/exclude_types_repo/bin/hook.sh b/testing/resources/exclude_types_repo/bin/hook.sh
new file mode 100755
index 0000000..a828db4
--- /dev/null
+++ b/testing/resources/exclude_types_repo/bin/hook.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+echo "$@"
+exit 1
diff --git a/testing/resources/failing_hook_repo/.pre-commit-hooks.yaml b/testing/resources/failing_hook_repo/.pre-commit-hooks.yaml
new file mode 100644
index 0000000..118cc8b
--- /dev/null
+++ b/testing/resources/failing_hook_repo/.pre-commit-hooks.yaml
@@ -0,0 +1,5 @@
+- id: failing_hook
+ name: Failing hook
+ entry: bin/hook.sh
+ language: script
+ files: .
diff --git a/testing/resources/failing_hook_repo/bin/hook.sh b/testing/resources/failing_hook_repo/bin/hook.sh
new file mode 100755
index 0000000..7dcffeb
--- /dev/null
+++ b/testing/resources/failing_hook_repo/bin/hook.sh
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+echo 'Fail'
+echo "$@"
+exit 1
diff --git a/testing/resources/img1.jpg b/testing/resources/img1.jpg
new file mode 100644
index 0000000..dea4262
--- /dev/null
+++ b/testing/resources/img1.jpg
Binary files differ
diff --git a/testing/resources/img2.jpg b/testing/resources/img2.jpg
new file mode 100644
index 0000000..68568e5
--- /dev/null
+++ b/testing/resources/img2.jpg
Binary files differ
diff --git a/testing/resources/img3.jpg b/testing/resources/img3.jpg
new file mode 100644
index 0000000..392d2cf
--- /dev/null
+++ b/testing/resources/img3.jpg
Binary files differ
diff --git a/testing/resources/logfile_repo/.pre-commit-hooks.yaml b/testing/resources/logfile_repo/.pre-commit-hooks.yaml
new file mode 100644
index 0000000..dcaba2e
--- /dev/null
+++ b/testing/resources/logfile_repo/.pre-commit-hooks.yaml
@@ -0,0 +1,6 @@
+- id: logfile test hook
+ name: Logfile test hook
+ entry: bin/hook.sh
+ language: script
+ files: .
+ log_file: test.log
diff --git a/testing/resources/logfile_repo/bin/hook.sh b/testing/resources/logfile_repo/bin/hook.sh
new file mode 100755
index 0000000..890d941
--- /dev/null
+++ b/testing/resources/logfile_repo/bin/hook.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+echo "This is STDOUT output"
+echo "This is STDERR output" 1>&2
+
+exit 1
diff --git a/testing/resources/modified_file_returns_zero_repo/.pre-commit-hooks.yaml b/testing/resources/modified_file_returns_zero_repo/.pre-commit-hooks.yaml
new file mode 100644
index 0000000..8d79ef3
--- /dev/null
+++ b/testing/resources/modified_file_returns_zero_repo/.pre-commit-hooks.yaml
@@ -0,0 +1,15 @@
+- id: bash_hook
+ name: Bash hook
+ entry: bin/hook.sh
+ language: script
+ files: 'foo.py'
+- id: bash_hook2
+ name: Bash hook
+ entry: bin/hook2.sh
+ language: script
+ files: ''
+- id: bash_hook3
+ name: Bash hook
+ entry: bin/hook3.sh
+ language: script
+ files: 'bar.py'
diff --git a/testing/resources/modified_file_returns_zero_repo/bin/hook.sh b/testing/resources/modified_file_returns_zero_repo/bin/hook.sh
new file mode 100755
index 0000000..98b05f9
--- /dev/null
+++ b/testing/resources/modified_file_returns_zero_repo/bin/hook.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+for f in $@; do
+ # Non UTF-8 bytes
+ echo -e '\x01\x97' > "$f"
+ echo "Modified: $f!"
+done
diff --git a/testing/resources/modified_file_returns_zero_repo/bin/hook2.sh b/testing/resources/modified_file_returns_zero_repo/bin/hook2.sh
new file mode 100755
index 0000000..a9f1dcd
--- /dev/null
+++ b/testing/resources/modified_file_returns_zero_repo/bin/hook2.sh
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+echo "$@"
diff --git a/testing/resources/modified_file_returns_zero_repo/bin/hook3.sh b/testing/resources/modified_file_returns_zero_repo/bin/hook3.sh
new file mode 100755
index 0000000..3180eb3
--- /dev/null
+++ b/testing/resources/modified_file_returns_zero_repo/bin/hook3.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+for f in $@; do
+ # Non UTF-8 bytes
+ echo -e '\x01\x97' > "$f"
+done
diff --git a/testing/resources/not_found_exe/.pre-commit-hooks.yaml b/testing/resources/not_found_exe/.pre-commit-hooks.yaml
new file mode 100644
index 0000000..566f3c1
--- /dev/null
+++ b/testing/resources/not_found_exe/.pre-commit-hooks.yaml
@@ -0,0 +1,5 @@
+- id: not-found-exe
+ name: Not found exe
+ entry: i-dont-exist-lol
+ language: system
+ files: ''
diff --git a/testing/resources/prints_cwd_repo/.pre-commit-hooks.yaml b/testing/resources/prints_cwd_repo/.pre-commit-hooks.yaml
new file mode 100644
index 0000000..7092379
--- /dev/null
+++ b/testing/resources/prints_cwd_repo/.pre-commit-hooks.yaml
@@ -0,0 +1,5 @@
+- id: prints_cwd
+ name: Prints Cwd
+ entry: pwd
+ language: system
+ files: \.sh$
diff --git a/testing/resources/python3_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/python3_hooks_repo/.pre-commit-hooks.yaml
new file mode 100644
index 0000000..2c23700
--- /dev/null
+++ b/testing/resources/python3_hooks_repo/.pre-commit-hooks.yaml
@@ -0,0 +1,6 @@
+- id: python3-hook
+ name: Python 3 Hook
+ entry: python3-hook
+ language: python
+ language_version: python3
+ files: \.py$
diff --git a/testing/resources/python3_hooks_repo/py3_hook.py b/testing/resources/python3_hooks_repo/py3_hook.py
new file mode 100644
index 0000000..8c9cda4
--- /dev/null
+++ b/testing/resources/python3_hooks_repo/py3_hook.py
@@ -0,0 +1,8 @@
+import sys
+
+
+def main():
+ print(sys.version_info[0])
+ print(repr(sys.argv[1:]))
+ print('Hello World')
+ return 0
diff --git a/testing/resources/python3_hooks_repo/setup.py b/testing/resources/python3_hooks_repo/setup.py
new file mode 100644
index 0000000..9125dc1
--- /dev/null
+++ b/testing/resources/python3_hooks_repo/setup.py
@@ -0,0 +1,8 @@
+from setuptools import setup
+
+setup(
+ name='python3_hook',
+ version='0.0.0',
+ py_modules=['py3_hook'],
+ entry_points={'console_scripts': ['python3-hook = py3_hook:main']},
+)
diff --git a/testing/resources/python_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/python_hooks_repo/.pre-commit-hooks.yaml
new file mode 100644
index 0000000..e10ad50
--- /dev/null
+++ b/testing/resources/python_hooks_repo/.pre-commit-hooks.yaml
@@ -0,0 +1,5 @@
+- id: foo
+ name: Foo
+ entry: foo
+ language: python
+ files: \.py$
diff --git a/testing/resources/python_hooks_repo/foo.py b/testing/resources/python_hooks_repo/foo.py
new file mode 100644
index 0000000..40efde3
--- /dev/null
+++ b/testing/resources/python_hooks_repo/foo.py
@@ -0,0 +1,9 @@
+from __future__ import annotations
+
+import sys
+
+
+def main():
+ print(repr(sys.argv[1:]))
+ print('Hello World')
+ return 0
diff --git a/testing/resources/python_hooks_repo/setup.py b/testing/resources/python_hooks_repo/setup.py
new file mode 100644
index 0000000..cff6cad
--- /dev/null
+++ b/testing/resources/python_hooks_repo/setup.py
@@ -0,0 +1,10 @@
+from __future__ import annotations
+
+from setuptools import setup
+
+setup(
+ name='foo',
+ version='0.0.0',
+ py_modules=['foo'],
+ entry_points={'console_scripts': ['foo = foo:main']},
+)
diff --git a/testing/resources/script_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/script_hooks_repo/.pre-commit-hooks.yaml
new file mode 100644
index 0000000..21cad4a
--- /dev/null
+++ b/testing/resources/script_hooks_repo/.pre-commit-hooks.yaml
@@ -0,0 +1,5 @@
+- id: bash_hook
+ name: Bash hook
+ entry: bin/hook.sh
+ language: script
+ files: ''
diff --git a/testing/resources/script_hooks_repo/bin/hook.sh b/testing/resources/script_hooks_repo/bin/hook.sh
new file mode 100755
index 0000000..cbc4b35
--- /dev/null
+++ b/testing/resources/script_hooks_repo/bin/hook.sh
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+
+echo "$@"
+echo 'Hello World'
diff --git a/testing/resources/stdout_stderr_repo/.pre-commit-hooks.yaml b/testing/resources/stdout_stderr_repo/.pre-commit-hooks.yaml
new file mode 100644
index 0000000..6800d25
--- /dev/null
+++ b/testing/resources/stdout_stderr_repo/.pre-commit-hooks.yaml
@@ -0,0 +1,8 @@
+- id: stdout-stderr
+ name: stdout-stderr
+ language: script
+ entry: ./stdout-stderr-entry
+- id: tty-check
+ name: tty-check
+ language: script
+ entry: ./tty-check-entry
diff --git a/testing/resources/stdout_stderr_repo/stdout-stderr-entry b/testing/resources/stdout_stderr_repo/stdout-stderr-entry
new file mode 100755
index 0000000..7563df5
--- /dev/null
+++ b/testing/resources/stdout_stderr_repo/stdout-stderr-entry
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+echo 0
+echo 1 1>&2
+echo 2
+echo 3 1>&2
+echo 4
+echo 5 1>&2
diff --git a/testing/resources/stdout_stderr_repo/tty-check-entry b/testing/resources/stdout_stderr_repo/tty-check-entry
new file mode 100755
index 0000000..01a9d38
--- /dev/null
+++ b/testing/resources/stdout_stderr_repo/tty-check-entry
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+t() {
+ if [ -t "$1" ]; then
+ echo "$2: True"
+ else
+ echo "$2: False"
+ fi
+}
+t 0 stdin
+t 1 stdout
+t 2 stderr
diff --git a/testing/resources/system_hook_with_spaces_repo/.pre-commit-hooks.yaml b/testing/resources/system_hook_with_spaces_repo/.pre-commit-hooks.yaml
new file mode 100644
index 0000000..b2c347c
--- /dev/null
+++ b/testing/resources/system_hook_with_spaces_repo/.pre-commit-hooks.yaml
@@ -0,0 +1,5 @@
+- id: system-hook-with-spaces
+ name: System hook with spaces
+ entry: bash -c 'echo "Hello World"'
+ language: system
+ files: \.sh$
diff --git a/testing/resources/types_or_repo/.pre-commit-hooks.yaml b/testing/resources/types_or_repo/.pre-commit-hooks.yaml
new file mode 100644
index 0000000..a4ea920
--- /dev/null
+++ b/testing/resources/types_or_repo/.pre-commit-hooks.yaml
@@ -0,0 +1,6 @@
+- id: python-cython-files
+ name: Python and Cython files
+ entry: bin/hook.sh
+ language: script
+ types: [file]
+ types_or: [python, cython]
diff --git a/testing/resources/types_or_repo/bin/hook.sh b/testing/resources/types_or_repo/bin/hook.sh
new file mode 100755
index 0000000..a828db4
--- /dev/null
+++ b/testing/resources/types_or_repo/bin/hook.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+echo "$@"
+exit 1
diff --git a/testing/resources/types_repo/.pre-commit-hooks.yaml b/testing/resources/types_repo/.pre-commit-hooks.yaml
new file mode 100644
index 0000000..2e5e4a6
--- /dev/null
+++ b/testing/resources/types_repo/.pre-commit-hooks.yaml
@@ -0,0 +1,5 @@
+- id: python-files
+ name: Python files
+ entry: bin/hook.sh
+ language: script
+ types: [python]
diff --git a/testing/resources/types_repo/bin/hook.sh b/testing/resources/types_repo/bin/hook.sh
new file mode 100755
index 0000000..a828db4
--- /dev/null
+++ b/testing/resources/types_repo/bin/hook.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+echo "$@"
+exit 1