Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add assert-contains.py script #86

Merged
merged 1 commit into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions scripts/assert-contains.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/python3

"""
Asserts that stdin contains the <PATTERN> provided as CLI argument.
"""

import sys

if len(sys.argv) != 2:
sys.exit(sys.argv[0] + " <PATTERN>")

pattern = sys.argv[1]
input_content = sys.stdin.read()

if pattern in input_content:
sys.exit(0)

print("Pattern not in input", file=sys.stderr)
print("Pattern:", pattern, file=sys.stderr)
print("Input:", input_content, file=sys.stderr)

sys.exit(1)
6 changes: 3 additions & 3 deletions test/configuration-tests/with-compilation-options/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ CONTRACT_NAME=contract_with_execute.cairo

cp "$PREFIX/$CONTRACT_NAME" contracts/

EXPECTED='Only account contracts may have a function named "__execute__". Use --account-contract flag.'

echo "Testing rejection of compilation without the account flag"
npx hardhat starknet-compile "contracts/$CONTRACT_NAME" 2>&1 \
| tail -n +3 \
| head -n 1 \
| diff - "$PREFIX/without-account-flag.txt"
| ../scripts/assert-contains.py "$EXPECTED"
echo "Success"

npx hardhat starknet-compile "contracts/$CONTRACT_NAME" --account-contract

This file was deleted.