From 4b7342ba37a6573d91d2211c9b965e45e79719cb Mon Sep 17 00:00:00 2001 From: stringertheory Date: Mon, 5 Feb 2024 22:25:18 -0600 Subject: [PATCH] hacky script to help separate tests with dev dependencies --- .check_external_deps.sh | 14 ++++++++++++++ Makefile | 2 ++ 2 files changed, 16 insertions(+) create mode 100755 .check_external_deps.sh diff --git a/.check_external_deps.sh b/.check_external_deps.sh new file mode 100755 index 0000000..d464577 --- /dev/null +++ b/.check_external_deps.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# write all imports that are in non-external-named test files +grep "import " tests/*.py | grep -v "external" > .test_external_deps_imports +# ls tests/*.py | grep -v external | xargs cat | grep "import " | sort | uniq > .test_external_deps_imports + +# # go through every value in this and grep +> .test_external_deps_overlap +for i in `poetry show -T --only dev | tr '-' '_' | awk '{print $1}'`; do + grep $i .test_external_deps_imports >> .test_external_deps_overlap +done; + +cat .test_external_deps_overlap | grep -v "\bpytest\b" | sort | uniq +rm -f .test_external_deps_imports .test_external_deps_overlap diff --git a/Makefile b/Makefile index 13b1289..87c1fa4 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,8 @@ check: ## Run code quality tools. # @poetry run mypy # @echo "🚀 Checking for obsolete dependencies: Running deptry" # @poetry run deptry traces + @echo "🚀 Check if using dev dependencies outside of tests marked external" + @./.check_external_deps.sh .PHONY: test test: ## Test the code with pytest