Skip to content

Commit df13730

Browse files
committed
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 <[email protected]>
1 parent 82918f5 commit df13730

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1100
-8
lines changed

cdo_local_uuid/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def configure() -> None:
7878
env_base_dir_name = os.getenv("CDO_DEMO_NONRANDOM_UUID_BASE")
7979
if env_base_dir_name is None:
8080
return
81+
# _logger.debug("env_base_dir_name = %r.", env_base_dir_name)
8182

8283
base_dir_original_path = pathlib.Path(env_base_dir_name)
8384
if not base_dir_original_path.exists():

cdo_local_uuid/py.typed

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Portions of this file contributed by NIST are governed by the following
2-
# statement:
1+
# Portions of this file contributed by NIST are governed by the
2+
# following statement:
33
#
44
# This software was developed at the National Institute of Standards
55
# and Technology by employees of the Federal Government in the course

setup.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ testing =
3535
[options.package_data]
3636
cdo_local_uuid = py.typed
3737

38+
[options.packages.find]
39+
# https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#finding-simple-packages
40+
exclude = tests
41+
3842
[flake8]
3943
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8
4044
extend-ignore =

tests/Makefile

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/make -f
22

3-
# Portions of this file contributed by NIST are governed by the following
4-
# statement:
3+
# Portions of this file contributed by NIST are governed by the
4+
# following statement:
55
#
66
# This software was developed at the National Institute of Standards
77
# and Technology by employees of the Federal Government in the course
@@ -48,10 +48,10 @@ all:
4848
# These check calls are provided in preferred run-order.
4949
check: \
5050
check-mypy \
51-
check-doctest
52-
source venv/bin/activate \
53-
&& pytest \
54-
--log-level=DEBUG
51+
check-doctest \
52+
check-pytest \
53+
check-relativity_to_venv \
54+
check-varying_top_srcdir
5555

5656
check-doctest: \
5757
.venv.done.log
@@ -65,11 +65,33 @@ check-mypy: \
6565
.venv.done.log
6666
source venv/bin/activate \
6767
&& mypy \
68+
--exclude varying_top_srcdir \
6869
--exclude venv \
6970
--strict \
7071
$(top_srcdir)/cdo_local_uuid \
7172
.
7273

74+
check-pytest: \
75+
.venv.done.log
76+
source venv/bin/activate \
77+
&& pytest \
78+
--ignore relativity_to_venv \
79+
--ignore varying_top_srcdir \
80+
--log-level=DEBUG
81+
82+
check-relativity_to_venv: \
83+
.venv.done.log
84+
$(MAKE) \
85+
PYTHON3=$(PYTHON3) \
86+
--directory relativity_to_venv \
87+
check
88+
89+
check-varying_top_srcdir: \
90+
.venv.done.log
91+
$(MAKE) \
92+
--directory varying_top_srcdir \
93+
check
94+
7395
clean:
7496
@rm -f \
7597
.venv.done.log

tests/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
These tests confirm the impact, and mostly non-impact, of the following factors in usage of `cdo-local-uuid`:
2+
3+
* Whether a project's top source directory has an effect on the UUID seeding (e.g. via indepenent Git clones).
4+
- See `varying_top_srcdir/`.
5+
* Whether the called program is installed in a virtual environment, or a standalone script.
6+
- See `relativity_to_venv/editability_*/cdo_example_command/__init__.py` for the former.
7+
- See `varying_top_srcdir/project_*/example.py` for the latter.
8+
* Whether the virtual environment being in the same directory, or not, has an effect on the UUID seeding.
9+
- See `relativity_to_venv/editability_*/dir_1/Makefile` for call examples.
10+
11+
`pytest` scripts confirm when various factors are expected to influence and not influence the UUID seeding.

tests/relativity_to_venv/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.txt

