From df1373044dc0c154003b50c062ee435ab071bba4 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Mon, 18 Dec 2023 14:21:09 -0500 Subject: [PATCH] Test relative call positions Disclaimer: Participation by NIST in the creation of the documentation of mentioned software is not intended to imply a recommendation or endorsement by the National Institute of Standards and Technology, nor is it intended to imply that any specific software is necessarily the best available for the purpose. Signed-off-by: Alex Nelson --- cdo_local_uuid/__init__.py | 1 + cdo_local_uuid/py.typed | 4 +- setup.cfg | 4 + tests/Makefile | 34 ++++-- tests/README.md | 11 ++ tests/relativity_to_venv/.gitignore | 1 + tests/relativity_to_venv/Makefile | 58 ++++++++++ tests/relativity_to_venv/README.md | 3 + .../editability_no/Makefile | 19 ++++ .../cdo_example_command/__init__.py | 29 +++++ .../cdo_example_command/py.typed | 16 +++ .../editability_no/dir_1/Makefile | 17 +++ .../editability_no/setup.cfg | 28 +++++ .../editability_no/setup.py | 20 ++++ tests/relativity_to_venv/editability_x.mk | 100 ++++++++++++++++++ .../relativity_to_venv/editability_x_dir_1.mk | 51 +++++++++ .../editability_yes/Makefile | 19 ++++ .../cdo_example_command/__init__.py | 29 +++++ .../cdo_example_command/py.typed | 16 +++ .../editability_yes/dir_1/Makefile | 17 +++ .../editability_yes/setup.cfg | 28 +++++ .../editability_yes/setup.py | 20 ++++ tests/relativity_to_venv/test_outputs.py | 78 ++++++++++++++ tests/varying_top_srcdir/.gitignore | 1 + tests/varying_top_srcdir/Makefile | 55 ++++++++++ tests/varying_top_srcdir/README.md | 3 + tests/varying_top_srcdir/project_1/Makefile | 17 +++ .../project_1/dir_1/Makefile | 19 ++++ .../project_1/dir_1/example.py | 23 ++++ .../project_1/dir_2/Makefile | 19 ++++ .../project_1/dir_2/example.py | 23 ++++ tests/varying_top_srcdir/project_1/example.py | 23 ++++ tests/varying_top_srcdir/project_2/Makefile | 17 +++ .../project_2/dir_1/Makefile | 19 ++++ .../project_2/dir_1/example.py | 23 ++++ .../project_2/dir_2/Makefile | 19 ++++ .../project_2/dir_2/example.py | 23 ++++ tests/varying_top_srcdir/project_2/example.py | 23 ++++ tests/varying_top_srcdir/project_x.mk | 74 +++++++++++++ tests/varying_top_srcdir/project_x_dir_y.mk | 57 ++++++++++ tests/varying_top_srcdir/test_outputs.py | 67 ++++++++++++ 41 files changed, 1100 insertions(+), 8 deletions(-) create mode 100644 tests/README.md create mode 100644 tests/relativity_to_venv/.gitignore create mode 100644 tests/relativity_to_venv/Makefile create mode 100644 tests/relativity_to_venv/README.md create mode 100644 tests/relativity_to_venv/editability_no/Makefile create mode 100644 tests/relativity_to_venv/editability_no/cdo_example_command/__init__.py create mode 100644 tests/relativity_to_venv/editability_no/cdo_example_command/py.typed create mode 100644 tests/relativity_to_venv/editability_no/dir_1/Makefile create mode 100644 tests/relativity_to_venv/editability_no/setup.cfg create mode 100644 tests/relativity_to_venv/editability_no/setup.py create mode 100644 tests/relativity_to_venv/editability_x.mk create mode 100644 tests/relativity_to_venv/editability_x_dir_1.mk create mode 100644 tests/relativity_to_venv/editability_yes/Makefile create mode 100644 tests/relativity_to_venv/editability_yes/cdo_example_command/__init__.py create mode 100644 tests/relativity_to_venv/editability_yes/cdo_example_command/py.typed create mode 100644 tests/relativity_to_venv/editability_yes/dir_1/Makefile create mode 100644 tests/relativity_to_venv/editability_yes/setup.cfg create mode 100644 tests/relativity_to_venv/editability_yes/setup.py create mode 100644 tests/relativity_to_venv/test_outputs.py create mode 100644 tests/varying_top_srcdir/.gitignore create mode 100644 tests/varying_top_srcdir/Makefile create mode 100644 tests/varying_top_srcdir/README.md create mode 100644 tests/varying_top_srcdir/project_1/Makefile create mode 100644 tests/varying_top_srcdir/project_1/dir_1/Makefile create mode 100644 tests/varying_top_srcdir/project_1/dir_1/example.py create mode 100644 tests/varying_top_srcdir/project_1/dir_2/Makefile create mode 100644 tests/varying_top_srcdir/project_1/dir_2/example.py create mode 100644 tests/varying_top_srcdir/project_1/example.py create mode 100644 tests/varying_top_srcdir/project_2/Makefile create mode 100644 tests/varying_top_srcdir/project_2/dir_1/Makefile create mode 100644 tests/varying_top_srcdir/project_2/dir_1/example.py create mode 100644 tests/varying_top_srcdir/project_2/dir_2/Makefile create mode 100644 tests/varying_top_srcdir/project_2/dir_2/example.py create mode 100644 tests/varying_top_srcdir/project_2/example.py create mode 100644 tests/varying_top_srcdir/project_x.mk create mode 100644 tests/varying_top_srcdir/project_x_dir_y.mk create mode 100644 tests/varying_top_srcdir/test_outputs.py diff --git a/cdo_local_uuid/__init__.py b/cdo_local_uuid/__init__.py index 6f42b31..8b49e8d 100644 --- a/cdo_local_uuid/__init__.py +++ b/cdo_local_uuid/__init__.py @@ -78,6 +78,7 @@ def configure() -> None: env_base_dir_name = os.getenv("CDO_DEMO_NONRANDOM_UUID_BASE") if env_base_dir_name is None: return + # _logger.debug("env_base_dir_name = %r.", env_base_dir_name) base_dir_original_path = pathlib.Path(env_base_dir_name) if not base_dir_original_path.exists(): diff --git a/cdo_local_uuid/py.typed b/cdo_local_uuid/py.typed index 38c5320..3a6cd3a 100644 --- a/cdo_local_uuid/py.typed +++ b/cdo_local_uuid/py.typed @@ -1,5 +1,5 @@ -# Portions of this file contributed by NIST are governed by the following -# statement: +# Portions of this file contributed by NIST are governed by the +# following statement: # # This software was developed at the National Institute of Standards # and Technology by employees of the Federal Government in the course diff --git a/setup.cfg b/setup.cfg index 75480e9..3ad4e62 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,6 +35,10 @@ testing = [options.package_data] cdo_local_uuid = py.typed +[options.packages.find] +# https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#finding-simple-packages +exclude = tests + [flake8] # https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8 extend-ignore = diff --git a/tests/Makefile b/tests/Makefile index 076fb05..4c20d67 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,7 +1,7 @@ #!/usr/bin/make -f -# Portions of this file contributed by NIST are governed by the following -# statement: +# Portions of this file contributed by NIST are governed by the +# following statement: # # This software was developed at the National Institute of Standards # and Technology by employees of the Federal Government in the course @@ -48,10 +48,10 @@ all: # These check calls are provided in preferred run-order. check: \ check-mypy \ - check-doctest - source venv/bin/activate \ - && pytest \ - --log-level=DEBUG + check-doctest \ + check-pytest \ + check-relativity_to_venv \ + check-varying_top_srcdir check-doctest: \ .venv.done.log @@ -65,11 +65,33 @@ check-mypy: \ .venv.done.log source venv/bin/activate \ && mypy \ + --exclude varying_top_srcdir \ --exclude venv \ --strict \ $(top_srcdir)/cdo_local_uuid \ . +check-pytest: \ + .venv.done.log + source venv/bin/activate \ + && pytest \ + --ignore relativity_to_venv \ + --ignore varying_top_srcdir \ + --log-level=DEBUG + +check-relativity_to_venv: \ + .venv.done.log + $(MAKE) \ + PYTHON3=$(PYTHON3) \ + --directory relativity_to_venv \ + check + +check-varying_top_srcdir: \ + .venv.done.log + $(MAKE) \ + --directory varying_top_srcdir \ + check + clean: @rm -f \ .venv.done.log diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..cc954d5 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,11 @@ +These tests confirm the impact, and mostly non-impact, of the following factors in usage of `cdo-local-uuid`: + +* Whether a project's top source directory has an effect on the UUID seeding (e.g. via indepenent Git clones). + - See `varying_top_srcdir/`. +* Whether the called program is installed in a virtual environment, or a standalone script. + - See `relativity_to_venv/editability_*/cdo_example_command/__init__.py` for the former. + - See `varying_top_srcdir/project_*/example.py` for the latter. +* Whether the virtual environment being in the same directory, or not, has an effect on the UUID seeding. + - See `relativity_to_venv/editability_*/dir_1/Makefile` for call examples. + +`pytest` scripts confirm when various factors are expected to influence and not influence the UUID seeding. diff --git a/tests/relativity_to_venv/.gitignore b/tests/relativity_to_venv/.gitignore new file mode 100644 index 0000000..2211df6 --- /dev/null +++ b/tests/relativity_to_venv/.gitignore @@ -0,0 +1 @@ +*.txt diff --git a/tests/relativity_to_venv/Makefile b/tests/relativity_to_venv/Makefile new file mode 100644 index 0000000..b985f97 --- /dev/null +++ b/tests/relativity_to_venv/Makefile @@ -0,0 +1,58 @@ +#!/usr/bin/make -f + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +SHELL := /bin/bash + +top_srcdir := $(shell cd ../.. ; pwd) + +PYTHON3 ?= python3 + +all: \ + all-editability_no \ + all-editability_yes + +all-editability_no: + $(MAKE) \ + --directory editability_no + +all-editability_yes: + $(MAKE) \ + --directory editability_yes + +check: \ + all + +check: \ + all + source $(top_srcdir)/tests/venv/bin/activate \ + && pytest \ + --log-level=DEBUG \ + --verbose \ + test_outputs.py + +clean: \ + clean-editability_no \ + clean-editability_yes + +clean-editability_no: + @$(MAKE) \ + --directory editability_no \ + clean + +clean-editability_yes: + @$(MAKE) \ + --directory editability_yes \ + clean diff --git a/tests/relativity_to_venv/README.md b/tests/relativity_to_venv/README.md new file mode 100644 index 0000000..d7c6abf --- /dev/null +++ b/tests/relativity_to_venv/README.md @@ -0,0 +1,3 @@ +# Tests: Virtual environment editability + +This directory confirms the editability of a project installed into a virtual environment does not influence programs in the top directory, nor below the top directory. The Python test in this directory confirms generated UUIDs match only when they're expected to, and mismatch in expected cases. diff --git a/tests/relativity_to_venv/editability_no/Makefile b/tests/relativity_to_venv/editability_no/Makefile new file mode 100644 index 0000000..05f58e0 --- /dev/null +++ b/tests/relativity_to_venv/editability_no/Makefile @@ -0,0 +1,19 @@ +#!/usr/bin/make -f + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +installation_editable := no + +include ../editability_x.mk diff --git a/tests/relativity_to_venv/editability_no/cdo_example_command/__init__.py b/tests/relativity_to_venv/editability_no/cdo_example_command/__init__.py new file mode 100644 index 0000000..ca32ea9 --- /dev/null +++ b/tests/relativity_to_venv/editability_no/cdo_example_command/__init__.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +import logging + +import cdo_local_uuid + + +def main() -> None: + logging.basicConfig(level=logging.DEBUG) + cdo_local_uuid.configure() + print(cdo_local_uuid.local_uuid()) + + +if __name__ == "__main__": + main() diff --git a/tests/relativity_to_venv/editability_no/cdo_example_command/py.typed b/tests/relativity_to_venv/editability_no/cdo_example_command/py.typed new file mode 100644 index 0000000..3a6cd3a --- /dev/null +++ b/tests/relativity_to_venv/editability_no/cdo_example_command/py.typed @@ -0,0 +1,16 @@ +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +# This file is defined to support PEP 561: +# https://www.python.org/dev/peps/pep-0561/ diff --git a/tests/relativity_to_venv/editability_no/dir_1/Makefile b/tests/relativity_to_venv/editability_no/dir_1/Makefile new file mode 100644 index 0000000..00c8816 --- /dev/null +++ b/tests/relativity_to_venv/editability_no/dir_1/Makefile @@ -0,0 +1,17 @@ +#!/usr/bin/make -f + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +include ../../editability_x_dir_1.mk diff --git a/tests/relativity_to_venv/editability_no/setup.cfg b/tests/relativity_to_venv/editability_no/setup.cfg new file mode 100644 index 0000000..39c4626 --- /dev/null +++ b/tests/relativity_to_venv/editability_no/setup.cfg @@ -0,0 +1,28 @@ +[metadata] +name = cdo-example-command +version = 0.0.1 +author = Example Developer +author_email = test@example.org +description = Test project +classifiers = + Development Status :: 1 - Planning + Operating System :: OS Independent + Private :: Do Not Upload + Programming Language :: Python :: 3 +# Usage of the classifier 'Private :: Do Not Upload' is to confirm that +# the package configuration for cdo-local-uuid is ignoring this test +# project. If it's picked up, PyPI will reject the package, per: +# https://pypi.org/classifiers/ + +[options] +include_package_data = true +packages = find: +install_requires = + cdo_local_uuid + +[options.entry_points] +console_scripts = + cdo_example_command = cdo_example_command:main + +[options.package_data] +cdo_example_command = py.typed diff --git a/tests/relativity_to_venv/editability_no/setup.py b/tests/relativity_to_venv/editability_no/setup.py new file mode 100644 index 0000000..97f44de --- /dev/null +++ b/tests/relativity_to_venv/editability_no/setup.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +import setuptools + +if __name__ == "__main__": + setuptools.setup() diff --git a/tests/relativity_to_venv/editability_x.mk b/tests/relativity_to_venv/editability_x.mk new file mode 100644 index 0000000..ccbef79 --- /dev/null +++ b/tests/relativity_to_venv/editability_x.mk @@ -0,0 +1,100 @@ +#!/usr/bin/make -f + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +# Purpose: +# +# This Makefile is intended to be loaded with the 'include' Make +# directive in one of the editability_*/Makefile files. The variable +# installation_editable is expected to be 'yes' or 'no'. +# https://www.gnu.org/software/make/manual/html_node/Include.html +# +# This file is not intended to be used with Make by itself. +# +# This Makefile confirms that the same command line generates the same +# UUID sequence, and clarifies that redirection of stdout to a differing +# file path is not considered as part of the sequence seed. It also +# recurses into dir_1/ to test different relative positions (pwd, or +# pwd's parent) for CDO_DEMO_NONRANDOM_UUID_BASE. + +SHELL := /bin/bash + +# NOTE: This top_srcdir is the "real" top source directory, the root +# directory of the cdo-local-uuid repository, for access to the +# cdo_local_uuid project as a local directory. +top_srcdir := $(shell cd ../../.. ; pwd) + +PYTHON3 ?= python3 + +ifeq ($(installation_editable),) +$(error installation_editable undefined ; please define before the Make 'include' directive) +endif +ifeq ($(installation_editable),yes) +editable_flag=--editable +else +editable_flag= +endif + +all: \ + all-dir_1 \ + output_0.txt \ + output_1.txt + +%.txt: \ + .venv.done.log \ + cdo_example_command/__init__.py + export CDO_DEMO_NONRANDOM_UUID_BASE="$$(pwd)" \ + && source venv/bin/activate \ + && cdo_example_command \ + > _$@ + mv _$@ $@ + +.venv.done.log: \ + $(top_srcdir)/setup.cfg \ + $(top_srcdir)/setup.py \ + setup.cfg \ + setup.py + rm -rf venv + $(PYTHON3) -m venv \ + venv + source venv/bin/activate \ + && pip install \ + --upgrade \ + pip \ + setuptools \ + wheel + source venv/bin/activate \ + && pip install \ + $(top_srcdir) + source venv/bin/activate \ + && pip install \ + $(editable_flag) \ + . + touch $@ + +all-dir_1: \ + .venv.done.log + $(MAKE) \ + --directory dir_1 + +check: \ + all + +clean: + @rm -f \ + .venv.done.log \ + *.txt + @rm -rf \ + venv diff --git a/tests/relativity_to_venv/editability_x_dir_1.mk b/tests/relativity_to_venv/editability_x_dir_1.mk new file mode 100644 index 0000000..99565f8 --- /dev/null +++ b/tests/relativity_to_venv/editability_x_dir_1.mk @@ -0,0 +1,51 @@ +#!/usr/bin/make -f + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +# Purpose: +# +# This Makefile is intended to be loaded with the 'include' Make +# directive in one of the editability_*/dir_1/Makefile files. + +SHELL := /bin/bash + +all: \ + output_base_above.txt \ + output_base_here.txt + +check: \ + all + +clean: + @rm -f \ + *.txt + +output_base_above.txt: \ + ../.venv.done.log \ + ../cdo_example_command/__init__.py + export CDO_DEMO_NONRANDOM_UUID_BASE="$$(cd .. ; pwd)" \ + && source ../venv/bin/activate \ + && cdo_example_command \ + > _$@ + mv _$@ $@ + +output_base_here.txt: \ + ../.venv.done.log \ + ../cdo_example_command/__init__.py + export CDO_DEMO_NONRANDOM_UUID_BASE="$$(pwd)" \ + && source ../venv/bin/activate \ + && cdo_example_command \ + > _$@ + mv _$@ $@ diff --git a/tests/relativity_to_venv/editability_yes/Makefile b/tests/relativity_to_venv/editability_yes/Makefile new file mode 100644 index 0000000..4fad3a0 --- /dev/null +++ b/tests/relativity_to_venv/editability_yes/Makefile @@ -0,0 +1,19 @@ +#!/usr/bin/make -f + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +installation_editable := yes + +include ../editability_x.mk diff --git a/tests/relativity_to_venv/editability_yes/cdo_example_command/__init__.py b/tests/relativity_to_venv/editability_yes/cdo_example_command/__init__.py new file mode 100644 index 0000000..ca32ea9 --- /dev/null +++ b/tests/relativity_to_venv/editability_yes/cdo_example_command/__init__.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +import logging + +import cdo_local_uuid + + +def main() -> None: + logging.basicConfig(level=logging.DEBUG) + cdo_local_uuid.configure() + print(cdo_local_uuid.local_uuid()) + + +if __name__ == "__main__": + main() diff --git a/tests/relativity_to_venv/editability_yes/cdo_example_command/py.typed b/tests/relativity_to_venv/editability_yes/cdo_example_command/py.typed new file mode 100644 index 0000000..3a6cd3a --- /dev/null +++ b/tests/relativity_to_venv/editability_yes/cdo_example_command/py.typed @@ -0,0 +1,16 @@ +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +# This file is defined to support PEP 561: +# https://www.python.org/dev/peps/pep-0561/ diff --git a/tests/relativity_to_venv/editability_yes/dir_1/Makefile b/tests/relativity_to_venv/editability_yes/dir_1/Makefile new file mode 100644 index 0000000..00c8816 --- /dev/null +++ b/tests/relativity_to_venv/editability_yes/dir_1/Makefile @@ -0,0 +1,17 @@ +#!/usr/bin/make -f + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +include ../../editability_x_dir_1.mk diff --git a/tests/relativity_to_venv/editability_yes/setup.cfg b/tests/relativity_to_venv/editability_yes/setup.cfg new file mode 100644 index 0000000..39c4626 --- /dev/null +++ b/tests/relativity_to_venv/editability_yes/setup.cfg @@ -0,0 +1,28 @@ +[metadata] +name = cdo-example-command +version = 0.0.1 +author = Example Developer +author_email = test@example.org +description = Test project +classifiers = + Development Status :: 1 - Planning + Operating System :: OS Independent + Private :: Do Not Upload + Programming Language :: Python :: 3 +# Usage of the classifier 'Private :: Do Not Upload' is to confirm that +# the package configuration for cdo-local-uuid is ignoring this test +# project. If it's picked up, PyPI will reject the package, per: +# https://pypi.org/classifiers/ + +[options] +include_package_data = true +packages = find: +install_requires = + cdo_local_uuid + +[options.entry_points] +console_scripts = + cdo_example_command = cdo_example_command:main + +[options.package_data] +cdo_example_command = py.typed diff --git a/tests/relativity_to_venv/editability_yes/setup.py b/tests/relativity_to_venv/editability_yes/setup.py new file mode 100644 index 0000000..97f44de --- /dev/null +++ b/tests/relativity_to_venv/editability_yes/setup.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +import setuptools + +if __name__ == "__main__": + setuptools.setup() diff --git a/tests/relativity_to_venv/test_outputs.py b/tests/relativity_to_venv/test_outputs.py new file mode 100644 index 0000000..8c4afec --- /dev/null +++ b/tests/relativity_to_venv/test_outputs.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python3 + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +import logging +from pathlib import Path +from pprint import pformat +from typing import Set +from uuid import UUID + + +def _load_uuid(filename: str) -> UUID: + with Path(filename).open("r") as fh: + return UUID(fh.read().strip()) + + +def test_expected_matches_seed_is_pwd() -> None: + computed: Set[UUID] = set() + for filename in [ + "editability_no/dir_1/output_base_here.txt", + "editability_no/output_0.txt", + "editability_no/output_1.txt", + "editability_yes/dir_1/output_base_here.txt", + "editability_yes/output_0.txt", + "editability_yes/output_1.txt", + ]: + computed.add(_load_uuid(filename)) + try: + assert ( + len(computed) == 1 + ), "Output where root directory was always process present working directory was affected by virtual environment being in different location from process present working directory, but shouldn't have been affected." + except AssertionError: + logging.debug(pformat(computed)) + raise + + +def test_expected_matches_seed_is_not_pwd() -> None: + computed: Set[UUID] = set() + for filename in [ + "editability_no/dir_1/output_base_above.txt", + "editability_yes/dir_1/output_base_above.txt", + ]: + computed.add(_load_uuid(filename)) + try: + assert ( + len(computed) == 1 + ), "Output where root directory was at different location from process pwd was affected by virtual environment being editable, but shouldn't have been affected." + except AssertionError: + logging.debug(pformat(computed)) + raise + + +def test_expected_mismatches() -> None: + computed: Set[UUID] = set() + for filename in [ + "editability_no/dir_1/output_base_above.txt", + "editability_no/dir_1/output_base_here.txt", + ]: + computed.add(_load_uuid(filename)) + try: + assert ( + len(computed) == 2 + ), "Output where root directory was at different relative locations matched, but shouldn't have." + except AssertionError: + logging.debug(pformat(computed)) + raise diff --git a/tests/varying_top_srcdir/.gitignore b/tests/varying_top_srcdir/.gitignore new file mode 100644 index 0000000..2211df6 --- /dev/null +++ b/tests/varying_top_srcdir/.gitignore @@ -0,0 +1 @@ +*.txt diff --git a/tests/varying_top_srcdir/Makefile b/tests/varying_top_srcdir/Makefile new file mode 100644 index 0000000..bbf88a4 --- /dev/null +++ b/tests/varying_top_srcdir/Makefile @@ -0,0 +1,55 @@ +#!/usr/bin/make -f + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +SHELL := /bin/bash + +top_srcdir := $(shell cd ../.. ; pwd) + +all: \ + all-project_1 \ + all-project_2 + +all-project_1: \ + $(top_srcdir)/tests/.venv.done.log + $(MAKE) \ + --directory project_1 + +all-project_2: \ + $(top_srcdir)/tests/.venv.done.log + $(MAKE) \ + --directory project_2 + +check: \ + all + source $(top_srcdir)/tests/venv/bin/activate \ + && pytest \ + --log-level=DEBUG \ + --verbose \ + test_outputs.py + +clean: \ + clean-project_1 \ + clean-project_2 + +clean-project_1: + @$(MAKE) \ + --directory project_1 \ + clean + +clean-project_2: + @$(MAKE) \ + --directory project_2 \ + clean diff --git a/tests/varying_top_srcdir/README.md b/tests/varying_top_srcdir/README.md new file mode 100644 index 0000000..c276408 --- /dev/null +++ b/tests/varying_top_srcdir/README.md @@ -0,0 +1,3 @@ +# Varying the top source directory + +This directory confirms that when a project source tree is copied to multiple directories (e.g. via independent Git clones), the source tree's top directory as a changing value of `CDO_DEMO_NONRANDOM_UUID_BASE` does not influence programs in the top directory, nor below the top directory. The Python test in this directory confirms generated UUIDs match only when they're expected to, and mismatch in expected cases. diff --git a/tests/varying_top_srcdir/project_1/Makefile b/tests/varying_top_srcdir/project_1/Makefile new file mode 100644 index 0000000..a7c8b3f --- /dev/null +++ b/tests/varying_top_srcdir/project_1/Makefile @@ -0,0 +1,17 @@ +#!/usr/bin/make -f + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +include ../project_x.mk diff --git a/tests/varying_top_srcdir/project_1/dir_1/Makefile b/tests/varying_top_srcdir/project_1/dir_1/Makefile new file mode 100644 index 0000000..64125ed --- /dev/null +++ b/tests/varying_top_srcdir/project_1/dir_1/Makefile @@ -0,0 +1,19 @@ +#!/usr/bin/make -f + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +output_txt := output_1.txt + +include ../../project_x_dir_y.mk diff --git a/tests/varying_top_srcdir/project_1/dir_1/example.py b/tests/varying_top_srcdir/project_1/dir_1/example.py new file mode 100644 index 0000000..5104fd4 --- /dev/null +++ b/tests/varying_top_srcdir/project_1/dir_1/example.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +import logging + +import cdo_local_uuid + +logging.basicConfig(level=logging.DEBUG) +cdo_local_uuid.configure() +print(cdo_local_uuid.local_uuid()) diff --git a/tests/varying_top_srcdir/project_1/dir_2/Makefile b/tests/varying_top_srcdir/project_1/dir_2/Makefile new file mode 100644 index 0000000..e6e8c07 --- /dev/null +++ b/tests/varying_top_srcdir/project_1/dir_2/Makefile @@ -0,0 +1,19 @@ +#!/usr/bin/make -f + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +output_txt := output_2.txt + +include ../../project_x_dir_y.mk diff --git a/tests/varying_top_srcdir/project_1/dir_2/example.py b/tests/varying_top_srcdir/project_1/dir_2/example.py new file mode 100644 index 0000000..5104fd4 --- /dev/null +++ b/tests/varying_top_srcdir/project_1/dir_2/example.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +import logging + +import cdo_local_uuid + +logging.basicConfig(level=logging.DEBUG) +cdo_local_uuid.configure() +print(cdo_local_uuid.local_uuid()) diff --git a/tests/varying_top_srcdir/project_1/example.py b/tests/varying_top_srcdir/project_1/example.py new file mode 100644 index 0000000..5104fd4 --- /dev/null +++ b/tests/varying_top_srcdir/project_1/example.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +import logging + +import cdo_local_uuid + +logging.basicConfig(level=logging.DEBUG) +cdo_local_uuid.configure() +print(cdo_local_uuid.local_uuid()) diff --git a/tests/varying_top_srcdir/project_2/Makefile b/tests/varying_top_srcdir/project_2/Makefile new file mode 100644 index 0000000..a7c8b3f --- /dev/null +++ b/tests/varying_top_srcdir/project_2/Makefile @@ -0,0 +1,17 @@ +#!/usr/bin/make -f + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +include ../project_x.mk diff --git a/tests/varying_top_srcdir/project_2/dir_1/Makefile b/tests/varying_top_srcdir/project_2/dir_1/Makefile new file mode 100644 index 0000000..64125ed --- /dev/null +++ b/tests/varying_top_srcdir/project_2/dir_1/Makefile @@ -0,0 +1,19 @@ +#!/usr/bin/make -f + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +output_txt := output_1.txt + +include ../../project_x_dir_y.mk diff --git a/tests/varying_top_srcdir/project_2/dir_1/example.py b/tests/varying_top_srcdir/project_2/dir_1/example.py new file mode 100644 index 0000000..5104fd4 --- /dev/null +++ b/tests/varying_top_srcdir/project_2/dir_1/example.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +import logging + +import cdo_local_uuid + +logging.basicConfig(level=logging.DEBUG) +cdo_local_uuid.configure() +print(cdo_local_uuid.local_uuid()) diff --git a/tests/varying_top_srcdir/project_2/dir_2/Makefile b/tests/varying_top_srcdir/project_2/dir_2/Makefile new file mode 100644 index 0000000..e6e8c07 --- /dev/null +++ b/tests/varying_top_srcdir/project_2/dir_2/Makefile @@ -0,0 +1,19 @@ +#!/usr/bin/make -f + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +output_txt := output_2.txt + +include ../../project_x_dir_y.mk diff --git a/tests/varying_top_srcdir/project_2/dir_2/example.py b/tests/varying_top_srcdir/project_2/dir_2/example.py new file mode 100644 index 0000000..5104fd4 --- /dev/null +++ b/tests/varying_top_srcdir/project_2/dir_2/example.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +import logging + +import cdo_local_uuid + +logging.basicConfig(level=logging.DEBUG) +cdo_local_uuid.configure() +print(cdo_local_uuid.local_uuid()) diff --git a/tests/varying_top_srcdir/project_2/example.py b/tests/varying_top_srcdir/project_2/example.py new file mode 100644 index 0000000..5104fd4 --- /dev/null +++ b/tests/varying_top_srcdir/project_2/example.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +import logging + +import cdo_local_uuid + +logging.basicConfig(level=logging.DEBUG) +cdo_local_uuid.configure() +print(cdo_local_uuid.local_uuid()) diff --git a/tests/varying_top_srcdir/project_x.mk b/tests/varying_top_srcdir/project_x.mk new file mode 100644 index 0000000..5ff7377 --- /dev/null +++ b/tests/varying_top_srcdir/project_x.mk @@ -0,0 +1,74 @@ +#!/usr/bin/make -f + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +# Usage: +# +# This file is intended to be loaded into 'project_*/Makefile' using the +# Make include directive. +# https://www.gnu.org/software/make/manual/html_node/Include.html +# +# This file is not intended to be used with Make by itself. + +SHELL := /bin/bash + +# NOTE: This top_srcdir is the "real" top source directory, the root +# directory of the cdo-local-uuid repository, for access to the virtual +# environment. +top_srcdir := $(shell cd ../../.. ; pwd) + +all: \ + all-dir_1 \ + all-dir_2 \ + output_0.txt + +all-dir_1: \ + $(top_srcdir)/tests/.venv.done.log + $(MAKE) \ + --directory dir_1 + +all-dir_2: \ + $(top_srcdir)/tests/.venv.done.log + $(MAKE) \ + --directory dir_2 + +check: \ + all + +clean: \ + clean-dir_1 \ + clean-dir_2 + @rm -f \ + *.txt + +clean-dir_1: + @$(MAKE) \ + --directory dir_1 \ + clean + +clean-dir_2: + @$(MAKE) \ + --directory dir_2 \ + clean + +output_0.txt: \ + $(top_srcdir)/cdo_local_uuid/__init__.py \ + $(top_srcdir)/tests/.venv.done.log \ + example.py + export CDO_DEMO_NONRANDOM_UUID_BASE="$$(pwd)" \ + && source $(top_srcdir)/tests/venv/bin/activate \ + && python3 example.py \ + > _$@ + mv _$@ $@ diff --git a/tests/varying_top_srcdir/project_x_dir_y.mk b/tests/varying_top_srcdir/project_x_dir_y.mk new file mode 100644 index 0000000..05b72d8 --- /dev/null +++ b/tests/varying_top_srcdir/project_x_dir_y.mk @@ -0,0 +1,57 @@ +#!/usr/bin/make -f + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +# Usage: +# +# This file is intended to be loaded into 'project_*/dir_*/Makefile' +# using the Make include directive. +# https://www.gnu.org/software/make/manual/html_node/Include.html +# +# A Make variable, output_txt, is expected to be defined before using +# the Make include directive. +# +# This file is not intended to be used with Make by itself. + +SHELL := /bin/bash + +# NOTE: This top_srcdir is the "real" top source directory, the root +# directory of the cdo-local-uuid repository, for access to the virtual +# environment. +top_srcdir := $(shell cd ../../../.. ; pwd) + +output_txt ?= +ifeq ($(output_txt),) +$(error output_txt undefined ; please define before the Make 'include' directive) +endif + +all: \ + $(output_txt) + +%.txt: \ + $(top_srcdir)/cdo_local_uuid/__init__.py \ + $(top_srcdir)/tests/.venv.done.log \ + example.py + export CDO_DEMO_NONRANDOM_UUID_BASE="$$(cd .. ; pwd)" \ + && source $(top_srcdir)/tests/venv/bin/activate \ + && python3 example.py > _$@ + mv _$@ $@ + +check: \ + all + +clean: + @rm -f \ + *.txt diff --git a/tests/varying_top_srcdir/test_outputs.py b/tests/varying_top_srcdir/test_outputs.py new file mode 100644 index 0000000..ad10f29 --- /dev/null +++ b/tests/varying_top_srcdir/test_outputs.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 + +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +from pathlib import Path +from uuid import UUID + +p1: UUID +p1d1: UUID +p1d2: UUID +p2: UUID +p2d1: UUID +p2d2: UUID + +srcdir = Path(__file__).parent + +with (srcdir / "project_1" / "output_0.txt").open("r") as fh: + p1 = UUID(fh.read().strip()) + +with (srcdir / "project_2" / "output_0.txt").open("r") as fh: + p2 = UUID(fh.read().strip()) + +with (srcdir / "project_1" / "dir_1" / "output_1.txt").open("r") as fh: + p1d1 = UUID(fh.read().strip()) + +with (srcdir / "project_1" / "dir_2" / "output_2.txt").open("r") as fh: + p1d2 = UUID(fh.read().strip()) + +with (srcdir / "project_2" / "dir_1" / "output_1.txt").open("r") as fh: + p2d1 = UUID(fh.read().strip()) + +with (srcdir / "project_2" / "dir_2" / "output_2.txt").open("r") as fh: + p2d2 = UUID(fh.read().strip()) + + +def test_p1_p2() -> None: + assert ( + p1 == p2 + ), "Output in root directory varies between project copies, but shouldn't." + + +def test_p1_p1d1() -> None: + assert p1 != p1d1, "Output in root directory matched subdirectory, but shouldn't." + + +def test_p1d1_p2d1() -> None: + assert p1d1 == p2d1, "Output in d1 varies between project copies, but shouldn't." + + +def test_p1d2_p2d2() -> None: + assert p1d2 == p2d2, "Output in d2 varies between project copies, but shouldn't." + + +def test_p1d1_p1d2() -> None: + assert p1d1 != p1d2, "Output in d1 matches d2, but shouldn't."