@@ -57,6 +57,13 @@ ObjectCompilerTest::ObjectCompilerTest(std::string const& _filename):
57
57
},
58
58
" minimal"
59
59
);
60
+
61
+ constexpr std::array allowedOutputs = {" Assembly" , " Bytecode" , " Opcodes" , " SourceMappings" };
62
+ boost::split (m_outputSetting, m_reader.stringSetting (" outputs" , " Assembly,Bytecode,Opcodes,SourceMappings" ), boost::is_any_of (" ," ));
63
+ for (auto const & output: m_outputSetting)
64
+ if (std::find (allowedOutputs.begin (), allowedOutputs.end (), output) == allowedOutputs.end ())
65
+ BOOST_THROW_EXCEPTION (std::runtime_error{" Invalid output type: \" " + output + " \" " });
66
+
60
67
m_expectation = m_reader.simpleExpectations ();
61
68
}
62
69
@@ -78,18 +85,26 @@ TestCase::TestResult ObjectCompilerTest::run(std::ostream& _stream, std::string
78
85
solAssert (obj.bytecode );
79
86
solAssert (obj.sourceMappings );
80
87
81
- m_obtainedResult = " Assembly:\n " + obj.assembly ->assemblyString (yulStack.debugInfoSelection ());
88
+ if (std::find (m_outputSetting.begin (), m_outputSetting.end (), " Assembly" ) != m_outputSetting.end ())
89
+ m_obtainedResult = " Assembly:\n " + obj.assembly ->assemblyString (yulStack.debugInfoSelection ());
82
90
if (obj.bytecode ->bytecode .empty ())
83
91
m_obtainedResult += " -- empty bytecode --\n " ;
84
92
else
85
- m_obtainedResult +=
86
- " Bytecode: " +
87
- util::toHex (obj.bytecode ->bytecode ) +
88
- " \n Opcodes: " +
89
- boost::trim_copy (evmasm::disassemble (obj.bytecode ->bytecode , solidity::test::CommonOptions::get ().evmVersion ())) +
90
- " \n SourceMappings:" +
91
- (obj.sourceMappings ->empty () ? " " : " " + *obj.sourceMappings ) +
92
- " \n " ;
93
+ {
94
+ if (std::find (m_outputSetting.begin (), m_outputSetting.end (), " Bytecode" ) != m_outputSetting.end ())
95
+ m_obtainedResult += " Bytecode: " + util::toHex (obj.bytecode ->bytecode );
96
+ if (std::find (m_outputSetting.begin (), m_outputSetting.end (), " Opcodes" ) != m_outputSetting.end ())
97
+ {
98
+ m_obtainedResult += (!m_obtainedResult.empty () && m_obtainedResult.back () != ' \n ' ) ? " \n " : " " ;
99
+ m_obtainedResult += " Opcodes: " +
100
+ boost::trim_copy (evmasm::disassemble (obj.bytecode ->bytecode , solidity::test::CommonOptions::get ().evmVersion ()));
101
+ }
102
+ if (std::find (m_outputSetting.begin (), m_outputSetting.end (), " SourceMappings" ) != m_outputSetting.end ())
103
+ {
104
+ m_obtainedResult += (!m_obtainedResult.empty () && m_obtainedResult.back () != ' \n ' ) ? " \n " : " " ;
105
+ m_obtainedResult += " SourceMappings:" + (obj.sourceMappings ->empty () ? " " : " " + *obj.sourceMappings ) + " \n " ;
106
+ }
107
+ }
93
108
94
109
return checkResult (_stream, _linePrefix, _formatted);
95
110
}
0 commit comments