5#include <initializer_list>
20 std::initializer_list<const char*> additional_options = {}) {
21 std::vector<const char*> options = {
"--opengl-desktop",
"--input=input.vert",
23 "--spirv=output.spirv"};
24 options.insert(options.end(), additional_options.begin(),
25 additional_options.end());
32TEST(SwitchesTest, DoesntMangleUnicodeIncludes) {
33 const char* directory_name =
"test_shader_include_�";
39 auto include_option =
"--include=" + include_path;
43 ASSERT_TRUE(switches.
AreValid(std::cout));
49TEST(SwitchesTest, SourceLanguageDefaultsToGLSL) {
51 ASSERT_TRUE(switches.
AreValid(std::cout));
55TEST(SwitchesTest, SourceLanguageCanBeSetToHLSL) {
57 ASSERT_TRUE(switches.
AreValid(std::cout));
61TEST(SwitchesTest, DefaultEntryPointIsMain) {
63 ASSERT_TRUE(switches.
AreValid(std::cout));
67TEST(SwitchesTest, EntryPointCanBeSetForHLSL) {
69 ASSERT_TRUE(switches.
AreValid(std::cout));
70 ASSERT_EQ(switches.
entry_point,
"CustomEntryPoint");
75 "mandelbrot_unrolled");
77 "mandelbrotunrolled");
84TEST(SwitchesTest, ShaderBundleModeValid) {
87 std::vector<const char*> options = {
88 "--shader-bundle={}",
"--sl=test.shaderbundle",
"--runtime-stage-metal"};
93 ASSERT_TRUE(switches.
AreValid(std::cout));
97TEST(SwitchesTest, EntryPointPrefixIsApplied) {
100 ASSERT_TRUE(switches.
AreValid(std::cout));
105 EXPECT_EQ(options.entry_point_name,
"my_prefix_test_fragment_main");
108TEST(SwitchesTest, CommandLinePathUtf8) {
109 std::u16string filename = u
"test\u1234";
112 ASSERT_TRUE(switches.
AreValid(std::cout));
std::string entry_point_prefix
SourceLanguage source_language
std::string shader_bundle
SourceOptions CreateSourceOptions(std::optional< TargetPlatform > target_platform=std::nullopt) const
bool AreValid(std::ostream &explain) 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.