@@ -61,7 +61,8 @@ TEST_F(CompilerTest, CompleteShader)
6161
6262 auto stage = static_cast <Stage>(i);
6363 std::vector<Parser::LineMapping> lineMappings;
64- std::string glsl = parser.createShaderString (lineMappings, output, pipeline, stage);
64+ std::string glsl =
65+ parser.createShaderString (lineMappings, output, pipeline, stage, false , false );
6566 EXPECT_TRUE (Compiler::compile (stages, output, shaderName, glsl, lineMappings, stage,
6667 Compiler::getDefaultResources ()));
6768 compiledStage = true ;
@@ -102,7 +103,40 @@ TEST_F(CompilerTest, CompileError)
102103
103104 auto stage = Stage::Fragment;
104105 std::vector<Parser::LineMapping> lineMappings;
105- std::string glsl = parser.createShaderString (lineMappings, output, pipeline, stage);
106+ std::string glsl =
107+ parser.createShaderString (lineMappings, output, pipeline, stage, false , false );
108+ EXPECT_FALSE (Compiler::compile (stages, output, shaderName, glsl, lineMappings, stage,
109+ Compiler::getDefaultResources ()));
110+
111+ const std::vector<Output::Message>& messages = output.getMessages ();
112+ ASSERT_LE (1U , messages.size ());
113+ EXPECT_EQ (Output::Level::Error, messages[0 ].level );
114+ EXPECT_TRUE (boost::algorithm::ends_with (pathStr (messages[0 ].file ),
115+ pathStr (inputDir/" CompileError.mslh" )));
116+ EXPECT_EQ (15U , messages[0 ].line );
117+ EXPECT_EQ (" 'inputss' : undeclared identifier" , messages[0 ].message );
118+ }
119+
120+ TEST_F (CompilerTest, CompileErrorWithEarlyFragmentTests)
121+ {
122+ boost::filesystem::path inputDir = exeDir/" inputs" ;
123+ std::string shaderName = pathStr (inputDir/" CompileError.msl" );
124+
125+ Parser parser;
126+ Preprocessor preprocessor;
127+ Output output;
128+ preprocessor.addIncludePath (pathStr (inputDir));
129+ EXPECT_TRUE (preprocessor.preprocess (parser.getTokens (), output, shaderName));
130+ EXPECT_TRUE (parser.parse (output));
131+
132+ ASSERT_EQ (1U , parser.getPipelines ().size ());
133+ const Parser::Pipeline& pipeline = parser.getPipelines ()[0 ];
134+ Compiler::Stages stages;
135+
136+ auto stage = Stage::Fragment;
137+ std::vector<Parser::LineMapping> lineMappings;
138+ std::string glsl =
139+ parser.createShaderString (lineMappings, output, pipeline, stage, false , true );
106140 EXPECT_FALSE (Compiler::compile (stages, output, shaderName, glsl, lineMappings, stage,
107141 Compiler::getDefaultResources ()));
108142
@@ -133,7 +167,8 @@ TEST_F(CompilerTest, CompileWarning)
133167
134168 auto stage = Stage::Fragment;
135169 std::vector<Parser::LineMapping> lineMappings;
136- std::string glsl = parser.createShaderString (lineMappings, output, pipeline, stage);
170+ std::string glsl =
171+ parser.createShaderString (lineMappings, output, pipeline, stage, false , false );
137172 EXPECT_TRUE (Compiler::compile (stages, output, shaderName, glsl, lineMappings, stage,
138173 Compiler::getDefaultResources ()));
139174
@@ -169,7 +204,8 @@ TEST_F(CompilerTest, MissingEntryPoint)
169204
170205 auto stage = static_cast <Stage>(i);
171206 std::vector<Parser::LineMapping> lineMappings;
172- std::string glsl = parser.createShaderString (lineMappings, output, pipeline, stage);
207+ std::string glsl =
208+ parser.createShaderString (lineMappings, output, pipeline, stage, false , false );
173209 if (stage == Stage::Fragment)
174210 EXPECT_TRUE (glsl.empty ());
175211 else
@@ -210,7 +246,8 @@ TEST_F(CompilerTest, DuplicateEntryPoint)
210246
211247 auto stage = static_cast <Stage>(i);
212248 std::vector<Parser::LineMapping> lineMappings;
213- std::string glsl = parser.createShaderString (lineMappings, output, pipeline, stage);
249+ std::string glsl =
250+ parser.createShaderString (lineMappings, output, pipeline, stage, false , false );
214251 if (stage == Stage::Fragment)
215252 EXPECT_TRUE (glsl.empty ());
216253 else
0 commit comments