diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 2cbbffbc..133ddf0f 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -465,38 +465,6 @@ jobs: - name: /testLicense run: nix-env -if . && m . /testLicense - linux_testPython_cliMain: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@f095bcc56b7c2baf48f3ac70d6d6782f4f553222 - - uses: docker://docker.io/nixos/nix@sha256:c3db4c484f6b1ee6c9bb8ca90307cfbeca8ef88156840911356a677eeaff4845 - name: /testPython/cliMain - with: - args: sh -c "chown -R root:root /github/workspace && nix-env -if . && m . /testPython/cliMain" - macos_testPython_cliMain: - runs-on: macos-latest - steps: - - uses: actions/checkout@f095bcc56b7c2baf48f3ac70d6d6782f4f553222 - - uses: cachix/install-nix-action@6ed004b9ccb68dbc28e7c85bee15fa93dbd214ac - - name: /testPython/cliMain - run: nix-env -if . && m . /testPython/cliMain - - linux_testPython_example: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@f095bcc56b7c2baf48f3ac70d6d6782f4f553222 - - uses: docker://docker.io/nixos/nix@sha256:c3db4c484f6b1ee6c9bb8ca90307cfbeca8ef88156840911356a677eeaff4845 - name: /testPython/example - with: - args: sh -c "chown -R root:root /github/workspace && nix-env -if . && m . /testPython/example" - macos_testPython_example: - runs-on: macos-latest - steps: - - uses: actions/checkout@f095bcc56b7c2baf48f3ac70d6d6782f4f553222 - - uses: cachix/install-nix-action@6ed004b9ccb68dbc28e7c85bee15fa93dbd214ac - - name: /testPython/example - run: nix-env -if . && m . /testPython/example - linux_tests_calculateCvss3: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index 94a9347c..ed273769 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -649,26 +649,6 @@ jobs: - name: /testLicense run: nix-env -if . && m . /testLicense - linux_testPython_example: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@f095bcc56b7c2baf48f3ac70d6d6782f4f553222 - - uses: docker://docker.io/nixos/nix@sha256:c3db4c484f6b1ee6c9bb8ca90307cfbeca8ef88156840911356a677eeaff4845 - name: /testPython/example - with: - args: sh -c "chown -R root:root /github/workspace && nix-env -if . && m . /testPython/example" - env: - CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }} - macos_testPython_example: - runs-on: macos-latest - steps: - - uses: actions/checkout@f095bcc56b7c2baf48f3ac70d6d6782f4f553222 - - uses: cachix/install-nix-action@6ed004b9ccb68dbc28e7c85bee15fa93dbd214ac - - name: /testPython/example - run: nix-env -if . && m . /testPython/example - env: - CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }} - linux_tests_calculateCvss3: runs-on: ubuntu-latest steps: diff --git a/.mailmap b/.mailmap index f2a78031..18dd034e 100644 --- a/.mailmap +++ b/.mailmap @@ -1,7 +1,7 @@ Andres Cuberos Andres Cuberos <31192632+acuberosatfluid@users.noreply.github.com> Andres Cuberos Andres Cuberos -Andres Uribe Andres Uribe Andres Saldarriaga Andres Saldarriaga +Andres Uribe Andres Uribe Brandon Lotero Brandon Lotero Briam Agudelo Briam Agudelo Daniel Murcia Daniel F. Murcia Rivera diff --git a/docs/src/api/builtins/test.md b/docs/src/api/builtins/test.md index 2535f563..6b738b50 100644 --- a/docs/src/api/builtins/test.md +++ b/docs/src/api/builtins/test.md @@ -26,84 +26,6 @@ Example: m . /testLicense ``` -## testPython - -Test Python code -with [pytest](https://docs.pytest.org/). - -Types: - -- testPython (`attrsOf targetType`): Optional. - Mapping of names to pytest targets. - Defaults to `{ }`. -- targetType (`submodule`): - - python (`enum ["3.9" "3.10" "3.11" "3.12"]`): - Python interpreter version that your package/module is designed for. - - src (`str`): - Path to the file or directory that contains the tests code. - - searchPaths (`asIn makeSearchPaths`): Optional. - Arguments here will be passed as-is to `makeSearchPaths`. - Defaults to `makeSearchPaths`'s defaults. - - extraFlags (`listOf str`): Optional. - Extra command line arguments to propagate to pytest. - Defaults to `[ ]`. - - extraSrcs (`attrsOf package`): Optional. - Place extra sources at the same level of your project code - so you can reference them via relative paths. - - The final test structure looks like this: - - ```bash - /tmp/some-random-unique-dir - ├── __project__ # The entire source code of your project - │  ├── ... - │  └── path/to/src - ... # repeat for all extraSrcs - ├── "${extraSrcName}" - │  └── "${extraSrcValue}" - ... - ``` - - And we will run pytest like this: - - ```bash - pytest /tmp/some-random-unique-dir/__project__/path/to/src - ``` - - Defaults to `{ }`. - -Example: - -=== "makes.nix" - - ```nix - { - testPython = { - example.src = "/test/test-python"; - }; - } - ``` - -=== "Invocation" - - ```bash - m . /testPython/example - ``` - -=== "Directory" - - ```bash - $ tree test/test-python/ - - test/test-python/ - └── test_something.py - - $ cat test/test-python/test_something.py - - 1 def test_one_plus_one_equals_two() -> None: - 2 assert (1 + 1) == 2 - ``` - ## testTerraform Test Terraform code diff --git a/makes.nix b/makes.nix index 3808e94c..bad13d30 100644 --- a/makes.nix +++ b/makes.nix @@ -207,23 +207,6 @@ }; }; testLicense = { enable = true; }; - testPython = { - example = { src = "/test/test-python"; }; - cliMain = { - extraFlags = [ - "--cov=main" - "--cov-branch" - "--cov-report=term-missing" - "--capture=no" - ]; - searchPaths = { - bin = [ __nixpkgs__.git ]; - pythonPackage = [ (projectPath "/src/cli/main") ]; - source = [ outputs."/cli/env/test" outputs."/cli/env/runtime" ]; - }; - src = "/src/cli"; - }; - }; testTerraform = { modules = { module = { diff --git a/makes/utils/makePythonLock/update.sh b/makes/utils/makePythonLock/update.sh index d01adf44..2fdde77f 100644 --- a/makes/utils/makePythonLock/update.sh +++ b/makes/utils/makePythonLock/update.sh @@ -48,19 +48,6 @@ function main { && "${cmd[@]}" 3.12 \ "${PWD}/src/args/make-python-pypi-environment/sources/numpy-1.24.0/dependencies.yaml" \ "${PWD}/src/args/make-python-pypi-environment/sources/numpy-1.24.0/sources-312.yaml" - - : && "${cmd[@]}" 3.9 \ - "${PWD}/src/args/test-python/pypi-deps.yaml" \ - "${PWD}/src/args/test-python/pypi-sources-3.9.yaml" \ - && "${cmd[@]}" 3.10 \ - "${PWD}/src/args/test-python/pypi-deps.yaml" \ - "${PWD}/src/args/test-python/pypi-sources-3.10.yaml" \ - && "${cmd[@]}" 3.11 \ - "${PWD}/src/args/test-python/pypi-deps.yaml" \ - "${PWD}/src/args/test-python/pypi-sources-3.11.yaml" \ - && "${cmd[@]}" 3.12 \ - "${PWD}/src/args/test-python/pypi-deps.yaml" \ - "${PWD}/src/args/test-python/pypi-sources-3.12.yaml" } main "${@}" diff --git a/src/args/agnostic.nix b/src/args/agnostic.nix index baf98fe6..47a59b28 100644 --- a/src/args/agnostic.nix +++ b/src/args/agnostic.nix @@ -128,7 +128,6 @@ let taintTerraform = import ./taint-terraform/default.nix self; testLicense = import ./test-license/default.nix self; testTerraform = import ./test-terraform/default.nix self; - testPython = import ./test-python/default.nix self; toDerivationName = __nixpkgs__.lib.strings.sanitizeDerivationName; toBashArray = import ./to-bash-array/default.nix self; toBashMap = import ./to-bash-map/default.nix self; diff --git a/src/args/test-python/default.nix b/src/args/test-python/default.nix deleted file mode 100644 index 61541654..00000000 --- a/src/args/test-python/default.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ makePythonEnvironment, makeSearchPaths, makeScript, toBashArray, toBashMap -, ... }: -{ extraFlags, extraSrcs, name, project, searchPaths, src, }: -makeScript { - name = "test-python-for-${name}"; - replace = { - __argExtraFlags__ = toBashArray extraFlags; - __argExtraSrcs__ = toBashMap extraSrcs; - __argProject__ = project; - __argSrc__ = src; - }; - entrypoint = ./entrypoint.sh; - searchPaths = { - source = [ - (makePythonEnvironment { - pythonProjectDir = ./.; - pythonVersion = "3.11"; - }) - (makeSearchPaths searchPaths) - ]; - }; -} diff --git a/src/args/test-python/entrypoint.sh b/src/args/test-python/entrypoint.sh deleted file mode 100644 index 51688015..00000000 --- a/src/args/test-python/entrypoint.sh +++ /dev/null @@ -1,24 +0,0 @@ -# shellcheck shell=bash - -function main { - source __argExtraFlags__/template local extra_flags - source __argExtraSrcs__/template extra_srcs - - cd "$(mktemp -d)" \ - && copy __argProject__ __project__ \ - && for extra_src in "${!extra_srcs[@]}"; do - copy "${extra_srcs[$extra_src]}" "${extra_src}" - done \ - && cd __project____argSrc__ \ - && pytest \ - --capture tee-sys \ - --disable-pytest-warnings \ - --durations 10 \ - --exitfirst \ - --showlocals \ - --show-capture no \ - -vvv \ - "${extra_flags[@]}" -} - -main "${@}" diff --git a/src/args/test-python/poetry.lock b/src/args/test-python/poetry.lock deleted file mode 100644 index 431026ea..00000000 --- a/src/args/test-python/poetry.lock +++ /dev/null @@ -1,94 +0,0 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. - -[[package]] -name = "attrs" -version = "23.2.0" -description = "Classes Without Boilerplate" -optional = false -python-versions = ">=3.7" -files = [ - {file = "attrs-23.2.0-py3-none-any.whl", hash = "sha256:99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1"}, - {file = "attrs-23.2.0.tar.gz", hash = "sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30"}, -] - -[package.extras] -cov = ["attrs[tests]", "coverage[toml] (>=5.3)"] -dev = ["attrs[tests]", "pre-commit"] -docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope-interface"] -tests = ["attrs[tests-no-zope]", "zope-interface"] -tests-mypy = ["mypy (>=1.6)", "pytest-mypy-plugins"] -tests-no-zope = ["attrs[tests-mypy]", "cloudpickle", "hypothesis", "pympler", "pytest (>=4.3.0)", "pytest-xdist[psutil]"] - -[[package]] -name = "colorama" -version = "0.4.6" -description = "Cross-platform colored terminal text." -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" -files = [ - {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, - {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, -] - -[[package]] -name = "iniconfig" -version = "2.0.0" -description = "brain-dead simple config-ini parsing" -optional = false -python-versions = ">=3.7" -files = [ - {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, - {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, -] - -[[package]] -name = "packaging" -version = "23.2" -description = "Core utilities for Python packages" -optional = false -python-versions = ">=3.7" -files = [ - {file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"}, - {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, -] - -[[package]] -name = "pluggy" -version = "1.3.0" -description = "plugin and hook calling mechanisms for python" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pluggy-1.3.0-py3-none-any.whl", hash = "sha256:d89c696a773f8bd377d18e5ecda92b7a3793cbe66c87060a6fb58c7b6e1061f7"}, - {file = "pluggy-1.3.0.tar.gz", hash = "sha256:cf61ae8f126ac6f7c451172cf30e3e43d3ca77615509771b3a984a0730651e12"}, -] - -[package.extras] -dev = ["pre-commit", "tox"] -testing = ["pytest", "pytest-benchmark"] - -[[package]] -name = "pytest" -version = "7.2.0" -description = "pytest: simple powerful testing with Python" -optional = false -python-versions = ">=3.7" -files = [ - {file = "pytest-7.2.0-py3-none-any.whl", hash = "sha256:892f933d339f068883b6fd5a459f03d85bfcb355e4981e146d2c7616c21fef71"}, - {file = "pytest-7.2.0.tar.gz", hash = "sha256:c4014eb40e10f11f355ad4e3c2fb2c6c6d1919c73f3b5a433de4708202cade59"}, -] - -[package.dependencies] -attrs = ">=19.2.0" -colorama = {version = "*", markers = "sys_platform == \"win32\""} -iniconfig = "*" -packaging = "*" -pluggy = ">=0.12,<2.0" - -[package.extras] -testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] - -[metadata] -lock-version = "2.0" -python-versions = "^3.11" -content-hash = "31b3d40c9cc52557b657df28967512319964fdf3447804ba5f543f48ccbf3ef7" diff --git a/src/args/test-python/pyproject.toml b/src/args/test-python/pyproject.toml deleted file mode 100644 index 09e8e411..00000000 --- a/src/args/test-python/pyproject.toml +++ /dev/null @@ -1,15 +0,0 @@ -[tool.poetry] -name = "lint-python-imports" -version = "0.1.0" -description = "" -authors = ["Your Name "] -readme = "README.md" - -[tool.poetry.dependencies] -python = "^3.11" -pytest = "7.2.0" - - -[build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" diff --git a/src/cli/test_all.py b/src/cli/test_all.py deleted file mode 100644 index 3f117fee..00000000 --- a/src/cli/test_all.py +++ /dev/null @@ -1,74 +0,0 @@ -from main import ( - cli, - emojis, - tui, -) -import os -import pytest -import shutil - - -def test_imports() -> None: - assert emojis - assert tui - - -def test_tui() -> None: - assert tui.TuiCommand(src=".").render() - assert tui.TuiUsage(src=".").render() - assert tui.TuiHeader().render() - tui_outputs = tui.TuiOutputs() - tui_outputs.outputs = ["/a", "/b"] - assert tui_outputs.render() - assert tui.TuiOutputsTitle().render() - - -def test_help() -> None: - with pytest.raises(SystemExit) as result: - cli.main(["m"]) - assert result.value.code == 1 - - with pytest.raises(SystemExit) as result: - cli.main(["m", "--help"]) - assert result.value.code == 1 - - -def test_dot_wrong() -> None: - with pytest.raises(SystemExit) as result: - cli.main(["m", ".", "/shouldn't/exist"]) - assert result.value.code == 1 - - -def test_dot_hello_world() -> None: - with pytest.raises(SystemExit) as result: - cli.main(["m", ".", "/helloWorld"]) - assert result.value.code == 0 - - -def test_remote_hello_world() -> None: - cache = ( - os.environ["HOME_IMPURE"] - + "/.cache/makes/sources/github-fluidattacks-makes-main" - ) - - shutil.rmtree(cache, ignore_errors=True) - - with pytest.raises(SystemExit) as result: - cli.main(["m", "github:fluidattacks/makes@main", "/helloWorld"]) - assert result.value.code == 0 - - with pytest.raises(SystemExit) as result: - cli.main(["m", "github:fluidattacks/makes@main", "/helloWorld"]) - assert result.value.code == 0 - - with pytest.raises(SystemExit) as result: - cli.main(["m", f"local:{cache}@main", "/helloWorld"]) - assert result.value.code == 0 - - with pytest.raises(SystemExit) as result: - cli.main(["m", f"local:{cache}@shouldn't-exist", "/helloWorld"]) - assert result.value.code == 128 - - with pytest.raises(SystemExit) as result: - cli.main(["m", "gitlab:fluidattacks/shouldn't@exist", "/helloWorld"]) - assert result.value.code == 128 diff --git a/src/comp/bash.sh b/src/comp/bash.sh deleted file mode 100644 index 8ce992b5..00000000 --- a/src/comp/bash.sh +++ /dev/null @@ -1,30 +0,0 @@ -# shellcheck shell=bash - -function __comp_makes_bash { - local opt - local opts - local temp - export COMP_CWORD - export COMP_WORDS - export COMPREPLY=() - - opt="${COMP_WORDS[COMP_CWORD]}" \ - && case "${COMP_CWORD}" in - 1) - temp="$(mktemp)" \ - && opts=(. github: github:owner/repo@rev gitlab: gitlab:owner/repo@rev) \ - && COMP_WORDBREAKS=" " compgen -W "${opts[*]}" -- "${opt}" > "${temp}" \ - && mapfile -t COMPREPLY < "${temp}" - ;; - 2) - temp="$(mktemp)" \ - && m "${COMP_WORDS[1]}" |& grep '^ /' > "${temp}" \ - && mapfile -t opts < "${temp}" \ - && COMP_WORDBREAKS=" " compgen -W "${opts[*]}" -- "${opt}" > "${temp}" \ - && mapfile -t COMPREPLY < "${temp}" - ;; - *) return 1 ;; - esac -} - -complete -F __comp_makes_bash m diff --git a/src/evaluator/modules/default.nix b/src/evaluator/modules/default.nix index 1597d8a8..e2b0d630 100644 --- a/src/evaluator/modules/default.nix +++ b/src/evaluator/modules/default.nix @@ -42,7 +42,6 @@ (import ./secure-python-with-bandit/default.nix args) (import ./taint-terraform/default.nix args) (import ./test-license/default.nix args) - (import ./test-python/default.nix args) (import ./test-terraform/default.nix args) (import ./workspace-for-terraform-from-env args) ]; diff --git a/src/evaluator/modules/test-python/default.nix b/src/evaluator/modules/test-python/default.nix deleted file mode 100644 index 25de464e..00000000 --- a/src/evaluator/modules/test-python/default.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ __toModuleOutputs__, projectPath, testPython, ... }: -{ config, lib, ... }: -let - makeOutput = name: args: { - name = "/testPython/${name}"; - value = testPython { - inherit name; - inherit (args) extraSrcs; - inherit (args) extraFlags; - project = projectPath "/"; - inherit (args) searchPaths; - inherit (args) src; - }; - }; -in { - options = { - testPython = lib.mkOption { - default = { }; - type = lib.types.attrsOf (lib.types.submodule (_: { - options = { - extraSrcs = lib.mkOption { - default = { }; - type = lib.types.attrsOf lib.types.package; - }; - extraFlags = lib.mkOption { - default = [ ]; - type = lib.types.listOf lib.types.str; - }; - searchPaths = lib.mkOption { - default = { }; - type = lib.types.attrs; - }; - src = lib.mkOption { type = lib.types.str; }; - }; - })); - }; - }; - config = { outputs = __toModuleOutputs__ makeOutput config.testPython; }; -} diff --git a/test/test-python/test_something.py b/test/test-python/test_something.py deleted file mode 100644 index 353236c5..00000000 --- a/test/test-python/test_something.py +++ /dev/null @@ -1,2 +0,0 @@ -def test_one_plus_one_equals_two() -> None: - assert (1 + 1) == 2