Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
5cc1d5ca
Kaydet (Commit)
5cc1d5ca
authored
Eyl 30, 2012
tarafından
Tim Retout
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
installer::profiles: Test and rewrite sorting_profile
Change-Id: Ie3c9bddcb4760d2fe2195c1ca0de7520e57d705f
üst
665785c0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
26 deletions
+79
-26
profiles.pm
solenv/bin/modules/installer/profiles.pm
+19
-26
installer-profiles.t
solenv/bin/modules/t/installer-profiles.t
+60
-0
No files found.
solenv/bin/modules/installer/profiles.pm
Dosyayı görüntüle @
5cc1d5ca
...
...
@@ -42,40 +42,33 @@ use installer::systemactions;
# Sorting the content of a profile
#######################################################
sub
sorting_profile
{
sub
sorting_profile
{
my
(
$profilesref
)
=
@_
;
my
@
profile
=
()
;
my
@definedsections
=
()
;
my
@
sections
;
my
%
section_content
;
for
(
my
$i
=
0
;
$i
<=
$#
{
$profilesref
};
$i
++
)
{
for
(
my
$i
=
0
;
$i
<
@
{
$profilesref
};
$i
++
)
{
my
$line
=
$
{
$profilesref
}[
$i
];
if
(
$line
=~
/^\s*(\[.*\])\s*$/
)
# this is a section (every second line)
{
my
$section
=
$1
;
# Skip unless this is a section (every second line)
next
unless
(
$line
=~
/^\s*(\[.*\])\s*$/
);
if
(
!
grep
{
$_
eq
$section
}
@definedsections
)
{
my
$sectionline
=
$section
.
"\n"
;
push
(
@definedsections
,
$section
);
push
(
@profile
,
$sectionline
);
my
$section
=
$1
;
my
$next_line
=
$
{
$profilesref
}[
$i
+
1
];
for
(
my
$j
=
0
;
$j
<=
$#
{
$profilesref
};
$j
++
)
{
my
$oneline
=
$
{
$profilesref
}[
$j
];
installer::remover::
remove_leading_and_ending_whitespaces
(
\
$oneline
);
if
(
$oneline
eq
$section
)
{
my
$nextline
=
$
{
$profilesref
}[
$j
+
1
];
push
(
@profile
,
$nextline
);
}
}
}
if
(
!
exists
$section_content
{
$section
}
)
{
push
@sections
,
$section
;
}
push
@
{
$section_content
{
$section
}
},
$next_line
;
}
my
@profile
;
for
my
$section
(
@sections
)
{
push
@profile
,
"$section\n"
;
push
@profile
,
@
{
$section_content
{
$section
}
};
}
return
\
@profile
;
...
...
solenv/bin/modules/t/installer-profiles.t
0 → 100644
Dosyayı görüntüle @
5cc1d5ca
# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# Major Contributor(s):
# [ Copyright (C) 2012 Tim Retout <tim@retout.co.uk> (initial developer) ]
#
# All Rights Reserved.
#
# For minor contributions see the git repository.
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.
use
strict
;
use
warnings
;
use
Test::
More
;
use
lib
'.'
;
use
installer::
profiles
;
my
@input
=
map
{
"$_\n"
}
split
"\n"
,
<<'END';
[foo]
1
NOT SEEN
[bar]
3
[foo]
2
[bar]
4
END
my
@expected
=
map
{
"$_\n"
}
split
"\n"
,
<<'END';
[foo]
1
2
[bar]
3
4
END
my
$result
=
installer::profiles::
sorting_profile
(
\
@input
);
is_deeply
(
$result
,
\
@expected
);
done_testing
();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment