|
29 | 29 | A unit test executed with \pytest\ will fail and exit with a non-zero exit code if the test, well, fails.
|
30 | 30 | A static code analysis tool like \ruff\ will fail with a non-zero exit code if it discovers any issue with the code.
|
31 | 31 | However, our scripts invoking these tools will \emph{not} fail in such cases.
|
32 |
| -They will collect the exit code of the tool they are invoking and print it. |
| 32 | +They will collect the \pgls{exitCode} of the tool they are invoking and print it. |
33 | 33 | Then they will exit with exit code~0.
|
34 | 34 | This is necessary for our book building process, which invokes these scripts to construct the outputs of the examples.
|
35 |
| -If any of them would fail with non-zero exit code, the book building would fail as well. |
| 35 | +If any of them would fail with non-zero \pgls{exitCode}, the book building would fail as well. |
36 | 36 | However, to illustrate that the tools are useful, we must apply them to cases where they would fail.
|
37 |
| -So for our book, it is necessary that the scripts just print the exit codes while still returning successfully. |
| 37 | +So for our book, it is necessary that the scripts just print the \pglspl{exitCode} while still returning successfully. |
38 | 38 | For a real productive environment, this is usually not what we want:
|
39 | 39 | We apply the tools to source code precisely to get them to fail on error, because if nothing fails, we know that everything seems to be OK.
|
40 | 40 | In such a practical environment, you would thus not want to use \emph{our} scripts, but you could use the same comments that we use.
|
|
46 | 46 | It then prints the command with a prepended~\expandafter\textil{\$}.
|
47 | 47 | Then, it executes it.
|
48 | 48 | \mypy\ will print its comments and messages to the standard output.
|
49 |
| -Finally, the script shows the \mypy\ version and exit code in a brief success or failure message (with a prepended~\expandafter\textil{\#}). |
| 49 | +Finally, the script shows the \mypy\ version and \pgls{exitCode} in a brief success or failure message (with a prepended~\expandafter\textil{\#}). |
50 | 50 | \Cref{exec:variables:variable_types_wrong_hints_1:mypy,exec:variables:variable_types_wrong_hints_2:mypy} are example outputs of this script.
|
51 | 51 |
|
52 | 52 | \Cref{lst:bash:ruff} works basically the same way, just for \ruff.
|
|
71 | 71 | Either way, the script executes the test cases, prints the results as well as potential errors.
|
72 | 72 | Notice that we select some options to make the output less verbose, because for this book, we do want listings that are not too long.
|
73 | 73 | In practical scenarios, you may use different options.
|
74 |
| -Either way, the script also prints the command that was executed at the beginning and the \pytest\ version used and the program's exit code at the end of the output. |
| 74 | +Either way, the script also prints the command that was executed at the beginning and the \pytest\ version used and the \pgls{exitCode} of the process at the end of the output. |
75 | 75 | \Cref{exec:functions:test_my_math:pytest,exec:functions:test_my_math_2:pytest,exec:functions:test_my_math_3:pytest} are examples for the output of \pytest.%
|
76 | 76 | %
|
77 | 77 | \endhsection%
|
|
0 commit comments