mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
externalTests: Add support for hardhat.config.ts
This commit is contained in:
parent
eee30b6ead
commit
19b1a13c6d
@ -189,14 +189,17 @@ function force_hardhat_compiler_binary
|
||||
echo "Config file: ${config_file}"
|
||||
echo "Binary type: ${binary_type}"
|
||||
echo "Compiler path: ${solc_path}"
|
||||
hardhat_solc_build_subtask "$SOLCVERSION_SHORT" "$SOLCVERSION" "$binary_type" "$solc_path" >> "$config_file"
|
||||
|
||||
local language="${config_file##*.}"
|
||||
hardhat_solc_build_subtask "$SOLCVERSION_SHORT" "$SOLCVERSION" "$binary_type" "$solc_path" "$language" >> "$config_file"
|
||||
}
|
||||
|
||||
function force_hardhat_compiler_settings
|
||||
{
|
||||
local config_file="$1"
|
||||
local preset="$2"
|
||||
local evm_version="${3:-"$CURRENT_EVM_VERSION"}"
|
||||
local config_var_name="$3"
|
||||
local evm_version="${4:-"$CURRENT_EVM_VERSION"}"
|
||||
|
||||
printLog "Configuring Hardhat..."
|
||||
echo "-------------------------------------"
|
||||
@ -208,10 +211,16 @@ function force_hardhat_compiler_settings
|
||||
echo "Compiler version (full): ${SOLCVERSION}"
|
||||
echo "-------------------------------------"
|
||||
|
||||
{
|
||||
echo -n 'module.exports["solidity"] = '
|
||||
hardhat_compiler_settings "$SOLCVERSION_SHORT" "$preset" "$evm_version"
|
||||
} >> "$config_file"
|
||||
local settings
|
||||
settings=$(hardhat_compiler_settings "$SOLCVERSION_SHORT" "$preset" "$evm_version")
|
||||
if [[ $config_file == *\.js ]]; then
|
||||
[[ $config_var_name == "" ]] || assertFail
|
||||
echo "module.exports['solidity'] = ${settings}" >> "$config_file"
|
||||
else
|
||||
[[ $config_file == *\.ts ]] || assertFail
|
||||
[[ $config_var_name != "" ]] || assertFail
|
||||
echo "${config_var_name}.solidity = {compilers: [${settings}]}" >> "$config_file"
|
||||
fi
|
||||
}
|
||||
|
||||
function truffle_verify_compiler_version
|
||||
@ -309,16 +318,27 @@ function hardhat_solc_build_subtask {
|
||||
local full_solc_version="$2"
|
||||
local binary_type="$3"
|
||||
local solc_path="$4"
|
||||
local language="$5"
|
||||
|
||||
[[ $binary_type == native || $binary_type == solcjs ]] || assertFail
|
||||
|
||||
[[ $binary_type == native ]] && local is_solcjs=false
|
||||
[[ $binary_type == solcjs ]] && local is_solcjs=true
|
||||
|
||||
if [[ $language == js ]]; then
|
||||
echo "const {TASK_COMPILE_SOLIDITY_GET_SOLC_BUILD} = require('hardhat/builtin-tasks/task-names');"
|
||||
echo "const assert = require('assert');"
|
||||
echo
|
||||
echo "subtask(TASK_COMPILE_SOLIDITY_GET_SOLC_BUILD, async (args, hre, runSuper) => {"
|
||||
else
|
||||
[[ $language == ts ]] || assertFail
|
||||
echo "import {TASK_COMPILE_SOLIDITY_GET_SOLC_BUILD} from 'hardhat/builtin-tasks/task-names';"
|
||||
echo "import assert = require('assert');"
|
||||
echo "import {subtask} from 'hardhat/config';"
|
||||
echo
|
||||
echo "subtask(TASK_COMPILE_SOLIDITY_GET_SOLC_BUILD, async (args: any, _hre: any, _runSuper: any) => {"
|
||||
fi
|
||||
|
||||
echo " assert(args.solcVersion == '${solc_version}', 'Unexpected solc version: ' + args.solcVersion)"
|
||||
echo " return {"
|
||||
echo " compilerPath: '$(realpath "$solc_path")',"
|
||||
@ -384,9 +404,10 @@ function hardhat_run_test
|
||||
local compile_only_presets="$3"
|
||||
local compile_fn="$4"
|
||||
local test_fn="$5"
|
||||
local config_var_name="$6"
|
||||
|
||||
hardhat_clean
|
||||
force_hardhat_compiler_settings "$config_file" "$preset"
|
||||
force_hardhat_compiler_settings "$config_file" "$preset" "$config_var_name"
|
||||
compile_and_run_test compile_fn test_fn hardhat_verify_compiler_version "$preset" "$compile_only_presets"
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user