diff --git a/test/libsolidity/AnalysisFramework.cpp b/test/libsolidity/AnalysisFramework.cpp index a55ed68c9..a88c14581 100644 --- a/test/libsolidity/AnalysisFramework.cpp +++ b/test/libsolidity/AnalysisFramework.cpp @@ -51,9 +51,11 @@ AnalysisFramework::parseAnalyseAndReturnError( ) { compiler().reset(); + // Do not insert license if it is already present. + bool insertLicense = _insertLicenseAndVersionPragma && _source.find("// SPDX-License-Identifier:") == string::npos; compiler().setSources({{"", - _insertLicenseAndVersionPragma ? - "pragma solidity >=0.0;\n// SPDX-License-Identifier: GPL-3.0\n" + _source : + string{_insertLicenseAndVersionPragma ? "pragma solidity >=0.0;\n" : ""} + + string{insertLicense ? "// SPDX-License-Identifier: GPL-3.0\n" : ""} + _source }}); compiler().setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); diff --git a/test/libsolidity/SolidityExecutionFramework.cpp b/test/libsolidity/SolidityExecutionFramework.cpp index d46ce0dfd..366273faf 100644 --- a/test/libsolidity/SolidityExecutionFramework.cpp +++ b/test/libsolidity/SolidityExecutionFramework.cpp @@ -132,7 +132,9 @@ bytes SolidityExecutionFramework::compileContract( string SolidityExecutionFramework::addPreamble(string const& _sourceCode) { // Silence compiler version warning - string preamble = "pragma solidity >=0.0;\n// SPDX-License-Identifier: unlicensed\n"; + string preamble = "pragma solidity >=0.0;\n"; + if (_sourceCode.find("// SPDX-License-Identifier:") == string::npos) + preamble += "// SPDX-License-Identifier: unlicensed\n"; if ( solidity::test::CommonOptions::get().useABIEncoderV2 && _sourceCode.find("pragma experimental ABIEncoderV2;") == string::npos &&