summaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/language_helpers.py6
-rw-r--r--testing/resources/node_hooks_repo/.pre-commit-hooks.yaml5
-rw-r--r--testing/resources/node_hooks_repo/bin/main.js3
-rw-r--r--testing/resources/node_hooks_repo/package.json5
-rw-r--r--testing/resources/node_versioned_hooks_repo/.pre-commit-hooks.yaml6
-rw-r--r--testing/resources/node_versioned_hooks_repo/bin/main.js4
-rw-r--r--testing/resources/node_versioned_hooks_repo/package.json5
-rw-r--r--testing/resources/ruby_hooks_repo/.gitignore1
-rw-r--r--testing/resources/ruby_hooks_repo/.pre-commit-hooks.yaml5
-rwxr-xr-xtesting/resources/ruby_hooks_repo/bin/ruby_hook3
-rw-r--r--testing/resources/ruby_hooks_repo/lib/.gitignore0
-rw-r--r--testing/resources/ruby_hooks_repo/ruby_hook.gemspec9
-rw-r--r--testing/resources/ruby_versioned_hooks_repo/.gitignore1
-rw-r--r--testing/resources/ruby_versioned_hooks_repo/.pre-commit-hooks.yaml6
-rwxr-xr-xtesting/resources/ruby_versioned_hooks_repo/bin/ruby_hook4
-rw-r--r--testing/resources/ruby_versioned_hooks_repo/lib/.gitignore0
-rw-r--r--testing/resources/ruby_versioned_hooks_repo/ruby_hook.gemspec9
-rw-r--r--testing/resources/rust_hooks_repo/.pre-commit-hooks.yaml5
-rw-r--r--testing/resources/rust_hooks_repo/Cargo.lock3
-rw-r--r--testing/resources/rust_hooks_repo/Cargo.toml3
-rw-r--r--testing/resources/rust_hooks_repo/src/main.rs3
21 files changed, 4 insertions, 82 deletions
diff --git a/testing/language_helpers.py b/testing/language_helpers.py
index f9ae0b1..b9c5384 100644
--- a/testing/language_helpers.py
+++ b/testing/language_helpers.py
@@ -3,7 +3,6 @@ from __future__ import annotations
import os
from typing import Sequence
-import pre_commit.constants as C
from pre_commit.languages.all import Language
from pre_commit.prefix import Prefix
@@ -14,13 +13,16 @@ def run_language(
exe: str,
args: Sequence[str] = (),
file_args: Sequence[str] = (),
- version: str = C.DEFAULT,
+ version: str | None = None,
deps: Sequence[str] = (),
is_local: bool = False,
) -> tuple[int, bytes]:
prefix = Prefix(str(path))
+ version = version or language.get_default_version()
language.install_environment(prefix, version, deps)
+ health_error = language.health_check(prefix, version)
+ assert health_error is None, health_error
with language.in_env(prefix, version):
ret, out = language.run_hook(
prefix,
diff --git a/testing/resources/node_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/node_hooks_repo/.pre-commit-hooks.yaml
deleted file mode 100644
index 257698a..0000000
--- a/testing/resources/node_hooks_repo/.pre-commit-hooks.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-- id: foo
- name: Foo
- entry: foo
- language: node
- files: \.js$
diff --git a/testing/resources/node_hooks_repo/bin/main.js b/testing/resources/node_hooks_repo/bin/main.js
deleted file mode 100644
index 8e0f025..0000000
--- a/testing/resources/node_hooks_repo/bin/main.js
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env node
-
-console.log('Hello World');
diff --git a/testing/resources/node_hooks_repo/package.json b/testing/resources/node_hooks_repo/package.json
deleted file mode 100644
index 050b630..0000000
--- a/testing/resources/node_hooks_repo/package.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "name": "foo",
- "version": "0.0.1",
- "bin": {"foo": "./bin/main.js"}
-}
diff --git a/testing/resources/node_versioned_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/node_versioned_hooks_repo/.pre-commit-hooks.yaml
deleted file mode 100644
index e7ad5ea..0000000
--- a/testing/resources/node_versioned_hooks_repo/.pre-commit-hooks.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-- id: versioned-node-hook
- name: Versioned node hook
- entry: versioned-node-hook
- language: node
- language_version: 9.3.0
- files: \.js$
diff --git a/testing/resources/node_versioned_hooks_repo/bin/main.js b/testing/resources/node_versioned_hooks_repo/bin/main.js
deleted file mode 100644
index df12cbe..0000000
--- a/testing/resources/node_versioned_hooks_repo/bin/main.js
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/usr/bin/env node
-
-console.log(process.version);
-console.log('Hello World');
diff --git a/testing/resources/node_versioned_hooks_repo/package.json b/testing/resources/node_versioned_hooks_repo/package.json
deleted file mode 100644
index 18c7787..0000000
--- a/testing/resources/node_versioned_hooks_repo/package.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "name": "versioned-node-hook",
- "version": "0.0.1",
- "bin": {"versioned-node-hook": "./bin/main.js"}
-}
diff --git a/testing/resources/ruby_hooks_repo/.gitignore b/testing/resources/ruby_hooks_repo/.gitignore
deleted file mode 100644
index c111b33..0000000
--- a/testing/resources/ruby_hooks_repo/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.gem
diff --git a/testing/resources/ruby_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/ruby_hooks_repo/.pre-commit-hooks.yaml
deleted file mode 100644
index aa15872..0000000
--- a/testing/resources/ruby_hooks_repo/.pre-commit-hooks.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-- id: ruby_hook
- name: Ruby Hook
- entry: ruby_hook
- language: ruby
- files: \.rb$
diff --git a/testing/resources/ruby_hooks_repo/bin/ruby_hook b/testing/resources/ruby_hooks_repo/bin/ruby_hook
deleted file mode 100755
index 5a7e5ed..0000000
--- a/testing/resources/ruby_hooks_repo/bin/ruby_hook
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-
-puts 'Hello world from a ruby hook'
diff --git a/testing/resources/ruby_hooks_repo/lib/.gitignore b/testing/resources/ruby_hooks_repo/lib/.gitignore
deleted file mode 100644
index e69de29..0000000
--- a/testing/resources/ruby_hooks_repo/lib/.gitignore
+++ /dev/null
diff --git a/testing/resources/ruby_hooks_repo/ruby_hook.gemspec b/testing/resources/ruby_hooks_repo/ruby_hook.gemspec
deleted file mode 100644
index 75f4e8f..0000000
--- a/testing/resources/ruby_hooks_repo/ruby_hook.gemspec
+++ /dev/null
@@ -1,9 +0,0 @@
-Gem::Specification.new do |s|
- s.name = 'ruby_hook'
- s.version = '0.1.0'
- s.authors = ['Anthony Sottile']
- s.summary = 'A ruby hook!'
- s.description = 'A ruby hook!'
- s.files = ['bin/ruby_hook']
- s.executables = ['ruby_hook']
-end
diff --git a/testing/resources/ruby_versioned_hooks_repo/.gitignore b/testing/resources/ruby_versioned_hooks_repo/.gitignore
deleted file mode 100644
index c111b33..0000000
--- a/testing/resources/ruby_versioned_hooks_repo/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.gem
diff --git a/testing/resources/ruby_versioned_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/ruby_versioned_hooks_repo/.pre-commit-hooks.yaml
deleted file mode 100644
index c97939a..0000000
--- a/testing/resources/ruby_versioned_hooks_repo/.pre-commit-hooks.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-- id: ruby_hook
- name: Ruby Hook
- entry: ruby_hook
- language: ruby
- language_version: 3.2.0
- files: \.rb$
diff --git a/testing/resources/ruby_versioned_hooks_repo/bin/ruby_hook b/testing/resources/ruby_versioned_hooks_repo/bin/ruby_hook
deleted file mode 100755
index 2406f04..0000000
--- a/testing/resources/ruby_versioned_hooks_repo/bin/ruby_hook
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/usr/bin/env ruby
-
-puts RUBY_VERSION
-puts 'Hello world from a ruby hook'
diff --git a/testing/resources/ruby_versioned_hooks_repo/lib/.gitignore b/testing/resources/ruby_versioned_hooks_repo/lib/.gitignore
deleted file mode 100644
index e69de29..0000000
--- a/testing/resources/ruby_versioned_hooks_repo/lib/.gitignore
+++ /dev/null
diff --git a/testing/resources/ruby_versioned_hooks_repo/ruby_hook.gemspec b/testing/resources/ruby_versioned_hooks_repo/ruby_hook.gemspec
deleted file mode 100644
index 75f4e8f..0000000
--- a/testing/resources/ruby_versioned_hooks_repo/ruby_hook.gemspec
+++ /dev/null
@@ -1,9 +0,0 @@
-Gem::Specification.new do |s|
- s.name = 'ruby_hook'
- s.version = '0.1.0'
- s.authors = ['Anthony Sottile']
- s.summary = 'A ruby hook!'
- s.description = 'A ruby hook!'
- s.files = ['bin/ruby_hook']
- s.executables = ['ruby_hook']
-end
diff --git a/testing/resources/rust_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/rust_hooks_repo/.pre-commit-hooks.yaml
deleted file mode 100644
index df1269f..0000000
--- a/testing/resources/rust_hooks_repo/.pre-commit-hooks.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-- id: rust-hook
- name: rust example hook
- entry: rust-hello-world
- language: rust
- files: ''
diff --git a/testing/resources/rust_hooks_repo/Cargo.lock b/testing/resources/rust_hooks_repo/Cargo.lock
deleted file mode 100644
index 36fbfda..0000000
--- a/testing/resources/rust_hooks_repo/Cargo.lock
+++ /dev/null
@@ -1,3 +0,0 @@
-[[package]]
-name = "rust-hello-world"
-version = "0.1.0"
diff --git a/testing/resources/rust_hooks_repo/Cargo.toml b/testing/resources/rust_hooks_repo/Cargo.toml
deleted file mode 100644
index cd83b43..0000000
--- a/testing/resources/rust_hooks_repo/Cargo.toml
+++ /dev/null
@@ -1,3 +0,0 @@
-[package]
-name = "rust-hello-world"
-version = "0.1.0"
diff --git a/testing/resources/rust_hooks_repo/src/main.rs b/testing/resources/rust_hooks_repo/src/main.rs
deleted file mode 100644
index ad379d6..0000000
--- a/testing/resources/rust_hooks_repo/src/main.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-fn main() {
- println!("hello world");
-}