Merge pull request 'cli' (#15) from cli into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/15
This commit is contained in:
@@ -41,7 +41,7 @@ let
|
|||||||
propagatedBuildInputs =
|
propagatedBuildInputs =
|
||||||
dependencies
|
dependencies
|
||||||
++ [ ];
|
++ [ ];
|
||||||
passthru.tests = { inherit check; };
|
passthru.tests = { inherit clan-tests clan-mypy; };
|
||||||
passthru.devDependencies = devDependencies;
|
passthru.devDependencies = devDependencies;
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
installShellCompletion --bash --name clan \
|
installShellCompletion --bash --name clan \
|
||||||
@@ -53,16 +53,19 @@ let
|
|||||||
|
|
||||||
checkPython = python3.withPackages (_ps: devDependencies ++ dependencies);
|
checkPython = python3.withPackages (_ps: devDependencies ++ dependencies);
|
||||||
|
|
||||||
check = runCommand "${name}-check" { } ''
|
clan-mypy = runCommand "${name}-mypy" { } ''
|
||||||
cp -r ${src} ./src
|
cp -r ${src} ./src
|
||||||
chmod +w -R ./src
|
chmod +w -R ./src
|
||||||
cd src
|
cd src
|
||||||
export PYTHONPATH=.
|
|
||||||
echo -e "\x1b[32m## run ruff\x1b[0m"
|
|
||||||
${ruff}/bin/ruff check .
|
|
||||||
echo -e "\x1b[32m## run mypy\x1b[0m"
|
|
||||||
${checkPython}/bin/mypy .
|
${checkPython}/bin/mypy .
|
||||||
echo -e "\x1b[32m## run pytest\x1b[0m"
|
touch $out
|
||||||
|
'';
|
||||||
|
|
||||||
|
clan-tests = runCommand "${name}-tests" { } ''
|
||||||
|
cp -r ${src} ./src
|
||||||
|
chmod +w -R ./src
|
||||||
|
cd src
|
||||||
|
find .
|
||||||
${checkPython}/bin/pytest
|
${checkPython}/bin/pytest
|
||||||
touch $out
|
touch $out
|
||||||
'';
|
'';
|
||||||
|
|||||||
@@ -7,6 +7,6 @@
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages.${name} = package;
|
packages.${name} = package;
|
||||||
checks.${name} = package.tests.check;
|
checks = package.tests;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
import clan_admin
|
from clan_cli import admin
|
||||||
|
|
||||||
|
|
||||||
def test_make_parser():
|
def test_make_parser():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
clan_admin.make_parser(parser)
|
admin.register_parser(parser)
|
||||||
|
|
||||||
|
|
||||||
# using fp fixture from pytest-subprocess
|
# using fp fixture from pytest-subprocess
|
||||||
@@ -13,5 +13,5 @@ def test_create(fp):
|
|||||||
cmd = ["nix", "flake", "init", "-t", fp.any()]
|
cmd = ["nix", "flake", "init", "-t", fp.any()]
|
||||||
fp.register(cmd)
|
fp.register(cmd)
|
||||||
args = argparse.Namespace(folder="./my-clan")
|
args = argparse.Namespace(folder="./my-clan")
|
||||||
clan_admin.create(args)
|
admin.create(args)
|
||||||
assert fp.call_count(cmd) == 1
|
assert fp.call_count(cmd) == 1
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import clan
|
import clan_cli
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
def test_no_args(capsys):
|
def test_no_args(capsys):
|
||||||
clan.clan()
|
clan_cli.main()
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert captured.out.startswith("usage:")
|
assert captured.out.startswith("usage:")
|
||||||
|
|
||||||
@@ -13,6 +13,6 @@ def test_no_args(capsys):
|
|||||||
def test_help(capsys, monkeypatch):
|
def test_help(capsys, monkeypatch):
|
||||||
monkeypatch.setattr(sys, "argv", ["", "--help"])
|
monkeypatch.setattr(sys, "argv", ["", "--help"])
|
||||||
with pytest.raises(SystemExit):
|
with pytest.raises(SystemExit):
|
||||||
clan.clan()
|
clan_cli.main()
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert captured.out.startswith("usage:")
|
assert captured.out.startswith("usage:")
|
||||||
|
|||||||
Reference in New Issue
Block a user