mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Do not insert SPDX identifier if already present in SyntaxTest
This commit is contained in:
parent
5bbb017915
commit
6f1f0c5bbc
@ -51,13 +51,23 @@ TestCase::TestResult SyntaxTest::run(ostream& _stream, string const& _linePrefix
|
|||||||
return conclude(_stream, _linePrefix, _formatted);
|
return conclude(_stream, _linePrefix, _formatted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string SyntaxTest::addPreamble(string const& _sourceCode)
|
||||||
|
{
|
||||||
|
// Silence compiler version warning
|
||||||
|
string preamble = "pragma solidity >=0.0;\n";
|
||||||
|
// NOTE: this check is intentionally loose to match weird cases.
|
||||||
|
// We can manually adjust a test case where this causes problem.
|
||||||
|
if (_sourceCode.find("SPDX-License-Identifier:") == string::npos)
|
||||||
|
preamble += "// SPDX-License-Identifier: GPL-3.0\n";
|
||||||
|
return preamble + _sourceCode;
|
||||||
|
}
|
||||||
|
|
||||||
void SyntaxTest::setupCompiler()
|
void SyntaxTest::setupCompiler()
|
||||||
{
|
{
|
||||||
string const preamble = "pragma solidity >=0.0;\n// SPDX-License-Identifier: GPL-3.0\n";
|
|
||||||
compiler().reset();
|
compiler().reset();
|
||||||
auto sourcesWithPragma = m_sources;
|
auto sourcesWithPragma = m_sources;
|
||||||
for (auto& source: sourcesWithPragma)
|
for (auto& source: sourcesWithPragma)
|
||||||
source.second = preamble + source.second;
|
source.second = addPreamble(source.second);
|
||||||
compiler().setSources(sourcesWithPragma);
|
compiler().setSources(sourcesWithPragma);
|
||||||
compiler().setEVMVersion(m_evmVersion);
|
compiler().setEVMVersion(m_evmVersion);
|
||||||
compiler().setParserErrorRecovery(m_parserErrorRecovery);
|
compiler().setParserErrorRecovery(m_parserErrorRecovery);
|
||||||
|
@ -50,6 +50,9 @@ public:
|
|||||||
TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false) override;
|
TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
/// Returns @param _sourceCode prefixed with the version pragma and the SPDX license identifier.
|
||||||
|
static std::string addPreamble(std::string const& _sourceCode);
|
||||||
|
|
||||||
void setupCompiler();
|
void setupCompiler();
|
||||||
void parseAndAnalyze() override;
|
void parseAndAnalyze() override;
|
||||||
virtual void filterObtainedErrors();
|
virtual void filterObtainedErrors();
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
// This test is actually useless, as the test suite adds the automatic preamble.
|
||||||
contract C {}
|
contract C {}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
// This is just ignored:
|
|
||||||
// SPDX-License-Identifier: ⡉⡊⡋⡌⡍⡎⡏⡐⡑⡒
|
// SPDX-License-Identifier: ⡉⡊⡋⡌⡍⡎⡏⡐⡑⡒
|
||||||
contract C {}
|
contract C {}
|
||||||
|
// ----
|
||||||
|
// Warning 1878: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
|
||||||
|
Loading…
Reference in New Issue
Block a user