@@ -26,132 +26,151 @@ part%.forbook.asciidoc: part%.asciidoc
26
26
> $@
27
27
28
28
29
+
30
+ .PHONY : oreilly.% .asciidoc
31
+ oreilly.% .asciidoc : % .asciidoc
32
+ $(RUN_OREILLY_FLAVOURED_ASCIIDOCTOR ) $(subst oreilly.,,$@ )
33
+
29
34
book.html : part1.forbook.asciidoc
30
35
book.html : part2.forbook.asciidoc
31
36
book.html : part3.forbook.asciidoc
32
37
book.html : $(SOURCES )
33
38
39
+
40
+ % .html : % .asciidoc # build an individual chapter's html page
41
+ $(RUN_ASCIIDOCTOR ) $<
42
+
34
43
.PHONY : build
35
44
build : $(HTML_PAGES ) $(TMPDIR )
36
45
46
+
47
+ MKVENV := $(shell which uv && "uv venv" || "python3 -m venv")
48
+ MKVENV := $(shell which uv && "uv venv" || "python3 -m venv")
49
+
50
+ .venv/bin :
51
+ which uv && uv venv .venv || python -m venv .venv
52
+ which uv && uv pip install -e . || .venv/bin/pip install -e .
53
+
54
+ .PHONY : install
55
+ install : .venv/bin
56
+
57
+ .PHONY : update-submodules
58
+ update-submodules :
59
+ git submodule update --init --recursive
60
+ .venv/bin/python tests/update_source_repo.py
61
+
62
+ # this is to allow for a git remote called "local" for eg ./source/feed-thru-cherry-pick.sh
63
+ ../book-example.git :
64
+ mkdir -p ../book-example.git
65
+ git init --bare ../book-example.git
66
+
37
67
.PHONY : test
38
- test : build
39
- git submodule init
40
- python tests/update_source_repo.py
41
- pytest --tb=short --color=yes tests/
68
+ test : build update-submodules .venv/bin
69
+ .venv/bin/pytest --tb=short --color=yes tests/
42
70
43
71
.PHONY : testall
44
72
testall : build
45
- pytest --tb=short --color=yes --numprocesses=auto tests/test_chapter_*
73
+ .venv/bin/ pytest --tb=short --color=yes --numprocesses=auto tests/test_chapter_*
46
74
47
75
.PHONY : testall4
48
76
testall4 : build
49
- pytest --tb=short --color=yes --numprocesses=4 tests/test_chapter_*
50
-
51
- % .html : % .asciidoc
52
- $(RUN_ASCIIDOCTOR ) $<
53
-
54
- .PHONY : oreilly.% .asciidoc
55
- oreilly.% .asciidoc : % .asciidoc
56
- $(RUN_OREILLY_FLAVOURED_ASCIIDOCTOR ) $(subst oreilly.,,$@ )
77
+ .venv/bin/pytest --tb=short --color=yes --numprocesses=4 tests/test_chapter_*
57
78
58
79
59
80
.PHONY : test_%
60
81
test_% : % .html $(TMPDIR )
61
- pytest -s --tb=short ./tests/$@ .py
82
+ .venv/bin/ pytest -s --tb=short ./tests/$@ .py
62
83
63
84
# exhaustively list for nice tab-completion
64
85
#
65
86
.PHONY : test_chapter_01
66
- test_chapter_01 : chapter_01.html $(TMPDIR )
67
- pytest -s --tb=short ./tests/test_chapter_01.py
87
+ test_chapter_01 : chapter_01.html $(TMPDIR ) .venv/bin
88
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_01.py
68
89
.PHONY : test_chapter_02_unittest
69
- test_chapter_02_unittest : chapter_02_unittest.html $(TMPDIR )
70
- pytest -s --tb=short ./tests/test_chapter_02_unittest.py
90
+ test_chapter_02_unittest : chapter_02_unittest.html $(TMPDIR ) .venv/bin
91
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_02_unittest.py
71
92
.PHONY : test_chapter_03_unit_test_first_view
72
- test_chapter_03_unit_test_first_view : chapter_03_unit_test_first_view.html $(TMPDIR )
73
- pytest -s --tb=short ./tests/test_chapter_03_unit_test_first_view.py
93
+ test_chapter_03_unit_test_first_view : chapter_03_unit_test_first_view.html $(TMPDIR ) .venv/bin
94
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_03_unit_test_first_view.py
74
95
.PHONY : test_chapter_04_philosophy_and_refactoring
75
- test_chapter_04_philosophy_and_refactoring : chapter_04_philosophy_and_refactoring.html $(TMPDIR )
76
- pytest -s --tb=short ./tests/test_chapter_04_philosophy_and_refactoring.py
96
+ test_chapter_04_philosophy_and_refactoring : chapter_04_philosophy_and_refactoring.html $(TMPDIR ) .venv/bin
97
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_04_philosophy_and_refactoring.py
77
98
.PHONY : test_chapter_05_post_and_database
78
- test_chapter_05_post_and_database : chapter_05_post_and_database.html $(TMPDIR )
79
- pytest -s --tb=short ./tests/test_chapter_05_post_and_database.py
99
+ test_chapter_05_post_and_database : chapter_05_post_and_database.html $(TMPDIR ) .venv/bin
100
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_05_post_and_database.py
80
101
.PHONY : test_chapter_06_explicit_waits_1
81
- test_chapter_06_explicit_waits_1 : chapter_06_explicit_waits_1.html $(TMPDIR )
82
- pytest -s --tb=short ./tests/test_chapter_06_explicit_waits_1.py
102
+ test_chapter_06_explicit_waits_1 : chapter_06_explicit_waits_1.html $(TMPDIR ) .venv/bin
103
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_06_explicit_waits_1.py
83
104
.PHONY : test_chapter_07_working_incrementally
84
- test_chapter_07_working_incrementally : chapter_07_working_incrementally.html $(TMPDIR )
85
- pytest -s --tb=short ./tests/test_chapter_07_working_incrementally.py
105
+ test_chapter_07_working_incrementally : chapter_07_working_incrementally.html $(TMPDIR ) .venv/bin
106
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_07_working_incrementally.py
86
107
.PHONY : test_chapter_08_prettification
87
- test_chapter_08_prettification : chapter_08_prettification.html $(TMPDIR )
88
- pytest -s --tb=short ./tests/test_chapter_08_prettification.py
108
+ test_chapter_08_prettification : chapter_08_prettification.html $(TMPDIR ) .venv/bin
109
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_08_prettification.py
89
110
.PHONY : test_chapter_09_docker
90
- test_chapter_09_docker : chapter_09_docker.html $(TMPDIR )
91
- pytest -s --tb=short ./tests/test_chapter_09_docker.py
111
+ test_chapter_09_docker : chapter_09_docker.html $(TMPDIR ) .venv/bin
112
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_09_docker.py
92
113
.PHONY : test_chapter_10_production_readiness
93
- test_chapter_10_production_readiness : chapter_10_production_readiness.html $(TMPDIR )
94
- pytest -s --tb=short ./tests/test_chapter_10_production_readiness.py
114
+ test_chapter_10_production_readiness : chapter_10_production_readiness.html $(TMPDIR ) .venv/bin
115
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_10_production_readiness.py
95
116
.PHONY : test_chapter_11_ansible
96
- test_chapter_11_ansible : chapter_11_ansible.html $(TMPDIR )
97
- pytest -s --tb=short ./tests/test_chapter_11_ansible.py
117
+ test_chapter_11_ansible : chapter_11_ansible.html $(TMPDIR ) .venv/bin
118
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_11_ansible.py
98
119
.PHONY : test_chapter_12_organising_test_files
99
- test_chapter_12_organising_test_files : chapter_12_organising_test_files.html $(TMPDIR )
100
- pytest -s --tb=short ./tests/test_chapter_12_organising_test_files.py
120
+ test_chapter_12_organising_test_files : chapter_12_organising_test_files.html $(TMPDIR ) .venv/bin
121
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_12_organising_test_files.py
101
122
.PHONY : test_chapter_13_database_layer_validation
102
- test_chapter_13_database_layer_validation : chapter_13_database_layer_validation.html $(TMPDIR )
103
- pytest -s --tb=short ./tests/test_chapter_13_database_layer_validation.py
123
+ test_chapter_13_database_layer_validation : chapter_13_database_layer_validation.html $(TMPDIR ) .venv/bin
124
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_13_database_layer_validation.py
104
125
.PHONY : test_chapter_14_simple_form
105
- test_chapter_14_simple_form : chapter_14_simple_form.html $(TMPDIR )
106
- pytest -s --tb=short ./tests/test_chapter_14_simple_form.py
126
+ test_chapter_14_simple_form : chapter_14_simple_form.html $(TMPDIR ) .venv/bin
127
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_14_simple_form.py
107
128
.PHONY : test_chapter_15_advanced_forms
108
- test_chapter_15_advanced_forms : chapter_15_advanced_forms.html $(TMPDIR )
109
- pytest -s --tb=short ./tests/test_chapter_15_advanced_forms.py
129
+ test_chapter_15_advanced_forms : chapter_15_advanced_forms.html $(TMPDIR ) .venv/bin
130
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_15_advanced_forms.py
110
131
.PHONY : test_chapter_javascript
111
- test_chapter_javascript : chapter_javascript.html $(TMPDIR )
112
- pytest -s --tb=short ./tests/test_chapter_javascript.py
132
+ test_chapter_javascript : chapter_javascript.html $(TMPDIR ) .venv/bin
133
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_javascript.py
113
134
.PHONY : test_chapter_deploying_validation
114
- test_chapter_deploying_validation : chapter_deploying_validation.html $(TMPDIR )
115
- pytest -s --tb=short ./tests/test_chapter_deploying_validation.py
135
+ test_chapter_deploying_validation : chapter_deploying_validation.html $(TMPDIR ) .venv/bin
136
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_deploying_validation.py
116
137
.PHONY : test_chapter_spiking_custom_auth
117
- test_chapter_spiking_custom_auth : chapter_spiking_custom_auth.html $(TMPDIR )
118
- pytest -s --tb=short ./tests/test_chapter_spiking_custom_auth.py
138
+ test_chapter_spiking_custom_auth : chapter_spiking_custom_auth.html $(TMPDIR ) .venv/bin
139
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_spiking_custom_auth.py
119
140
.PHONY : test_chapter_mocking
120
- test_chapter_mocking : chapter_mocking.html $(TMPDIR )
121
- pytest -s --tb=short ./tests/test_chapter_mocking.py
141
+ test_chapter_mocking : chapter_mocking.html $(TMPDIR ) .venv/bin
142
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_mocking.py
122
143
.PHONY : test_chapter_fixtures_and_wait_decorator
123
- test_chapter_fixtures_and_wait_decorator : chapter_fixtures_and_wait_decorator.html $(TMPDIR )
124
- pytest -s --tb=short ./tests/test_chapter_fixtures_and_wait_decorator.py
144
+ test_chapter_fixtures_and_wait_decorator : chapter_fixtures_and_wait_decorator.html $(TMPDIR ) .venv/bin
145
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_fixtures_and_wait_decorator.py
125
146
.PHONY : test_chapter_server_side_debugging
126
- test_chapter_server_side_debugging : chapter_server_side_debugging.html $(TMPDIR )
127
- pytest -s --tb=short ./tests/test_chapter_server_side_debugging.py
147
+ test_chapter_server_side_debugging : chapter_server_side_debugging.html $(TMPDIR ) .venv/bin
148
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_server_side_debugging.py
128
149
.PHONY : test_chapter_outside_in
129
- test_chapter_outside_in : chapter_outside_in.html $(TMPDIR )
130
- pytest -s --tb=short ./tests/test_chapter_outside_in.py
150
+ test_chapter_outside_in : chapter_outside_in.html $(TMPDIR ) .venv/bin
151
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_outside_in.py
131
152
.PHONY : test_chapter_purist_unit_tests
132
- test_chapter_purist_unit_tests : chapter_purist_unit_tests.html $(TMPDIR )
133
- pytest -s --tb=short ./tests/test_chapter_purist_unit_tests.py
153
+ test_chapter_purist_unit_tests : chapter_purist_unit_tests.html $(TMPDIR ) .venv/bin
154
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_purist_unit_tests.py
134
155
.PHONY : test_chapter_CI
135
- test_chapter_CI : chapter_CI.html $(TMPDIR )
136
- pytest -s --tb=short ./tests/test_chapter_CI.py
156
+ test_chapter_CI : chapter_CI.html $(TMPDIR ) .venv/bin
157
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_CI.py
137
158
.PHONY : test_chapter_page_pattern
138
- test_chapter_page_pattern : chapter_page_pattern.html $(TMPDIR )
139
- pytest -s --tb=short ./tests/test_chapter_page_pattern.py
159
+ test_chapter_page_pattern : chapter_page_pattern.html $(TMPDIR ) .venv/bin
160
+ .venv/bin/ pytest -s --tb=short ./tests/test_chapter_page_pattern.py
140
161
141
162
142
163
143
164
.PHONY : silent_test_%
144
- silent_test_% : % .html $(TMPDIR )
145
- pytest --tb=short ./tests/$(subst silent_,,$@ ) .py
165
+ silent_test_% : % .html $(TMPDIR ) .venv/bin
166
+ .venv/bin/ pytest --tb=short ./tests/$(subst silent_,,$@ ) .py
146
167
147
168
.PHONY : unit-test
148
- unit-test : chapter_01.html
169
+ unit-test : chapter_01.html .venv/bin
149
170
SKIP_CHAPTER_SUBMODULES=1 ./tests/update_source_repo.py
150
- ./run_test_tests.sh
171
+ source .venv/bin/activate && ./run_test_tests.sh
151
172
152
173
.PHONY : clean
153
174
clean :
154
175
rm -rf $(TMPDIR )
155
176
rm -v $(HTML_PAGES )
156
-
157
- .PHONY = test clean test_chapter_%
0 commit comments