tests/relativity_to_venv/Makefile

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/make -f
2+
3+
# Portions of this file contributed by NIST are governed by the
4+
# following statement:
5+
#
6+
# This software was developed at the National Institute of Standards
7+
# and Technology by employees of the Federal Government in the course
8+
# of their official duties. Pursuant to Title 17 Section 105 of the
9+
# United States Code, this software is not subject to copyright
10+
# protection within the United States. NIST assumes no responsibility
11+
# whatsoever for its use by other parties, and makes no guarantees,
12+
# expressed or implied, about its quality, reliability, or any other
13+
# characteristic.
14+
#
15+
# We would appreciate acknowledgement if the software is used.
16+
17+
SHELL := /bin/bash
18+
19+
top_srcdir := $(shell cd ../.. ; pwd)
20+
21+
PYTHON3 ?= python3
22+
23+
all: \
24+
all-editability_no \
25+
all-editability_yes
26+
27+
all-editability_no:
28+
$(MAKE) \
29+
--directory editability_no
30+
31+
all-editability_yes:
32+
$(MAKE) \
33+
--directory editability_yes
34+
35+
check: \
36+
all
37+
38+
check: \
39+
all
40+
source $(top_srcdir)/tests/venv/bin/activate \
41+
&& pytest \
42+
--log-level=DEBUG \
43+
--verbose \
44+
test_outputs.py
45+
46+
clean: \
47+
clean-editability_no \
48+
clean-editability_yes
49+
50+
clean-editability_no:
51+
@$(MAKE) \
52+
--directory editability_no \
53+
clean
54+
55+
clean-editability_yes:
56+
@$(MAKE) \
57+
--directory editability_yes \
58+
clean

