Skip to content

Commit

Permalink
add error functions in tests scripts and print test names
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherDedominici committed Nov 28, 2023
1 parent 6817465 commit 3d41ff6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion e2e/fixture-projects/flatten/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "minimal",
"name": "flatten",
"dependencies": {
"hardhat": "file:../../../packages/hardhat-core/hardhat-2.19.1.tgz"
}
Expand Down
21 changes: 13 additions & 8 deletions e2e/fixture-projects/flatten/test.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
#! /usr/bin/env sh

# import helpers functions
. ../../helpers.sh

echo "Running tests: $(basename "$(pwd)")"

# replace the hardhat version in the files used to check that the output is correct because it changes in every release
sed -i "s/hardhat v[0-9]*\.[0-9]*\.[0-9]*/hardhat v$1/g" "flatten_all_files.txt"
sed -i "s/hardhat v[0-9]*\.[0-9]*\.[0-9]*/hardhat v$1/g" "flatten_lock_file.txt"

# it should flatten all the files in the folder because no file names are passed
if ! npx hardhat flatten | diff - flatten_all_files.txt; then
echo "The flatten file is different from the flatten_all_files.txt"
exit 1
echo "it should flatten all the files in the folder because no file names are passed"
if ! npx hardhat flatten 2>stderr | diff - flatten_all_files.txt; then
print_error_msg "The flatten file is different from the flatten_all_files.txt"
exit 1
fi

# it should flatten only the 'Lock.sol' file because it is passed as an argument
if ! npx hardhat flatten contracts/Lock.sol | diff - flatten_lock_file.txt; then
echo "The flatten file is different from the flatten_lock_file.txt"
exit 1
echo "it should flatten only the 'Lock.sol' file because it is passed as an argument"
if ! npx hardhat flatten contracts/Lock.sol 2>stderr | diff - flatten_lock_file.txt; then
print_error_msg "The flatten file is different from the flatten_lock_file.txt"
exit 1
fi
7 changes: 5 additions & 2 deletions e2e/fixture-projects/minimal-project/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
# fail if any commands fails
set -e

npx hardhat compile
npx hardhat test
echo "Running tests: $(basename "$(pwd)")"

echo "it should compile and run the tests in the project folder"
npx hardhat compile >stdout 2>stderr
npx hardhat test >stdout 2>stderr

0 comments on commit 3d41ff6

Please sign in to comment.