зеркало из https://github.com/mozilla/pjs.git
Synch with r2389
This commit is contained in:
Родитель
950bacc5b1
Коммит
02902a700b
|
@ -88,13 +88,26 @@ sub add_tag()
|
|||
push @{$self->tags}, $tag;
|
||||
}
|
||||
|
||||
# Temporary copy of Bugzilla::Testopia::TestPlan->get_available_products(). Remove when bug 220134 is fixed.
|
||||
sub TEMP_get_product_components {
|
||||
my ($product_id) = @_;
|
||||
my $dbh = Bugzilla->dbh;
|
||||
my $ref = $dbh->selectall_arrayref(
|
||||
"SELECT DISTINCT id, name
|
||||
FROM components
|
||||
WHERE product_id IN($product_id)
|
||||
ORDER BY name",
|
||||
{'Slice'=>{}});
|
||||
|
||||
return $ref;
|
||||
}
|
||||
sub add_component()
|
||||
{
|
||||
my ($self,$component,$component_product) = @_;
|
||||
my $component_id = "";
|
||||
my $product_id = "";
|
||||
|
||||
return "Component $component needs to provide a product" if ( $component_product eq "" );
|
||||
return "Component $component needs to provide a product." if ( $component_product eq "" );
|
||||
|
||||
# Find the product identifier.
|
||||
my $products_ref = Bugzilla::Testopia::TestPlan->get_available_products();
|
||||
|
@ -106,10 +119,10 @@ sub add_component()
|
|||
last;
|
||||
}
|
||||
}
|
||||
return "Cannot find product $component_product for component $component" if ( $product_id eq "" );
|
||||
return "Cannot find product $component_product for component $component." if ( $product_id eq "" );
|
||||
|
||||
# Find the component identifier for the product's componet
|
||||
my $components_ref = Bugzilla::Testopia::TestPlan->get_product_components($product_id);
|
||||
my $components_ref = TEMP_get_product_components($product_id);
|
||||
foreach my $product_component ( @$components_ref )
|
||||
{
|
||||
if ( $component eq $product_component->{name} )
|
||||
|
@ -118,7 +131,7 @@ sub add_component()
|
|||
last;
|
||||
}
|
||||
}
|
||||
return "Product $component_product does not have a component named $component" if ( $component_id eq "" );
|
||||
return "Product $component_product does not have a component named $component." if ( $component_id eq "" );
|
||||
|
||||
# Save the component identifier for this Test Case.
|
||||
push @{$self->component_ids}, $component_id;
|
||||
|
|
|
@ -99,6 +99,23 @@ sub map_TCDB_users
|
|||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Peek ahead one character in the file.
|
||||
#
|
||||
sub peek(*)
|
||||
{
|
||||
my $fh = shift;
|
||||
|
||||
# Get current position in file.
|
||||
my $position = tell $fh;
|
||||
# Read next character.
|
||||
read(CSVINPUT, my $next_char, 1);
|
||||
# Restore position in file.
|
||||
seek(CSVINPUT,$position,0);
|
||||
|
||||
return $next_char;
|
||||
}
|
||||
|
||||
#
|
||||
# Print the fields.
|
||||
#
|
||||
|
@ -180,7 +197,6 @@ sub remove_field_list
|
|||
s/\351/è/g; # small letter e with grave
|
||||
s/\364/ô/g; # small letter o with circumflex
|
||||
|
||||
|
||||
$line_count += 1;
|
||||
if ( $line_count == 1 )
|
||||
{
|
||||
|
@ -212,14 +228,10 @@ sub remove_field_list
|
|||
next;
|
||||
}
|
||||
|
||||
# Two TCDB CSV options that are not handled correctly:
|
||||
# 1) A unescaped double quote in a field that appears at the end of the line is assumed
|
||||
# to be the end of the field although it is suppose to be part of the field. This
|
||||
# could probably be detected by reading the next line and seeing if it begins with a
|
||||
# double quote. If it does then the double quote was the end of the field.
|
||||
# 2) If a field contains some thing like:
|
||||
# '2. Click "Roles and Tasks " , "Storage" , click "Volumes" and' the "," will be
|
||||
# seen as field seperator and not as part of the field.
|
||||
# TCDB CSV options that are not handled correctly:
|
||||
# If a field contains some thing like:
|
||||
# '2. Click "Roles and Tasks " , "Storage" , click "Volumes" and''
|
||||
# the "," will be seen as field seperator and not as part of the field.
|
||||
|
||||
# Add the current line onto the line to parse.
|
||||
$parse_line .= $_;
|
||||
|
@ -319,8 +331,11 @@ sub remove_field_list
|
|||
$index++;
|
||||
}
|
||||
|
||||
my $next_char = peek(*CSVINPUT);
|
||||
my $looks_like_end_of_csv_line = $next_char eq "\"" || $next_char eq "";
|
||||
|
||||
# Do we have all the fields we need?
|
||||
if ( ($#fields == ($number_of_fields-1)) && (! $in_quote_field) )
|
||||
if ( ($#fields == ($number_of_fields-1)) && (! $in_quote_field) && $looks_like_end_of_csv_line )
|
||||
{
|
||||
print_tcdb_fields(\*CSVWORK,\@fields,$testcasenamefield);
|
||||
$parse_line = "";
|
||||
|
@ -328,7 +343,7 @@ sub remove_field_list
|
|||
}
|
||||
# Is this the TCDB export error? We have one less field than needed and the next line begins with a
|
||||
# double quote.
|
||||
elsif ( ($#fields == ($number_of_fields-2)) && (! $in_quote_field ) )
|
||||
elsif ( ($#fields == ($number_of_fields-2)) && (! $in_quote_field ) && $looks_like_end_of_csv_line )
|
||||
{
|
||||
if ( $_ =~ m/^"/ )
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче