From d5bbba8120a86809d7709ce6b2c4e0aecef812a1 Mon Sep 17 00:00:00 2001 From: Lukas Ruzicka Date: Thu, 28 Nov 2024 18:13:03 +0100 Subject: [PATCH] Save progress, but needs fixing. --- tests/os_release.pm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/os_release.pm b/tests/os_release.pm index 6922b9bb..10042201 100644 --- a/tests/os_release.pm +++ b/tests/os_release.pm @@ -18,7 +18,11 @@ sub json_to_hash { # This will convert a Json string into a valid # Perl hash for further processing. my $json = shift; - my $hash = JSON::PP->new->utf8->decode($json); + my $hash; + eval { + my $hash = JSON::PP->new->utf8->decode($json); + }; + die("Failed to parse JSON: $@") if ($@); return $hash; } @@ -65,7 +69,11 @@ sub get_schedule_eol { # The format of the json is quite complicated, so we need to do # quite a lot of magic to arrive at the correct date, so let's # hope the format stays the same in the future. - foreach my $task (@{$json->{tasks}->[0]->{tasks}->[0]->{tasks}}) { + # FIXME parsing the tasks + my $tasks = $json->{tasks}[0]{tasks}[0]{tasks}; + my $eol; + + foreach my $task (@$tasks) { if ($task->{name} && $task->{name} =~ /End of Life/) { $eol = $task->{end}; last; @@ -80,8 +88,8 @@ sub get_current_date { # which we need to see if the EOL is correctly set in the future. my $time = localtime; my $dates = {}; - $dates->{date} = $time->strftime('%Y-%m-%d'); - $dates->{epoch} = date_to_epoch($dates{date}); + $dates->{'date'} = $time->strftime('%Y-%m-%d'); + $dates->{'epoch'} = date_to_epoch($dates->{'date'}); return $dates; } @@ -141,7 +149,7 @@ sub check_eols_match { $overall = 0 if ($rcode != 1); my $return_codes = { 0 => "No EOL dates do match:\n\tos-release: $tested\n\tBodhi: $bodhi\n\tSchedule: $schedule", - 2 => "The os-release doesn't match Bodhi or Schedule, but they match each other:\n\tos-release: $tested\n\tBodhi: $bodhi\n\tSchedule: $schedule" + 2 => "The os-release doesn't match Bodhi or Schedule, but they match each other:\n\tos-release: $tested\n\tBodhi: $bodhi\n\tSchedule: $schedule", 3 => "The os-release file matches Bodhi but Schedule differs:\n\tos-release: $tested\n\tBodhi: $bodhi\n\tSchedule: $schedule", 4 => "The os-release file matches Schedule but Bodhi differs:\n\tos-release: $tested\n\tBodhi: $bodhi\n\tSchedule: $schedule", 1 => "All EOL dates match:\n\tos-release: $tested\n\tBodhi: $bodhi\n\tSchedule: $schedule"