Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions glslc/src/dependency_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ bool DependencyInfoDumpingHandler::DumpDependencyInfo(
std::ofstream potential_file_stream_for_dep_info_dump;
std::ostream* dep_file_stream = shaderc_util::GetOutputStream(
dep_file_name, &potential_file_stream_for_dep_info_dump, &std::cerr);
if (!dep_file_stream) {
// An error message has already been emitted to the stderr stream.
return false;
}
*dep_file_stream << dep_string_stream.str();
if (dep_file_stream->fail()) {
std::cerr << "glslc: error: error writing dependent_files info to output "
Expand Down
10 changes: 10 additions & 0 deletions glslc/test/option_dash_M.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,3 +752,13 @@ class TestErrorMissingDependencyTargetName(expect.StderrMatch):
glslc_args = ['target', 'shader.vert', '-c', '-MT']
expected_stderr = ['glslc: error: '
'missing dependency info target after \'-MT\'\n']


@inside_glslc_testsuite('OptionsCapM')
class TestErrorDashMFUnwritableFile(expect.ErrorMessageSubstr):
"""Tests that when we fail to make an output dependency file, glslc
fails gracefully and emits an error message instead of crashing."""
environment = EMPTY_SHADER_IN_CURDIR
bad_file = '/file/should/not/exist/today.d'
glslc_args = ['-MD', '-MF', bad_file, 'shader.vert']
expected_error_substr = ['cannot open output file']
Loading