boost::test test cases are flexible but cumbersome. They're somewhat verbose and don't have an expectation update mechanism like isoltest. They're also more tedious to review. We are generally replacing them with custom isoltest TestCases.
solc input.json
--standard-json
--base-path=/home/user/
--include-path=/usr/lib/include/
--include-path=/home/user/include
--allow-paths=/tmp,/home,project,../contracts
--ignore-missing
--output-dir=/tmp/out # Accepted but has no effect in Standard JSON mode
--overwrite # Accepted but has no effect in Standard JSON mode
--evm-version=spuriousDragon # Ignored in Standard JSON mode
--revert-strings=strip # Accepted but has no effect in Standard JSON mode
--pretty-json
--json-indent=1
--no-color # Accepted but has no effect in Standard JSON mode
--error-codes # Accepted but has no effect in Standard JSON mode
--libraries=dir1/file1.sol:L=0x1234567890123456789012345678901234567890,dir2/file2.sol:L=0x1111122222333334444455555666667777788888 # Ignored in Standard JSON mode
--gas # Accepted but has no effect in Standard JSON mode
--combined-json=abi,bin # Accepted but has no effect in Standard JSON mode
// ----
// .cliOptions: {
// "input": {
// "mode": "standard-json",
// "paths": ["input.json"],
// "basePath": "/home/user/",
// "includePaths": ["/usr/lib/include/", "/home/user/include"],
// "allowedDirectories": ["/tmp", "/home", "project", "../contracts"],
// "ignoreMissingFiles": true
// },
// "output": {
// "dir": "/tmp/out",
// "overwriteFiles": true,
// "revertStrings": "strip"
// },
// "formatting": {
// "json": {"pretty": true, "indent": 1},
// "coloredOutput": false,
// "withErrorIds": false
// },
// "compiler": {
// "estimateGas": true,
// "combinedJsonRequests": ["abi", "bin"]
// }
// }
// .cliOptions.assembly.targetMachine: <PATH NOT FOUND>
solc input.json
--standard-json
--base-path=/home/user/
--include-path=/usr/lib/include/
--include-path=/home/user/include
--allow-paths=/tmp,/home,project,../contracts
--ignore-missing
--output-dir=/tmp/out # Accepted but has no effect in Standard JSON mode
--overwrite # Accepted but has no effect in Standard JSON mode
--evm-version=spuriousDragon # Ignored in Standard JSON mode
--revert-strings=strip # Accepted but has no effect in Standard JSON mode
--pretty-json
--json-indent=1
--no-color # Accepted but has no effect in Standard JSON mode
--error-codes # Accepted but has no effect in Standard JSON mode
--libraries=dir1/file1.sol:L=0x1234567890123456789012345678901234567890,dir2/file2.sol:L=0x1111122222333334444455555666667777788888 # Ignored in Standard JSON mode
--gas # Accepted but has no effect in Standard JSON mode
--combined-json=abi,bin # Accepted but has no effect in Standard JSON mode
// ====
// showUnchangedCliOptions: true
// ----
// .cliOptions: {
// "input": {
// "mode": "standard-json",
// "paths": ["input.json"],
// "remappings": [],
// "addStdin": false,
// "basePath": "/home/user/",
// "includePaths": ["/usr/lib/include/", "/home/user/include"],
// "allowedDirectories": ["/tmp", "/home", "project", "../contracts"],
// "ignoreMissingFiles": true,
// "noImportCallback": false
// },
// "output": {
// "dir": "/tmp/out",
// "overwriteFiles": true,
// "evmVersion": "osaka",
// "viaIR": false,
// "viaSSACFG": false,
// "revertStrings": "strip",
// "debugInfoSelection": null,
// "stopAfter": "compilation-successful"
// },
// "assembly": {
// "targetMachine": "evm"
// },
// "linker": {
// "libraries": {}
// },
// "formatting": {
// "json": {"pretty": true, "indent": 1},
// "coloredOutput": false,
// "withErrorIds": false
// },
// "compiler": {
// "outputs": [],
// "estimateGas": true,
// "combinedJsonRequests": ["abi", "bin"]
// },
// "metadata": {
// "format": "with-release-version-tag",
// "hash": "ipfs",
// "literalSources": false
// },
// "optimizer": {
// "optimizeEvmasm": false,
// "optimizeYul": false;
// "expectedExecutionsPerDeployment": null,
// "yulSteps": null
// },
// "modelChecker": {
// "initialize": false,
// "settings": {
// "bmcLoopIterations": null;
// "contracts": {},
// "divModNoSlacks": false;
// "engine": [],
// "externalCalls": "untrusted",
// "invariants": [],
// "printQuery": false,
// "showProvedSafe": false,
// "showUnproved": false,
// "showUnsupported": false,
// "solvers": ["z3"],
// "targets": ["constantCondition", "divByZero", "balance", "assert", "popEmptyArray", "outOfBounds"],
// "timeout": null
// }
// },
// "experimental": false
// }
Abstract
Define a new
TestCaseto replace the boost::test-basedCommandLineParserTest. The test case should for the most part work like the one defined in #17013, just exercising a single component rather than a full compilation pipeline.An additional output for inspecting the parsed options should be available (
.cliOptions).Motivation
boost::test test cases are flexible but cumbersome. They're somewhat verbose and don't have an expectation update mechanism like isoltest. They're also more tedious to review. We are generally replacing them with custom isoltest
TestCases.Specification
The new test case should be distinct from the one in #17013 but share most of the underlying functionality through a common base class. This includes:
.exit,.stderr,.stdoutoutputsExpected differences:
CommandLineParserand stops once it obtainsCommandLineOptionsstruct. We want to test a single component rather than the whole compiler end-to-end.StandardCompiler. This means that we cannot access itsInputsAndSettings. We might provide a separate test case for this in the future..exit,.stderr,.stdoutoutputs are available but may be incomplete compared to a full run. Especially errors that would only happen at later stages will not be present.CommandLineOptionsis exposed as an additional output:.cliOptions.standardJSON,implicitOptions,stripPrereleaseWarning,stripLicenseWarning,stripVersionWarning).showUnchangedCliOptions(bool). false by default. Unless enabled, fields that are equal to their defaults are not included in.cliOptions.Examples
This shows what
standard_json_mode_optionswould look like with such a test case.Without unchanged options
With unchanged options