Skip to content

Commit 410609c

Browse files
author
Steven Lott
committed
Improve some protobuf handling. Fix the conversion from test cases to Gherkin.
1 parent a60c3f5 commit 410609c

43 files changed

Lines changed: 8855 additions & 5925 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Makefile‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,37 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and limitations under the License.
1515

16+
# Tools require GO. Typically, the following kinds of setup is required.
17+
# export PATH="/usr/local/go/bin:/usr/local/bin:$PATH"
18+
# export GOPATH="~/go"
19+
1620
install:
1721
python3 -m venv .
1822
. bin/activate && pip install -r requirements-dev.txt
1923

24+
install-tools:
25+
cd tools && export PATH="/usr/local/go/bin:/usr/local/bin:$PATH" && go mod init mkgherkin && go mod tidy
26+
2027
test:
28+
cd features && $(MAKE) all
2129
tox -e py38
2230

2331
test-all:
32+
cd features && $(MAKE) all
2433
tox
2534

35+
test-wip:
36+
cd features && $(MAKE) all
37+
tox -e wip
38+
39+
test-tools:
40+
tox -e tools
41+
cd features && $(MAKE) scan
42+
2643
unit-test:
27-
PYTHONPATH=src pytest -vv --cov=src --cov-report=term-missing ${test}
44+
PYTHONPATH=src python -m pytest -vv --cov=src --cov-report=term-missing ${test}
45+
PYTHONPATH=src python -m doctest tools/*.py
46+
PYTHONPATH=src python -m doctest features/steps/*.py
2847

2948
sphinx:
3049
PYTHONPATH=src python -m doctest docs/source/*.rst

‎demo/C7N_Rewrite.ipynb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@
465465
"name": "python",
466466
"nbconvert_exporter": "python",
467467
"pygments_lexer": "ipython3",
468-
"version": "3.9.0"
468+
"version": "3.8.6"
469469
}
470470
},
471471
"nbformat": 4,

‎features/Makefile‎

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,36 @@ TOOLS = $(HERE)../tools
2222
CEL_SPEC_PATH ?= $(HERE)../../cel-spec
2323
CEL_SIMPLE_TESTDATA ?= $(CEL_SPEC_PATH)/tests/simple/testdata
2424

25+
# This is most -- but not all -- the feature files.
26+
# Some are built manually. These are built from textproto files.
2527
FEATURES = \
2628
basic.feature \
27-
parse.feature \
28-
integer_math.feature \
2929
comparisons.feature \
30-
logic.feature \
31-
string.feature \
30+
conversions.feature \
31+
dynamic.feature \
32+
enums.feature \
33+
fields.feature \
3234
fp_math.feature \
35+
integer_math.feature \
3336
lists.feature \
34-
fields.feature \
35-
namespace.feature \
36-
enums.feature \
37-
conversions.feature \
38-
timestamps.feature \
39-
unknowns.feature \
37+
logic.feature \
4038
macros.feature \
39+
namespace.feature \
40+
parse.feature \
4141
plumbing.feature \
42-
dynamic.feature \
4342
proto2.feature \
44-
proto3.feature
43+
proto3.feature \
44+
string.feature \
45+
timestamps.feature \
46+
unknowns.feature
4547

4648

4749
SOURCES := $(patsubst %.feature,%.textproto,$(FEATURES))
4850

4951
.PRECIOUS: %.textproto
5052

53+
.DELETE_ON_ERROR:
54+
5155
all : $(FEATURES)
5256

5357
# Copy the textproto from the cel-spec directory to keep our reference copy.
@@ -56,18 +60,18 @@ all : $(FEATURES)
5660

5761
# Create Gherkin from the textproto serialization.
5862
%.feature : %.textproto
59-
python $(TOOLS)/textproto_to_gherkin.py $^ -o $@
63+
python $(TOOLS)/pb2g.py $^ -o $@
6064

6165
# Run the lark scanner to be sure the grammar works for *all* of the textproto files.
6266
# This is necessary because we don't have a full textproto implementation.
6367
scan : $(SOURCES)
64-
@python $(TOOLS)/textproto_to_gherkin.py
68+
@python $(TOOLS)/pb2g.py
6569
@for name in $(SOURCES); do \
66-
echo $$name; \
67-
python $(TOOLS)/textproto_to_gherkin.py -s $$name >/dev/null; \
70+
python $(TOOLS)/pb2g.py $$name >/dev/null; \
6871
done
72+
@echo "\nAll files scanned successfully"
6973

70-
# When the grammar is incomplete, we'll have empty .feature files.
74+
# When the grammar was incomplete, we sometimes had empty .feature files.
7175
# It helps to remove them before rerunning.
7276
clean-broken:
7377
@for name in $(FEATURES); do \
@@ -77,6 +81,9 @@ clean-broken:
7781
fi; \
7882
done
7983

84+
clean-features:
85+
rm $(FEATURES)
86+
8087
clean:
8188
rm $(FEATURES)
8289
rm $(SOURCES)

‎features/README.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Here's the Gherkin::
5555
And type_env parameter is None
5656
And bindings parameter is None
5757
When CEL expression "0" is evaluated
58-
Then value is Value(value_type='int64_value', source='0')
58+
Then value is IntType(0)
5959
And eval_error is None
6060

6161
We've made a bunch of test features explicit.

0 commit comments

Comments
 (0)