mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-21 21:46:22 +00:00
validate: Fix parsing validate tests files with vars on windows
And ensure that we escape windows path in variables Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-devtools/-/merge_requests/190>
This commit is contained in:
parent
884c45ff3e
commit
dcb719d6cc
1 changed files with 44 additions and 12 deletions
|
@ -630,14 +630,16 @@ _file_get_structures (GFile * file, gchar ** err)
|
||||||
}
|
}
|
||||||
|
|
||||||
next = *(tmp + 1);
|
next = *(tmp + 1);
|
||||||
if (next && next == '\n'
|
if (next && (next == '\n' || next == '\r')
|
||||||
&& strchr (GST_STRUCT_LINE_CONTINUATION_CHARS, *tmp)) {
|
&& strchr (GST_STRUCT_LINE_CONTINUATION_CHARS, *tmp)) {
|
||||||
g_string_append_c (debug_line, *tmp);
|
g_string_append_c (debug_line, *tmp);
|
||||||
g_string_append_printf (debug_line, "\n %4d | ", lineno + 1);
|
g_string_append_printf (debug_line, "\n %4d | ", lineno + 1);
|
||||||
if (*tmp != '\\')
|
if (*tmp != '\\')
|
||||||
g_string_append_c (l, *tmp);
|
g_string_append_c (l, *tmp);
|
||||||
|
|
||||||
tmp += 2;
|
tmp++;
|
||||||
|
while (*tmp == '\n' || *tmp == '\r')
|
||||||
|
tmp++;
|
||||||
lineno++;
|
lineno++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1107,7 +1109,8 @@ gst_validate_replace_variables_in_string (GstStructure * local_vars,
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
tmpstring = string;
|
tmpstring = string;
|
||||||
string =
|
string =
|
||||||
g_regex_replace (replace_regex, string, -1, 0, var_value, 0, NULL);
|
g_regex_replace_literal (replace_regex, string, -1, 0, var_value, 0,
|
||||||
|
NULL);
|
||||||
|
|
||||||
GST_INFO ("Setting variable %s to %s", varname, var_value);
|
GST_INFO ("Setting variable %s to %s", varname, var_value);
|
||||||
g_free (tmpstring);
|
g_free (tmpstring);
|
||||||
|
@ -1130,6 +1133,10 @@ _structure_set_variables (GQuark field_id, GValue * value,
|
||||||
{
|
{
|
||||||
gchar *str;
|
gchar *str;
|
||||||
|
|
||||||
|
if (field_id == filename_quark || field_id == debug_quark
|
||||||
|
|| field_id == debug_quark)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
if (GST_VALUE_HOLDS_LIST (value)) {
|
if (GST_VALUE_HOLDS_LIST (value)) {
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
|
@ -1169,6 +1176,22 @@ _set_vars_func (GQuark field_id, const GValue * value, GstStructure * vars)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
structure_set_string_literal (GstStructure * structure, const gchar * fieldname,
|
||||||
|
const gchar * str)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
GString *escaped = g_string_sized_new (strlen (str) + 1);
|
||||||
|
|
||||||
|
for (i = 0; str[i] != '\0'; i++) {
|
||||||
|
g_string_append_c (escaped, str[i]);
|
||||||
|
if (str[i] == '\\')
|
||||||
|
g_string_append_c (escaped, '\\');
|
||||||
|
}
|
||||||
|
gst_structure_set (structure, fieldname, G_TYPE_STRING, escaped->str, NULL);
|
||||||
|
g_string_free (escaped, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_validate_set_globals (GstStructure * structure)
|
gst_validate_set_globals (GstStructure * structure)
|
||||||
{
|
{
|
||||||
|
@ -1258,10 +1281,15 @@ gst_validate_structure_set_variables_from_struct_file (GstStructure * vars,
|
||||||
gchar *t, *config_name_dir;
|
gchar *t, *config_name_dir;
|
||||||
gchar *validateflow, *expectations_dir, *actual_result_dir;
|
gchar *validateflow, *expectations_dir, *actual_result_dir;
|
||||||
const gchar *logdir;
|
const gchar *logdir;
|
||||||
|
gboolean local = ! !vars;
|
||||||
|
|
||||||
if (!struct_file)
|
if (!struct_file)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
vars = global_vars;
|
||||||
|
|
||||||
config_dir = g_path_get_dirname (struct_file);
|
config_dir = g_path_get_dirname (struct_file);
|
||||||
config_fname = g_path_get_basename (struct_file);
|
config_fname = g_path_get_basename (struct_file);
|
||||||
config_name = g_strdup (config_fname);
|
config_name = g_strdup (config_fname);
|
||||||
|
@ -1278,19 +1306,23 @@ gst_validate_structure_set_variables_from_struct_file (GstStructure * vars,
|
||||||
}
|
}
|
||||||
|
|
||||||
expectations_dir =
|
expectations_dir =
|
||||||
g_build_filename (config_dir, config_name, "flow-expectations", NULL);
|
g_build_path ("/", config_dir, config_name, "flow-expectations", NULL);
|
||||||
actual_result_dir = g_build_filename (logdir, config_name_dir, NULL);
|
actual_result_dir = g_build_path ("/", logdir, config_name_dir, NULL);
|
||||||
validateflow =
|
validateflow =
|
||||||
g_strdup_printf
|
g_strdup_printf
|
||||||
("validateflow, expectations-dir=\"%s\", actual-results-dir=\"%s\"",
|
("validateflow, expectations-dir=\"%s\", actual-results-dir=\"%s\"",
|
||||||
expectations_dir, actual_result_dir);
|
expectations_dir, actual_result_dir);
|
||||||
gst_structure_set (!vars ? global_vars : vars,
|
|
||||||
"gst_api_version", G_TYPE_STRING, GST_API_VERSION,
|
structure_set_string_literal (vars, "gst_api_version", GST_API_VERSION);
|
||||||
!vars ? "test_dir" : "CONFIG_DIR", G_TYPE_STRING, config_dir,
|
structure_set_string_literal (vars, !local ? "test_dir" : "CONFIG_DIR",
|
||||||
!vars ? "test_name" : "CONFIG_NAME", G_TYPE_STRING, config_name,
|
config_dir);
|
||||||
!vars ? "test_name_dir" : "CONFIG_NAME_DIR", G_TYPE_STRING,
|
structure_set_string_literal (vars, !local ? "test_name" : "CONFIG_NAME",
|
||||||
config_name_dir, !vars ? "test_path" : "CONFIG_PATH", G_TYPE_STRING,
|
config_name);
|
||||||
struct_file, "validateflow", G_TYPE_STRING, validateflow, NULL);
|
structure_set_string_literal (vars,
|
||||||
|
!local ? "test_name_dir" : "CONFIG_NAME_DIR", config_name_dir);
|
||||||
|
structure_set_string_literal (vars, !local ? "test_path" : "CONFIG_PATH",
|
||||||
|
struct_file);
|
||||||
|
structure_set_string_literal (vars, "validateflow", validateflow);
|
||||||
|
|
||||||
g_free (config_dir);
|
g_free (config_dir);
|
||||||
g_free (config_name_dir);
|
g_free (config_name_dir);
|
||||||
|
|
Loading…
Reference in a new issue