Merge pull request #3754 from AnthonyBroadCrawford/error-on-missing-file

Error on non existing or irregular files
This commit is contained in:
Alex Beregszaszi 2018-03-29 01:53:56 +01:00 committed by GitHub
commit c2ae33f806
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 7 deletions

View File

@ -1,6 +1,7 @@
### 0.4.22 (unreleased) ### 0.4.22 (unreleased)
Features: Features:
* Commandline interface: Error when missing or inaccessible file detected. Suppress it with the ``--ignore-missing`` flag.
* General: Support accessing dynamic return data in post-byzantium EVMs. * General: Support accessing dynamic return data in post-byzantium EVMs.
* Interfaces: Allow overriding external functions in interfaces with public in an implementing contract. * Interfaces: Allow overriding external functions in interfaces with public in an implementing contract.

View File

@ -116,6 +116,7 @@ static string const g_strStandardJSON = "standard-json";
static string const g_strStrictAssembly = "strict-assembly"; static string const g_strStrictAssembly = "strict-assembly";
static string const g_strPrettyJson = "pretty-json"; static string const g_strPrettyJson = "pretty-json";
static string const g_strVersion = "version"; static string const g_strVersion = "version";
static string const g_strIgnoreMissingFiles = "ignore-missing";
static string const g_argAbi = g_strAbi; static string const g_argAbi = g_strAbi;
static string const g_argPrettyJson = g_strPrettyJson; static string const g_argPrettyJson = g_strPrettyJson;
@ -152,6 +153,7 @@ static string const g_argStandardJSON = g_strStandardJSON;
static string const g_argStrictAssembly = g_strStrictAssembly; static string const g_argStrictAssembly = g_strStrictAssembly;
static string const g_argVersion = g_strVersion; static string const g_argVersion = g_strVersion;
static string const g_stdinFileName = g_stdinFileNameStr; static string const g_stdinFileName = g_stdinFileNameStr;
static string const g_argIgnoreMissingFiles = g_strIgnoreMissingFiles;
/// Possible arguments to for --combined-json /// Possible arguments to for --combined-json
static set<string> const g_combinedJsonArgs static set<string> const g_combinedJsonArgs
@ -398,8 +400,9 @@ void CommandLineInterface::handleGasEstimation(string const& _contract)
} }
} }
void CommandLineInterface::readInputFilesAndConfigureRemappings() bool CommandLineInterface::readInputFilesAndConfigureRemappings()
{ {
bool ignoreMissing = m_args.count(g_argIgnoreMissingFiles);
bool addStdin = false; bool addStdin = false;
if (!m_args.count(g_argInputFile)) if (!m_args.count(g_argInputFile))
addStdin = true; addStdin = true;
@ -416,13 +419,27 @@ void CommandLineInterface::readInputFilesAndConfigureRemappings()
auto infile = boost::filesystem::path(path); auto infile = boost::filesystem::path(path);
if (!boost::filesystem::exists(infile)) if (!boost::filesystem::exists(infile))
{ {
cerr << "Skipping non-existent input file \"" << infile << "\"" << endl; if (!ignoreMissing)
{
cerr << "\"" << infile << "\" is not found" << endl;
return false;
}
else
cerr << "\"" << infile << "\" is not found. Skipping." << endl;
continue; continue;
} }
if (!boost::filesystem::is_regular_file(infile)) if (!boost::filesystem::is_regular_file(infile))
{ {
cerr << "\"" << infile << "\" is not a valid file. Skipping" << endl; if (!ignoreMissing)
{
cerr << "\"" << infile << "\" is not a valid file" << endl;
return false;
}
else
cerr << "\"" << infile << "\" is not a valid file. Skipping." << endl;
continue; continue;
} }
@ -433,6 +450,8 @@ void CommandLineInterface::readInputFilesAndConfigureRemappings()
} }
if (addStdin) if (addStdin)
m_sourceCodes[g_stdinFileName] = dev::readStandardInput(); m_sourceCodes[g_stdinFileName] = dev::readStandardInput();
return true;
} }
bool CommandLineInterface::parseLibraryOption(string const& _input) bool CommandLineInterface::parseLibraryOption(string const& _input)
@ -599,7 +618,8 @@ Allowed options)",
g_argAllowPaths.c_str(), g_argAllowPaths.c_str(),
po::value<string>()->value_name("path(s)"), po::value<string>()->value_name("path(s)"),
"Allow a given path for imports. A list of paths can be supplied by separating them with a comma." "Allow a given path for imports. A list of paths can be supplied by separating them with a comma."
); )
(g_argIgnoreMissingFiles.c_str(), "Ignore missing files.");
po::options_description outputComponents("Output Components"); po::options_description outputComponents("Output Components");
outputComponents.add_options() outputComponents.add_options()
(g_argAst.c_str(), "AST of all source files.") (g_argAst.c_str(), "AST of all source files.")
@ -741,7 +761,8 @@ bool CommandLineInterface::processInput()
return true; return true;
} }
readInputFilesAndConfigureRemappings(); if (!readInputFilesAndConfigureRemappings())
return false;
if (m_args.count(g_argLibraries)) if (m_args.count(g_argLibraries))
for (string const& library: m_args[g_argLibraries].as<vector<string>>()) for (string const& library: m_args[g_argLibraries].as<vector<string>>())

View File

@ -72,7 +72,7 @@ private:
void handleFormal(); void handleFormal();
/// Fills @a m_sourceCodes initially and @a m_redirects. /// Fills @a m_sourceCodes initially and @a m_redirects.
void readInputFilesAndConfigureRemappings(); bool readInputFilesAndConfigureRemappings();
/// Tries to read from the file @a _input or interprets _input literally if that fails. /// Tries to read from the file @a _input or interprets _input literally if that fails.
/// It then tries to parse the contents and appends to m_libraries. /// It then tries to parse the contents and appends to m_libraries.
bool parseLibraryOption(std::string const& _input); bool parseLibraryOption(std::string const& _input);

View File

@ -32,7 +32,7 @@ REPO_ROOT=$(cd $(dirname "$0")/.. && pwd)
echo $REPO_ROOT echo $REPO_ROOT
SOLC="$REPO_ROOT/build/solc/solc" SOLC="$REPO_ROOT/build/solc/solc"
FULLARGS="--optimize --combined-json abi,asm,ast,bin,bin-runtime,clone-bin,compact-format,devdoc,hashes,interface,metadata,opcodes,srcmap,srcmap-runtime,userdoc" FULLARGS="--optimize --ignore-missing --combined-json abi,asm,ast,bin,bin-runtime,clone-bin,compact-format,devdoc,hashes,interface,metadata,opcodes,srcmap,srcmap-runtime,userdoc"
echo "Checking that the bug list is up to date..." echo "Checking that the bug list is up to date..."
"$REPO_ROOT"/scripts/update_bugs_by_version.py "$REPO_ROOT"/scripts/update_bugs_by_version.py