-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Travis check for YAML_TEST_DATA in yaml schedule
- Loading branch information
1 parent
5156f2f
commit b31608f
Showing
5 changed files
with
85 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,53 @@ | ||
#!/bin/sh -e | ||
|
||
FILES="${@}" | ||
success=1 | ||
for FILE in $FILES; do | ||
if ! [ -f "$FILE" ]; then | ||
echo "Error! $FILE does not exist." | ||
success=0 | ||
elif ! [ -s "$FILE" ]; then | ||
echo "Warning! The test_data file $FILE is empty." | ||
fi | ||
done | ||
[ $success = 1 ] && echo "SUCCESS" && exit 0 | ||
exit 1 | ||
#!/usr/bin/env perl | ||
|
||
# The script verifies if test data files included in yaml schedule exist in the repo. | ||
|
||
use strict; | ||
use warnings; | ||
use YAML::Tiny; | ||
use File::Basename; | ||
use Data::Dumper; | ||
|
||
=head2 get_testdata_filename | ||
get_testdata_paths($schedule_file_path); | ||
Returns yaml test data file name(s) with path, in case yaml schedule includes any, either via $include tag or YAML_TEST_DATA variable. | ||
=cut | ||
sub get_data_files { | ||
my ($schedule_file_path) = @_; | ||
my $schedule = YAML::Tiny::LoadFile($schedule_file_path); | ||
my $include_tag = '$include'; | ||
my @filename_list; | ||
my $test_data = $schedule->{test_data}; | ||
my @filenames; | ||
if (ref($test_data->{$include_tag}) eq 'ARRAY') { | ||
@filenames = @{$test_data->{$include_tag}}; | ||
} | ||
else { | ||
@filenames = $test_data->{$include_tag}; | ||
} | ||
if ($test_data && @filenames) { | ||
foreach my $item (@filenames) { | ||
push(@filename_list, $item); | ||
} | ||
} | ||
my $datafile = $schedule->{vars}->{YAML_TEST_DATA}; | ||
push(@filename_list, $datafile) if $datafile; | ||
return @filename_list; | ||
} | ||
|
||
my $success = 1; | ||
foreach my $schedule_file (@ARGV) { | ||
my @data_filenames = get_data_files($schedule_file); | ||
if (@data_filenames) { | ||
foreach my $item (@data_filenames) { | ||
unless (-f $item) { | ||
$success = 0; | ||
print "Failure: Test data file $item used in $schedule_file does not exist in the repo.\n"; | ||
} | ||
} | ||
} | ||
} | ||
$success == 1 ? exit 0 : exit 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh -e | ||
|
||
FILES="${@}" | ||
success=1 | ||
for FILE in $FILES; do | ||
if [ -f "$FILE" ]; then | ||
# if file exists it means it was renamed, and then original file name is retrieved by git log | ||
FILE=$(git log --follow -p $FILE | grep 'rename from test' | awk '{print $3}') | ||
fi | ||
if [ -n "$(echo $FILE | grep '\.pm$')" ]; then | ||
# In case file is a module, module name appears in scheduling files excluding 'tests/' and file extension | ||
filename=$(echo $FILE | cut -f 2- -d '/' | cut -f 1 -d '.') | ||
target_paths='schedule/ products/*/main.pm lib/main_common.pm' | ||
# In case file is test_data yaml file, the filename given is the same as in schedule files | ||
elif [ -n "$(echo $FILE | grep '\.ya\?ml$')" ]; then | ||
filename="$FILE" | ||
target_paths='schedule/' | ||
fi | ||
if MATCHED_SCHEDULE_FILES="$(grep --recursive --ignore-case --files-with-matches "${filename}\b" $target_paths)" | ||
then | ||
echo "\"$filename\" was removed or renamed, but it is still used in: \ | ||
\n$MATCHED_SCHEDULE_FILES\n" | ||
success=0 | ||
fi | ||
done | ||
[ $success = 1 ] && echo "SUCCESS" && exit 0 | ||
exit 1 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.