@@ -3,6 +3,7 @@ SHELL := /bin/bash
3
3
SOURCES := $(wildcard * .asciidoc)
4
4
HTML_PAGES := $(patsubst % .asciidoc, % .html, ${SOURCES})
5
5
TESTS := $(patsubst % .asciidoc, test_% , ${SOURCES})
6
+ VENV ?= .venv
6
7
7
8
RUN_ASCIIDOCTOR = asciidoctor -a source-highlighter=pygments -a pygments-style=default -a stylesheet=asciidoctor.css -a linkcss -a icons=font -a compat-mode -a '!example-caption' -a last-update-label='License: Creative Commons <a href="https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode">CC-BY-NC-ND</a>. Last updated:'
8
9
@@ -41,129 +42,129 @@ book.html: $(SOURCES)
41
42
build : $(HTML_PAGES ) $(TMPDIR )
42
43
43
44
44
- .venv /bin :
45
- which uv && uv venv .venv || python3 -m venv .venv
46
- which uv && uv pip install -e . || .venv /bin/pip install -e .
45
+ $( VENV ) /bin :
46
+ which uv && uv venv $( VENV ) || python3 -m venv $( VENV )
47
+ which uv && uv pip install -e . || $( VENV ) /bin/pip install -e .
47
48
48
49
.PHONY : install
49
- install : .venv /bin
50
+ install : $( VENV ) /bin
50
51
which brew && brew install asciidoctor tree || apt install -y asciidoctor tree
51
52
52
53
.PHONY : update-submodules
53
54
update-submodules :
54
55
git submodule update --init --recursive
55
- .venv /bin/python tests/update_source_repo.py
56
+ $( VENV ) /bin/python tests/update_source_repo.py
56
57
57
58
# this is to allow for a git remote called "local" for eg ./source/feed-thru-cherry-pick.sh
58
59
../book-example.git :
59
60
mkdir -p ../book-example.git
60
61
git init --bare ../book-example.git
61
62
62
63
.PHONY : test
63
- test : build update-submodules .venv /bin
64
- .venv /bin/pytest --tb=short --color=yes tests/
64
+ test : build update-submodules $( VENV ) /bin
65
+ $( VENV ) /bin/pytest --tb=short --color=yes tests/
65
66
66
67
.PHONY : testall
67
68
testall : build
68
- .venv /bin/pytest --tb=short --color=yes --numprocesses=auto tests/test_chapter_*
69
+ $( VENV ) /bin/pytest --tb=short --color=yes --numprocesses=auto tests/test_chapter_*
69
70
70
71
.PHONY : testall4
71
72
testall4 : build
72
- .venv /bin/pytest --tb=short --color=yes --numprocesses=4 tests/test_chapter_*
73
+ $( VENV ) /bin/pytest --tb=short --color=yes --numprocesses=4 tests/test_chapter_*
73
74
74
75
75
76
.PHONY : test_%
76
77
test_% : % .html $(TMPDIR )
77
- .venv /bin/pytest -s --tb=short ./tests/$@ .py
78
+ $( VENV ) /bin/pytest -s --tb=short ./tests/$@ .py
78
79
79
80
# exhaustively list for nice tab-completion
80
81
#
81
82
.PHONY : test_chapter_01
82
- test_chapter_01 : chapter_01.html $(TMPDIR ) .venv /bin
83
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_01.py
83
+ test_chapter_01 : chapter_01.html $(TMPDIR ) $( VENV ) /bin
84
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_01.py
84
85
.PHONY : test_chapter_02_unittest
85
- test_chapter_02_unittest : chapter_02_unittest.html $(TMPDIR ) .venv /bin
86
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_02_unittest.py
86
+ test_chapter_02_unittest : chapter_02_unittest.html $(TMPDIR ) $( VENV ) /bin
87
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_02_unittest.py
87
88
.PHONY : test_chapter_03_unit_test_first_view
88
- test_chapter_03_unit_test_first_view : chapter_03_unit_test_first_view.html $(TMPDIR ) .venv /bin
89
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_03_unit_test_first_view.py
89
+ test_chapter_03_unit_test_first_view : chapter_03_unit_test_first_view.html $(TMPDIR ) $( VENV ) /bin
90
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_03_unit_test_first_view.py
90
91
.PHONY : test_chapter_04_philosophy_and_refactoring
91
- test_chapter_04_philosophy_and_refactoring : chapter_04_philosophy_and_refactoring.html $(TMPDIR ) .venv /bin
92
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_04_philosophy_and_refactoring.py
92
+ test_chapter_04_philosophy_and_refactoring : chapter_04_philosophy_and_refactoring.html $(TMPDIR ) $( VENV ) /bin
93
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_04_philosophy_and_refactoring.py
93
94
.PHONY : test_chapter_05_post_and_database
94
- test_chapter_05_post_and_database : chapter_05_post_and_database.html $(TMPDIR ) .venv /bin
95
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_05_post_and_database.py
95
+ test_chapter_05_post_and_database : chapter_05_post_and_database.html $(TMPDIR ) $( VENV ) /bin
96
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_05_post_and_database.py
96
97
.PHONY : test_chapter_06_explicit_waits_1
97
- test_chapter_06_explicit_waits_1 : chapter_06_explicit_waits_1.html $(TMPDIR ) .venv /bin
98
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_06_explicit_waits_1.py
98
+ test_chapter_06_explicit_waits_1 : chapter_06_explicit_waits_1.html $(TMPDIR ) $( VENV ) /bin
99
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_06_explicit_waits_1.py
99
100
.PHONY : test_chapter_07_working_incrementally
100
- test_chapter_07_working_incrementally : chapter_07_working_incrementally.html $(TMPDIR ) .venv /bin
101
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_07_working_incrementally.py
101
+ test_chapter_07_working_incrementally : chapter_07_working_incrementally.html $(TMPDIR ) $( VENV ) /bin
102
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_07_working_incrementally.py
102
103
.PHONY : test_chapter_08_prettification
103
- test_chapter_08_prettification : chapter_08_prettification.html $(TMPDIR ) .venv /bin
104
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_08_prettification.py
104
+ test_chapter_08_prettification : chapter_08_prettification.html $(TMPDIR ) $( VENV ) /bin
105
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_08_prettification.py
105
106
.PHONY : test_chapter_09_docker
106
- test_chapter_09_docker : chapter_09_docker.html $(TMPDIR ) .venv /bin
107
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_09_docker.py
107
+ test_chapter_09_docker : chapter_09_docker.html $(TMPDIR ) $( VENV ) /bin
108
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_09_docker.py
108
109
.PHONY : test_chapter_10_production_readiness
109
- test_chapter_10_production_readiness : chapter_10_production_readiness.html $(TMPDIR ) .venv /bin
110
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_10_production_readiness.py
110
+ test_chapter_10_production_readiness : chapter_10_production_readiness.html $(TMPDIR ) $( VENV ) /bin
111
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_10_production_readiness.py
111
112
.PHONY : test_chapter_11_ansible
112
- test_chapter_11_ansible : chapter_11_ansible.html $(TMPDIR ) .venv /bin
113
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_11_ansible.py
113
+ test_chapter_11_ansible : chapter_11_ansible.html $(TMPDIR ) $( VENV ) /bin
114
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_11_ansible.py
114
115
.PHONY : test_chapter_12_organising_test_files
115
- test_chapter_12_organising_test_files : chapter_12_organising_test_files.html $(TMPDIR ) .venv /bin
116
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_12_organising_test_files.py
116
+ test_chapter_12_organising_test_files : chapter_12_organising_test_files.html $(TMPDIR ) $( VENV ) /bin
117
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_12_organising_test_files.py
117
118
.PHONY : test_chapter_13_database_layer_validation
118
- test_chapter_13_database_layer_validation : chapter_13_database_layer_validation.html $(TMPDIR ) .venv /bin
119
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_13_database_layer_validation.py
119
+ test_chapter_13_database_layer_validation : chapter_13_database_layer_validation.html $(TMPDIR ) $( VENV ) /bin
120
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_13_database_layer_validation.py
120
121
.PHONY : test_chapter_14_simple_form
121
- test_chapter_14_simple_form : chapter_14_simple_form.html $(TMPDIR ) .venv /bin
122
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_14_simple_form.py
122
+ test_chapter_14_simple_form : chapter_14_simple_form.html $(TMPDIR ) $( VENV ) /bin
123
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_14_simple_form.py
123
124
.PHONY : test_chapter_15_advanced_forms
124
- test_chapter_15_advanced_forms : chapter_15_advanced_forms.html $(TMPDIR ) .venv /bin
125
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_15_advanced_forms.py
125
+ test_chapter_15_advanced_forms : chapter_15_advanced_forms.html $(TMPDIR ) $( VENV ) /bin
126
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_15_advanced_forms.py
126
127
.PHONY : test_chapter_16_javascript
127
- test_chapter_16_javascript : chapter_16_javascript.html $(TMPDIR ) .venv /bin
128
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_16_javascript.py
128
+ test_chapter_16_javascript : chapter_16_javascript.html $(TMPDIR ) $( VENV ) /bin
129
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_16_javascript.py
129
130
.PHONY : test_chapter_deploying_validation
130
- test_chapter_deploying_validation : chapter_deploying_validation.html $(TMPDIR ) .venv /bin
131
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_deploying_validation.py
131
+ test_chapter_deploying_validation : chapter_deploying_validation.html $(TMPDIR ) $( VENV ) /bin
132
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_deploying_validation.py
132
133
.PHONY : test_chapter_spiking_custom_auth
133
- test_chapter_spiking_custom_auth : chapter_spiking_custom_auth.html $(TMPDIR ) .venv /bin
134
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_spiking_custom_auth.py
134
+ test_chapter_spiking_custom_auth : chapter_spiking_custom_auth.html $(TMPDIR ) $( VENV ) /bin
135
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_spiking_custom_auth.py
135
136
.PHONY : test_chapter_mocking
136
- test_chapter_mocking : chapter_mocking.html $(TMPDIR ) .venv /bin
137
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_mocking.py
137
+ test_chapter_mocking : chapter_mocking.html $(TMPDIR ) $( VENV ) /bin
138
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_mocking.py
138
139
.PHONY : test_chapter_fixtures_and_wait_decorator
139
- test_chapter_fixtures_and_wait_decorator : chapter_fixtures_and_wait_decorator.html $(TMPDIR ) .venv /bin
140
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_fixtures_and_wait_decorator.py
140
+ test_chapter_fixtures_and_wait_decorator : chapter_fixtures_and_wait_decorator.html $(TMPDIR ) $( VENV ) /bin
141
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_fixtures_and_wait_decorator.py
141
142
.PHONY : test_chapter_server_side_debugging
142
- test_chapter_server_side_debugging : chapter_server_side_debugging.html $(TMPDIR ) .venv /bin
143
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_server_side_debugging.py
143
+ test_chapter_server_side_debugging : chapter_server_side_debugging.html $(TMPDIR ) $( VENV ) /bin
144
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_server_side_debugging.py
144
145
.PHONY : test_chapter_outside_in
145
- test_chapter_outside_in : chapter_outside_in.html $(TMPDIR ) .venv /bin
146
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_outside_in.py
146
+ test_chapter_outside_in : chapter_outside_in.html $(TMPDIR ) $( VENV ) /bin
147
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_outside_in.py
147
148
.PHONY : test_chapter_purist_unit_tests
148
- test_chapter_purist_unit_tests : chapter_purist_unit_tests.html $(TMPDIR ) .venv /bin
149
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_purist_unit_tests.py
149
+ test_chapter_purist_unit_tests : chapter_purist_unit_tests.html $(TMPDIR ) $( VENV ) /bin
150
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_purist_unit_tests.py
150
151
.PHONY : test_chapter_CI
151
- test_chapter_CI : chapter_CI.html $(TMPDIR ) .venv /bin
152
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_CI.py
152
+ test_chapter_CI : chapter_CI.html $(TMPDIR ) $( VENV ) /bin
153
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_CI.py
153
154
.PHONY : test_chapter_page_pattern
154
- test_chapter_page_pattern : chapter_page_pattern.html $(TMPDIR ) .venv /bin
155
- .venv /bin/pytest -s --tb=short ./tests/test_chapter_page_pattern.py
155
+ test_chapter_page_pattern : chapter_page_pattern.html $(TMPDIR ) $( VENV ) /bin
156
+ $( VENV ) /bin/pytest -s --tb=short ./tests/test_chapter_page_pattern.py
156
157
157
158
158
159
159
160
.PHONY : silent_test_%
160
- silent_test_% : % .html $(TMPDIR ) .venv /bin
161
- .venv /bin/pytest --tb=short ./tests/$(subst silent_,,$@ ) .py
161
+ silent_test_% : % .html $(TMPDIR ) $( VENV ) /bin
162
+ $( VENV ) /bin/pytest --tb=short ./tests/$(subst silent_,,$@ ) .py
162
163
163
164
.PHONY : unit-test
164
- unit-test : chapter_01.html .venv /bin
165
+ unit-test : chapter_01.html $( VENV ) /bin
165
166
SKIP_CHAPTER_SUBMODULES=1 ./tests/update_source_repo.py
166
- source .venv /bin/activate && ./run_test_tests.sh
167
+ source $( VENV ) /bin/activate && ./run_test_tests.sh
167
168
168
169
.PHONY : clean
169
170
clean :
0 commit comments