diff --git a/.gitignore b/.gitignore index 954a83f50..61115b19a 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,7 @@ tests/primitives_pb2.py tests/primitives_pb2_grpc.py tests/autogenerate-examples-status.log tests/autogenerate-examples.json +tests/autogenerate-examples-repeat.log # Ignore unrelated stuff .DS_Store diff --git a/Makefile b/Makefile index 01208011d..5cd4628db 100644 --- a/Makefile +++ b/Makefile @@ -577,6 +577,17 @@ check-amount-access: @! (git grep -nE "(->|\.)(milli)?satoshis" -- "*.c" "*.h" ":(exclude)common/amount.*" ":(exclude)*/test/*" | grep -v '/* Raw:') @! git grep -nE "\\(struct amount_(m)?sat\\)" -- "*.c" "*.h" ":(exclude)common/amount.*" ":(exclude)*/test/*" | grep -vE "sizeof.struct amount_(m)?sat." +repeat-doc-examples: + @for i in $$(seq 1 $(n)); do \ + echo "----------------------------------" >> tests/autogenerate-examples-repeat.log; \ + echo "Iteration $$i" >> tests/autogenerate-examples-repeat.log; \ + echo "----------------------------------" >> tests/autogenerate-examples-repeat.log; \ + VALGRIND=0 TIMEOUT=40 TEST_DEBUG=1 GENERATE_EXAMPLES=1 pytest -vvv tests/autogenerate-rpc-examples.py; \ + git diff >> tests/autogenerate-examples-repeat.log; \ + git reset --hard; \ + echo "----------------------------------" >> tests/autogenerate-examples-repeat.log; \ + done + update-doc-examples: TEST_DEBUG=1 VALGRIND=0 GENERATE_EXAMPLES=1 $(PYTEST) $(PYTEST_OPTS) --timeout=1200 tests/autogenerate-rpc-examples.py && $(MAKE) $(MSGGEN_GEN_ALL) diff --git a/doc/contribute-to-core-lightning/coding-style-guidelines/writing-json-schemas.md b/doc/contribute-to-core-lightning/coding-style-guidelines/writing-json-schemas.md index d895e92e1..664cbe19a 100644 --- a/doc/contribute-to-core-lightning/coding-style-guidelines/writing-json-schemas.md +++ b/doc/contribute-to-core-lightning/coding-style-guidelines/writing-json-schemas.md @@ -84,10 +84,18 @@ is set, preventing accidental overwrites from unrelated tests. 3. Update the Ignore List: - Remove the RPC method name from `IGNORE_RPCS_LIST` to include it in the example generation. 4. Run and Refine: - - Run the test multiple times to detect variable values in responses: + - Run the test to detect variable values in responses either with: + + ```bash + make repeat-doc-examples n=5 + ``` + + where `n` can be any number of repetitions. OR by manually running the test multiple times with: + ```bash rm -rf /tmp/ltests* && make -s && VALGRIND=0 TIMEOUT=40 TEST_DEBUG=1 pytest -vvv -n 6 tests/autogenerate-rpc-examples.py ``` + - Identify changing values, and add them to `REPLACE_RESPONSE_VALUES`: ```bash REPLACE_RESPONSE_VALUES.extend([