externalTests: Generalize force_truffle_solc_modules and make it use symlinks instead of redownloading solc-js

This commit is contained in:
Kamil Śliwak 2021-10-27 16:26:52 +02:00
parent c090ff9d83
commit 0745279f15
6 changed files with 17 additions and 20 deletions

View File

@ -52,7 +52,7 @@ function colony_test
cd ..
replace_version_pragmas
force_truffle_solc_modules "$SOLJSON"
force_solc_modules "${DIR}/solc"
for level in $(seq "$min_optimizer_level" "$max_optimizer_level"); do
truffle_run_test "$config_file" "${DIR}/solc" "$level" compile_fn test_fn

View File

@ -112,25 +112,22 @@ function neutralize_package_json_hooks
sed -i 's|"prepare": *".*"|"prepare": ""|g' package.json
}
function force_truffle_solc_modules
function force_solc_modules
{
local soljson="$1"
local custom_solcjs_path="${1:-solc/}"
# Replace solc package by v0.5.0 and then overwrite with current version.
printLog "Forcing solc version for all Truffle modules..."
for d in node_modules node_modules/truffle/node_modules
[[ -d node_modules/ ]] || assertFail
printLog "Replacing all installed solc-js with a link to the latest version..."
soljson_binaries=$(find node_modules -type f -path "*/solc/soljson.js")
for soljson_binary in $soljson_binaries
do
(
if [ -d "$d" ]; then
cd $d
rm -rf solc
git clone --depth 1 -b master https://github.com/ethereum/solc-js.git solc
cp "$soljson" solc/soljson.js
local solc_module_path
solc_module_path=$(dirname "$soljson_binary")
cd solc
npm install
fi
)
printLog "Found and replaced solc-js in $solc_module_path"
rm -r "$solc_module_path"
ln -s "$custom_solcjs_path" "$solc_module_path"
done
}

View File

@ -50,7 +50,7 @@ function ens_test
npm install
replace_version_pragmas
force_truffle_solc_modules "$SOLJSON"
force_solc_modules "${DIR}/solc"
for level in $(seq "$min_optimizer_level" "$max_optimizer_level"); do
truffle_run_test "$config_file" "${DIR}/solc" "$level" compile_fn test_fn

View File

@ -51,7 +51,7 @@ function gnosis_safe_test
npm install --package-lock
replace_version_pragmas
force_truffle_solc_modules "$SOLJSON"
force_solc_modules "${DIR}/solc"
for level in $(seq "$min_optimizer_level" "$max_optimizer_level"); do
truffle_run_test "$config_file" "${DIR}/solc" "$level" compile_fn test_fn

View File

@ -49,7 +49,7 @@ function gnosis_safe_test
npm install --package-lock
replace_version_pragmas
force_truffle_solc_modules "$SOLJSON"
force_solc_modules "${DIR}/solc"
for level in $(seq "$min_optimizer_level" "$max_optimizer_level"); do
truffle_run_test "$config_file" "${DIR}/solc" "$level" compile_fn test_fn

View File

@ -46,7 +46,7 @@ function zeppelin_test
npm install
replace_version_pragmas
force_truffle_solc_modules "$SOLJSON"
force_solc_modules "${DIR}/solc"
for level in $(seq "$min_optimizer_level" "$max_optimizer_level"); do
truffle_run_test "$config_file" "${DIR}/solc" "$level" compile_fn test_fn