diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2021-06-21 17:32:00 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2021-06-21 17:32:00 +0100 |
commit | 61f10f985e19dfe20a4d9552902625edd5b6eabb (patch) | |
tree | 50db31971b38c4e0358253ef5005058a46fc773e /dev-lang/starlark-rust | |
parent | 34dea8e38f88007799629d0a56b12dec480b1d21 (diff) |
gentoo resync : 21.06.2021
Diffstat (limited to 'dev-lang/starlark-rust')
-rw-r--r-- | dev-lang/starlark-rust/Manifest | 3 | ||||
-rw-r--r-- | dev-lang/starlark-rust/files/test/features.bash | 193 | ||||
-rw-r--r-- | dev-lang/starlark-rust/starlark-rust-0.4.0.ebuild | 6 |
3 files changed, 200 insertions, 2 deletions
diff --git a/dev-lang/starlark-rust/Manifest b/dev-lang/starlark-rust/Manifest index 42b4969a445a..dc6babae929c 100644 --- a/dev-lang/starlark-rust/Manifest +++ b/dev-lang/starlark-rust/Manifest @@ -1,3 +1,4 @@ +AUX test/features.bash 3734 BLAKE2B a303b557ae2a9cbc8ec63153c65d4837e16febf5066045bc8a5b5fd88b3f92ace939bdbe510bd38698c88fea5085748fbbef6c7b27d94d5f1e713c7c207eb892 SHA512 9e6b0be6acb370610288cc2c1804fb8e34aa8a362eeae8e6bbb930988a8e366c7931a68f5d9afe90155d1c72e510c152e91823ff96b591277151033885869dca DIST Inflector-0.11.4.crate 17438 BLAKE2B eaf0c7f983b3186e9bc89353021a10592f2877e46585bd50b96db9b087343d1199c7b6cf3fa53cd274fb6d33de025a904b8aa31a7ac9599ae3689ecdbcec34cd SHA512 f1f6463e033b6d3c16c51dc1e1a3f5569954308b95b59058294b7f9310919bbda797e99e6a07529071bb83f0688867a243997d33795a7136b0af73977004296e DIST aho-corasick-0.7.18.crate 112923 BLAKE2B 4f6947d1aacf89ccfab0592cdc55fa61ef09cea38231d3f758765dbce328a810c0b588be4ba96e81d64955379ee005722d22a7aec39caea6e72342245d7ca34f SHA512 7a23b16231a90d23ee60ad4c81bc225410599a4560d33d3a203138fc540c39cf1000100fed3aed40dcc371c3635656a3792545dca5dd1aefbde00d8774eebd00 DIST annotate-snippets-0.9.0.crate 31491 BLAKE2B d62d0d0da8b38d570f6efac995ec9014074d44500fb8634d2215187d063cda2c523c37d690551a536c8a1e30b8fbb2974b577b695a02fd4c236520fae5fefb9f SHA512 bdcdf3ce7fae0232a804604b3580ca8b68d29f8cb67f10fd39411b2ca2dc4c497dc9882bbcddecb15977809bdc58f8a946f25ce0152d27e4d128b3dd83087d9c @@ -155,5 +156,5 @@ DIST winapi-i686-pc-windows-gnu-0.4.0.crate 2918815 BLAKE2B 4d357e4d30f955297217 DIST winapi-util-0.1.5.crate 10164 BLAKE2B fc800aceae5249a858c806c3e969ef2545766099872d856ebee51c883d9acf1122278db9607d50ca53eac351502b700fd2463900932d342240f97f683d517963 SHA512 7baeb661f397c4693dfa001fdc774b323c51a7c55caad40f2de5112a1cefd1d6151e3df41fa4ee193460a5905917c83d2b1de5fa10b4bd014ad96690af95c0fd DIST winapi-x86_64-pc-windows-gnu-0.4.0.crate 2947998 BLAKE2B 2ad1ea8b5fa07d544e910ccba043ae925269b76b26c9da356305b34b86741dd8b9aff0b9ffe3d562db4fcd7d7c46a11ce9e3168b782b1d89ae6881742b7ede82 SHA512 4a654af6a5d649dc87e00497245096b35a2894ae66f155cb62389902c3b93ddcc5cf7d0d8b9dd97b291d2d80bc686af2298e80abef6ac69883f4a54e79712513 DIST yansi-term-0.1.2.crate 14342 BLAKE2B 31a1651bb43644cf880d591a22fe9d899ab0acbc744ced2952f120b4abfa0c42f6513089e34deaff1a453f3a26f9fb78442f016baa9524ccac9b21e4a7ed6ad6 SHA512 ba720e36487871427aaa7139e8aeaf5b2b3f2d1df4798d7e238e323dc3d3220f12202e223f74339201be3466848c372dc1712e1842e5cd6bd51c3dedf76c9ff6 -EBUILD starlark-rust-0.4.0.ebuild 3616 BLAKE2B aae6a6b8d5d9b236b77c04354b37d9f1d7e281c50c36ca7ce488a760233d1774b4989b7716b11e2efa359e2049b4a2b01a9af36078945d28d6aebd040759f08f SHA512 7c2166c99ad503abd78e4dcf3bac81b68ca0be3ac5642e20470dfcbaa8014b77ded65852bc78b673f78b0eac8d660a1d0ce7a9a509a7dfcddeb7f5081c454e41 +EBUILD starlark-rust-0.4.0.ebuild 3722 BLAKE2B 29ee2374a066f36ceae5b9ccafbdc4e6c3bf448db6f291eee3d986f97cbc22db39d83c95cb134bf93ca1830efe56e010b7c956d23abbdfcd4c750dd3d8e5a28f SHA512 2cd0c4cbed27d7d2373c38b94fade3277553b34c1d3e12304400085c41f0e4615fb1361865f4af71dbed898e5eed37e6e73b71e4e8c03368a5eda1711546d94b MISC metadata.xml 601 BLAKE2B 917f50abeaa30d0b8b5c6d7d4505c138482321813cd791155289193d694ef37806a50c07fd789cb3206ea698eda0f182cdc216fc49f46e8d9c338776684b3748 SHA512 af72e05360ea24d1af783d877009b2119cf9a55b74266661290deb722358f3821a8cbbb1ac2da3ea704bc8ba091e155cbf55e3c9cf1997e89b1a1a3258771869 diff --git a/dev-lang/starlark-rust/files/test/features.bash b/dev-lang/starlark-rust/files/test/features.bash new file mode 100644 index 000000000000..1fd74e3326e9 --- /dev/null +++ b/dev-lang/starlark-rust/files/test/features.bash @@ -0,0 +1,193 @@ +#!/usr/bin/env bash + +# shellcheck disable=SC2034 +STARLARK_RUST_EXPECTED_functions=( + any + dir + fail + getattr + hasattr + hash + len + max + min + print + range + repr + reversed + sorted + type + zip +) + +# shellcheck disable=SC2034 +STARLARK_RUST_EXPECTED_types=( + bool + int + list + str + tuple + dict +) + +# shellcheck disable=SC2034 +STARLARK_RUST_EXPECTED_dict_methods=( + clear + get + items + keys + pop + popitem + setdefault + update + values +) + +# shellcheck disable=SC2034 +STARLARK_RUST_EXPECTED_list_methods=( + append + clear + extend + index + insert + pop + remove +) + +# shellcheck disable=SC2034 +STARLARK_RUST_EXPECTED_str_methods=( + capitalize + count + elems + endswith + find + format + index + isalnum + isalpha + isdigit + islower + isspace + istitle + isupper + join + lower + lstrip + partition + replace + rfind + rindex + rpartition + rsplit + rstrip + split + splitlines + startswith + strip + title + upper +) + +_test-features_execute-test() { + local error_msg test_title=$1 test_stdin=$2 exp_stdout=$3 exp_stderr=$4 exp_exitcode=$5 + ebegin "$test_title" + error_msg=$( + stderr_file=$(mktemp) || exit + cleanup() { rm -f "$stderr_file"; } + trap cleanup EXIT + + test_stdout=$("$starlark_binary" -i --json <<< "$test_stdin" 2>"$stderr_file") + test_exitcode=$? + + if (( test_exitcode != exp_exitcode )); then + echo "unexpected exit code \"$test_exitcode\", expected exit code \"$exp_exitcode\" for test_stdin: $test_stdin" + exit 1 + elif [[ "$test_stdout" != "$exp_stdout" ]]; then + echo "unexpected stdout \"$test_stdout\", expected stdout \"$exp_stdout\" for test_stdin: $test_stdin" + exit 1 + elif [[ $(< "$stderr_file") != "$exp_stderr" ]]; then + echo "unexpected stderr \"$(< "$stderr_file")\", expected stderr \"$exp_stderr\" for test_stdin: $test_stdin" + exit 1 + fi + exit 0 + ) + eend $? "$error_msg" + + # shellcheck disable=SC2015 + [[ $error_msg ]] && failures+=("$error_msg") || (( successes += 1 )) +} + +test-features_main() { + local starlark_binary=$1 + local failures=() successes=0 + local banner_width=45 + + local attr attr_type test_case + for attr_type in function type; do + printf -- '\n\n' >&2 + printf -- '%s\n' "Checking for existence of expected ${attr_type}s" >&2 + eval "printf -- '=%.0s' {1..${banner_width}}" >&2 + echo >&2 + while read -r attr; do + test_case=( + "$attr" + "$attr and print('$attr exists')" + "$attr exists" + "" + 0 + ) + _test-features_execute-test "${test_case[@]}" + done < <(eval "printf -- '%s\n' \"\${STARLARK_RUST_EXPECTED_${attr_type}s[@]}\"") + done + + local attr attr_type test_case type_literal + for attr_type in dict list str; do + printf -- '\n\n' >&2 + printf -- '%s\n' "Checking ${attr_type} built-in methods" >&2 + eval "printf -- '=%.0s' {1..${banner_width}}" >&2 + echo >&2 + + case $attr_type in + str) + type_literal='""' + ;; + *) + type_literal="$attr_type()" + ;; + esac + + while read -r attr; do + test_case=( + "$attr_type.$attr" + "hasattr($type_literal, \"$attr\") and print('$attr method exists')" + "$attr method exists" + "" + 0 + ) + _test-features_execute-test "${test_case[@]}" + done < <(eval "printf -- '%s\n' \"\${STARLARK_RUST_EXPECTED_${attr_type}_methods[@]}\"") + done + + printf -- '\n\n' >&2 + printf -- '%s\n' "Checking for miscellaneous starlark features" >&2 + eval "printf -- '=%.0s' {1..${banner_width}}" >&2 + printf -- '\n\n' >&2 + + test_case=( + 'list comprehension' + '[print("output from list comprehension") for i in range(0, 1) if (i == 0 and True) or not False]' + 'output from list comprehension' + "" + 0 + ) + _test-features_execute-test "${test_case[@]}" + printf -- '\n\n' >&2 + + if (( ${#failures[@]} > 0 )); then + echo "${#failures[@]} test (s) failed" >&2 + return 1 + elif (( successes == 0 )); then + echo "no tests ran" >&2 + return 1 + fi +} diff --git a/dev-lang/starlark-rust/starlark-rust-0.4.0.ebuild b/dev-lang/starlark-rust/starlark-rust-0.4.0.ebuild index 23f6be897226..6edd58cd1329 100644 --- a/dev-lang/starlark-rust/starlark-rust-0.4.0.ebuild +++ b/dev-lang/starlark-rust/starlark-rust-0.4.0.ebuild @@ -172,7 +172,6 @@ LICENSE="Apache-2.0" SLOT="0" KEYWORDS="~amd64" IUSE="" -RESTRICT+=" test" # Nightly rust-1.53.0 required for https://bugs.gentoo.org/796824 BDEPEND="${RUST_DEPEND} @@ -184,6 +183,11 @@ src_prepare() { default } +src_test() { + source "${FILESDIR}/test/features.bash" || die + test-features_main "${PWD}/target/release/starlark" || die +} + src_install() { dobin target/release/starlark ln "${ED}/usr/bin/starlark"{,-rust} || die |