From c472931eb9a201141c4aa28ba14628d28233a077 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Wed, 20 Apr 2011 20:09:33 -0500 Subject: [PATCH] Fixing example.bro's auto-reST generation baseline test. Adds a diff canonifier that skips diffing the places where example.bro may use MutableVal derivatives (e.g. sets/tables), which don't always generate the same ordering in the reST docs across runs. --- .../Baseline/doc.autogen-reST-example/example.rst | 2 +- .../btest/Scripts/doc/example-diff-canonifier.py | 15 +++++++++++++++ testing/btest/btest.cfg | 1 + testing/btest/doc/autogen-reST-example | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100755 testing/btest/Scripts/doc/example-diff-canonifier.py diff --git a/testing/btest/Baseline/doc.autogen-reST-example/example.rst b/testing/btest/Baseline/doc.autogen-reST-example/example.rst index eb125eda23..8e735b787e 100644 --- a/testing/btest/Baseline/doc.autogen-reST-example/example.rst +++ b/testing/btest/Baseline/doc.autogen-reST-example/example.rst @@ -13,7 +13,7 @@ these comments are transferred directly into the auto-generated `reStructuredText `_ (reST) document's summary section. -.. tip:: You can embed directives and roles within ``##``-stylized comments +.. tip:: You can embed directives and roles within ``##``-stylized comments. :Author: Jon Siwek diff --git a/testing/btest/Scripts/doc/example-diff-canonifier.py b/testing/btest/Scripts/doc/example-diff-canonifier.py new file mode 100755 index 0000000000..e0b8c110cc --- /dev/null +++ b/testing/btest/Scripts/doc/example-diff-canonifier.py @@ -0,0 +1,15 @@ +#!/usr/bin/python + +import sys +import re + +# MutableVal derivatives (e.g. sets/tables) don't always generate the same +# ordering in the reST documentation, so just don't bother diffing +# the places where example.bro uses them. + +RE1 = "\d*/tcp" +RE2 = "tcp port \d*" + +for line in sys.stdin.readlines(): + if re.search(RE1, line) is None and re.search(RE2, line) is None: + print line diff --git a/testing/btest/btest.cfg b/testing/btest/btest.cfg index 52f7e6280a..0eee6883ef 100644 --- a/testing/btest/btest.cfg +++ b/testing/btest/btest.cfg @@ -12,5 +12,6 @@ BRO_SEED_FILE=%(testbase)s/random.seed PATH=%(testbase)s/../../build/src:%(testbase)s/../../aux/btest:%(default_path)s TEST_DIFF_CANONIFIER=%(testbase)s/Scripts/diff-canonifier TRACES=%(testbase)s/Traces +SCRIPTS=%(testbase)s/Scripts DIST=%(testbase)s/../.. BUILD=%(testbase)s/../../build diff --git a/testing/btest/doc/autogen-reST-example b/testing/btest/doc/autogen-reST-example index 7870259cad..c47a604373 100644 --- a/testing/btest/doc/autogen-reST-example +++ b/testing/btest/doc/autogen-reST-example @@ -1,2 +1,2 @@ @TEST-EXEC: bro --doc-scripts $DIST/doc/example.bro -@TEST-EXEC: btest-diff example.rst +@TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/doc/example-diff-canonifier.py btest-diff example.rst