-
-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2709 from pre-commit/test-lua
test lua directly
- Loading branch information
Showing
6 changed files
with
58 additions
and
53 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from __future__ import annotations | ||
|
||
import sys | ||
|
||
import pytest | ||
|
||
from pre_commit.languages import lua | ||
from pre_commit.util import make_executable | ||
from testing.language_helpers import run_language | ||
|
||
pytestmark = pytest.mark.skipif( | ||
sys.platform == 'win32', | ||
reason='lua is not supported on windows', | ||
) | ||
|
||
|
||
def test_lua(tmp_path): # pragma: win32 no cover | ||
rockspec = '''\ | ||
package = "hello" | ||
version = "dev-1" | ||
source = { | ||
url = "git+ssh://git@github.com/pre-commit/pre-commit.git" | ||
} | ||
description = {} | ||
dependencies = {} | ||
build = { | ||
type = "builtin", | ||
modules = {}, | ||
install = { | ||
bin = {"bin/hello-world-lua"} | ||
}, | ||
} | ||
''' | ||
hello_world_lua = '''\ | ||
#!/usr/bin/env lua | ||
print('hello world') | ||
''' | ||
tmp_path.joinpath('hello-dev-1.rockspec').write_text(rockspec) | ||
bin_dir = tmp_path.joinpath('bin') | ||
bin_dir.mkdir() | ||
bin_file = bin_dir.joinpath('hello-world-lua') | ||
bin_file.write_text(hello_world_lua) | ||
make_executable(bin_file) | ||
|
||
expected = (0, b'hello world\n') | ||
assert run_language(tmp_path, lua, 'hello-world-lua') == expected | ||
|
||
|
||
def test_lua_additional_dependencies(tmp_path): # pragma: win32 no cover | ||
ret, out = run_language( | ||
tmp_path, | ||
lua, | ||
'luacheck --version', | ||
deps=('luacheck',), | ||
) | ||
assert ret == 0 | ||
assert out.startswith(b'Luacheck: ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters