Skip to content

Commit

Permalink
Add availableSince for every stdlib function and require it in a test…
Browse files Browse the repository at this point in the history
… so we don't get any more gaps
  • Loading branch information
sparkprime committed Apr 13, 2023
1 parent 5e70ed7 commit 39f8dfa
Show file tree
Hide file tree
Showing 6 changed files with 660 additions and 114 deletions.
43 changes: 43 additions & 0 deletions doc/_stdlib_gen/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash

# Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

TEST_SUITE_NAME="${TEST_SUITE_NAME:-$0}"

cd $(dirname $0)

JSONNET_BIN="${JSONNET_BIN:-../../jsonnet}"

source ../../test_suite/tests.source

init

shopt -s nullglob

FAILED=0
SUCCESS=0

test_eval "$JSONNET_BIN" "stdlib-content-test.jsonnet" 0 "true" "PLAIN"

deinit

if [ "$FAILED" -eq 0 ] ; then
echo "$TEST_SUITE_NAME: All $EXECUTED tests executed correctly."
else
echo "$TEST_SUITE_NAME: $FAILED / $EXECUTED tests failed."
exit 1
fi


13 changes: 13 additions & 0 deletions doc/_stdlib_gen/stdlib-content-test.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
local stdlib_content = import 'stdlib-content.jsonnet';

std.all([
if !std.objectHas(field, 'availableSince') then
error 'No availableSince field for std.%s' % field.name
else if field.availableSince[0] == 'v' then
error 'availableSince field for std.%s should not begin with a "v" (got %s)'
% [field.name, field.availableSince]
else
true
for group in stdlib_content.groups
for field in group.fields
])

0 comments on commit 39f8dfa

Please sign in to comment.