5#include <initializer_list>
21 std::initializer_list<const char*> additional_options = {}) {
22 std::vector<const char*> options = {
"--opengl-desktop",
"--input=input.vert",
24 "--spirv=output.spirv"};
25 options.insert(options.end(), additional_options.begin(),
26 additional_options.end());
33TEST(SwitchesTest, DoesntMangleUnicodeIncludes) {
34 const char* directory_name =
"test_shader_include_�";
40 auto include_option =
"--include=" + include_path;
44 ASSERT_TRUE(switches.
AreValid(std::cout));
50TEST(SwitchesTest, SourceLanguageDefaultsToGLSL) {
52 ASSERT_TRUE(switches.
AreValid(std::cout));
56TEST(SwitchesTest, SourceLanguageCanBeSetToHLSL) {
58 ASSERT_TRUE(switches.
AreValid(std::cout));
62TEST(SwitchesTest, DefaultEntryPointIsMain) {
64 ASSERT_TRUE(switches.
AreValid(std::cout));
68TEST(SwitchesTest, EntryPointCanBeSetForHLSL) {
70 ASSERT_TRUE(switches.
AreValid(std::cout));
71 ASSERT_EQ(switches.
entry_point,
"CustomEntryPoint");
76 "mandelbrot_unrolled");
78 "mandelbrotunrolled");
85TEST(SwitchesTest, ShaderBundleModeValid) {
88 std::vector<const char*> options = {
89 "--shader-bundle={}",
"--sl=test.shaderbundle",
"--runtime-stage-metal"};
94 ASSERT_TRUE(switches.
AreValid(std::cout));
98TEST(SwitchesTest, EntryPointPrefixIsApplied) {
101 ASSERT_TRUE(switches.
AreValid(std::cout));
106 EXPECT_EQ(options.entry_point_name,
"my_prefix_test_fragment_main");
109TEST(SwitchesTest, CommandLinePathUtf8) {
110 std::u16string filename = u
"test\u1234";
113 ASSERT_TRUE(switches.
AreValid(std::cout));
std::string entry_point_prefix
SourceLanguage source_language
std::string shader_bundle
bool AreValid(std::ostream &explain) const
SourceOptions CreateSourceOptions() const
std::vector< IncludeDir > include_directories
std::filesystem::path source_file_name
const char * GetFixturesPath()
Returns the directory containing the test fixture for the target if this target has fixtures configur...
fml::UniqueFD OpenFixturesDirectory()
Opens the fixtures directory for the unit-test harness.
std::string Utf16ToUtf8(const std::u16string_view string)
static fml::UniqueFD CreateDirectory(const fml::UniqueFD &base_directory, const std::vector< std::string > &components, FilePermission permission, size_t index)
CommandLine CommandLineFromIteratorsWithArgv0(const std::string &argv0, InputIterator first, InputIterator last)
Switches MakeSwitchesDesktopGL(std::initializer_list< const char * > additional_options={})
TEST(CompilerTest, Defines)
std::string ConvertToEntrypointName(std::string_view string)
Ensure that the entrypoint name is a valid identifier in the target language.