tests/relativity_to_venv/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Tests: Virtual environment editability
2+
3+
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.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/make -f
2+
3+
# Portions of this file contributed by NIST are governed by the
4+
# following statement:
5+
#
6+
# This software was developed at the National Institute of Standards
7+
# and Technology by employees of the Federal Government in the course
8+
# of their official duties. Pursuant to Title 17 Section 105 of the
9+
# United States Code, this software is not subject to copyright
10+
# protection within the United States. NIST assumes no responsibility
11+
# whatsoever for its use by other parties, and makes no guarantees,
12+
# expressed or implied, about its quality, reliability, or any other
13+
# characteristic.
14+
#
15+
# We would appreciate acknowledgement if the software is used.
16+
17+
installation_editable := no
18+
19+
include ../editability_x.mk
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python3
2+
3+
# Portions of this file contributed by NIST are governed by the
4+
# following statement:
5+
#
6+
# This software was developed at the National Institute of Standards
7+
# and Technology by employees of the Federal Government in the course
8+
# of their official duties. Pursuant to Title 17 Section 105 of the
9+
# United States Code, this software is not subject to copyright
10+
# protection within the United States. NIST assumes no responsibility
11+
# whatsoever for its use by other parties, and makes no guarantees,
12+
# expressed or implied, about its quality, reliability, or any other
13+
# characteristic.
14+
#
15+
# We would appreciate acknowledgement if the software is used.
16+
17+
import logging
18+
19+
import cdo_local_uuid
20+
21+
22+
def main() -> None:
23+
logging.basicConfig(level=logging.DEBUG)
24+
cdo_local_uuid.configure()
25+
print(cdo_local_uuid.local_uuid())
26+
27+
28+
if __name__ == "__main__":
29+
main()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Portions of this file contributed by NIST are governed by the
2+
# following statement:
3+
#
4+
# This software was developed at the National Institute of Standards
5+
# and Technology by employees of the Federal Government in the course
6+
# of their official duties. Pursuant to Title 17 Section 105 of the
7+
# United States Code, this software is not subject to copyright
8+
# protection within the United States. NIST assumes no responsibility
9+
# whatsoever for its use by other parties, and makes no guarantees,
10+
# expressed or implied, about its quality, reliability, or any other
11+
# characteristic.
12+
#
13+
# We would appreciate acknowledgement if the software is used.
14+
15+
# This file is defined to support PEP 561:
16+
# https://www.python.org/dev/peps/pep-0561/
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/make -f
2+
3+
# Portions of this file contributed by NIST are governed by the
4+
# following statement:
5+
#
6+
# This software was developed at the National Institute of Standards
7+
# and Technology by employees of the Federal Government in the course
8+
# of their official duties. Pursuant to Title 17 Section 105 of the
9+
# United States Code, this software is not subject to copyright
10+
# protection within the United States. NIST assumes no responsibility
11+
# whatsoever for its use by other parties, and makes no guarantees,
12+
# expressed or implied, about its quality, reliability, or any other
13+
# characteristic.
14+
#
15+
# We would appreciate acknowledgement if the software is used.
16+
17+
include ../../editability_x_dir_1.mk
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[metadata]
2+
name = cdo-example-command
3+
version = 0.0.1
4+
author = Example Developer
5+
author_email = [email protected]
6+
description = Test project
7+
classifiers =
8+
Development Status :: 1 - Planning
9+
Operating System :: OS Independent
10+
Private :: Do Not Upload
11+
Programming Language :: Python :: 3
12+
# Usage of the classifier 'Private :: Do Not Upload' is to confirm that
13+
# the package configuration for cdo-local-uuid is ignoring this test
14+
# project. If it's picked up, PyPI will reject the package, per:
15+
# https://pypi.org/classifiers/
16+
17+
[options]
18+
include_package_data = true
19+
packages = find:
20+
install_requires =
21+
cdo_local_uuid
22+
23+
[options.entry_points]
24+
console_scripts =
25+
cdo_example_command = cdo_example_command:main
26+
27+
[options.package_data]
28+
cdo_example_command = py.typed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python3
2+
3+
# Portions of this file contributed by NIST are governed by the
4+
# following statement:
5+
#
6+
# This software was developed at the National Institute of Standards
7+
# and Technology by employees of the Federal Government in the course
8+
# of their official duties. Pursuant to Title 17 Section 105 of the
9+
# United States Code, this software is not subject to copyright
10+
# protection within the United States. NIST assumes no responsibility
11+
# whatsoever for its use by other parties, and makes no guarantees,
12+
# expressed or implied, about its quality, reliability, or any other
13+
# characteristic.
14+
#
15+
# We would appreciate acknowledgement if the software is used.
16+
17+
import setuptools
18+
19+
if __name__ == "__main__":
20+
setuptools.setup()
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/usr/bin/make -f
2+
3+
# Portions of this file contributed by NIST are governed by the
4+
# following statement:
5+
#
6+
# This software was developed at the National Institute of Standards
7+
# and Technology by employees of the Federal Government in the course
8+
# of their official duties. Pursuant to Title 17 Section 105 of the
9+
# United States Code, this software is not subject to copyright
10+
# protection within the United States. NIST assumes no responsibility
11+
# whatsoever for its use by other parties, and makes no guarantees,
12+
# expressed or implied, about its quality, reliability, or any other
13+
# characteristic.
14+
#
15+
# We would appreciate acknowledgement if the software is used.
16+
17+
# Purpose:
18+
#
19+
# This Makefile is intended to be loaded with the 'include' Make
20+
# directive in one of the editability_*/Makefile files. The variable
21+
# installation_editable is expected to be 'yes' or 'no'.
22+
# https://www.gnu.org/software/make/manual/html_node/Include.html
23+
#
24+
# This file is not intended to be used with Make by itself.
25+
#
26+
# This Makefile confirms that the same command line generates the same
27+
# UUID sequence, and clarifies that redirection of stdout to a differing
28+
# file path is not considered as part of the sequence seed. It also
29+
# recurses into dir_1/ to test different relative positions (pwd, or
30+
# pwd's parent) for CDO_DEMO_NONRANDOM_UUID_BASE.
31+
32+
SHELL := /bin/bash
33+
34+
# NOTE: This top_srcdir is the "real" top source directory, the root
35+
# directory of the cdo-local-uuid repository, for access to the
36+
# cdo_local_uuid project as a local directory.
37+
top_srcdir := $(shell cd ../../.. ; pwd)
38+
39+
PYTHON3 ?= python3
40+
41+
ifeq ($(installation_editable),)
42+
$(error installation_editable undefined ; please define before the Make 'include' directive)
43+
endif
44+
ifeq ($(installation_editable),yes)
45+
editable_flag=--editable
46+
else
47+
editable_flag=
48+
endif
49+
50+
all: \
51+
all-dir_1 \
52+
output_0.txt \
53+
output_1.txt
54+
55+
%.txt: \
56+
.venv.done.log \
57+
cdo_example_command/__init__.py
58+
export CDO_DEMO_NONRANDOM_UUID_BASE="$$(pwd)" \
59+
&& source venv/bin/activate \
60+
&& cdo_example_command \
61+
> _$@
62+
mv _$@ $@
63+
64+
.venv.done.log: \
65+
$(top_srcdir)/setup.cfg \
66+
$(top_srcdir)/setup.py \
67+
setup.cfg \
68+
setup.py
69+
rm -rf venv
70+
$(PYTHON3) -m venv \
71+
venv
72+
source venv/bin/activate \
73+
&& pip install \
74+
--upgrade \
75+
pip \
76+
setuptools \
77+
wheel
78+
source venv/bin/activate \
79+
&& pip install \
80+
$(top_srcdir)
81+
source venv/bin/activate \
82+
&& pip install \
83+
$(editable_flag) \
84+
.
85+
touch $@
86+
87+
all-dir_1: \
88+
.venv.done.log
89+
$(MAKE) \
90+
--directory dir_1
91+
92+
check: \
93+
all
94+
95+
clean:
96+
@rm -f \
97+
.venv.done.log \
98+
*.txt
99+
@rm -rf \
100+
venv

0 commit comments

Comments
 (0)