[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/rbm][main] 3 commits: Bug 40051: Fix test after change of default value for compress_tar



Title: GitLab

boklm pushed to branch main at The Tor Project / Applications / RBM

Commits:

  • 27a89ca5
    by Nicolas Vigier at 2023-05-08T18:06:36+02:00
    Bug 40051: Fix test after change of default value for compress_tar
    
    Default value for compress_tar was changed in
    a91d4653cb5f66d86fd4d306c564161acfd6fa79.
    
  • 60c5aff5
    by Nicolas Vigier at 2023-05-17T08:03:40+02:00
    Bug 40018: Add target_replace option in input_files
    
  • 37c204c3
    by Nicolas Vigier at 2023-05-17T08:03:43+02:00
    Bug 40052: Allow setting sha256sum as norec
    

6 changed files:

Changes:

  • doc/rbm_input_files.asc
    ... ... @@ -92,6 +92,12 @@ target_prepend::
    92 92
             The same as +target+, but instead of replacing the current targets,
    
    93 93
             the new targets are prepended.
    
    94 94
     
    
    95
    +target_replace::
    
    96
    +        A hash table containing targets to replace. The key is a regular
    
    97
    +        _expression_, and the value the replacement. See +perlre+ manual
    
    98
    +        page for details about the syntax. Note that referencing capture
    
    99
    +        groups in the replacement is currently not supported.
    
    100
    +
    
    95 101
     enable::
    
    96 102
             The files are enabled by default. If this option is set to
    
    97 103
             0, then the file is ignored.
    

  • lib/RBM.pm
    ... ... @@ -779,7 +779,7 @@ sub input_file_need_dl {
    779 779
         my ($input_file, $t, $fname, $action) = @_;
    
    780 780
         return undef if $action eq 'getfpaths';
    
    781 781
         if ($fname
    
    782
    -        && $input_file->{sha256sum}
    
    782
    +        && ($input_file->{sha256sum} || $input_file->{norec}{sha256sum})
    
    783 783
             && $t->('sha256sum') ne sha256file($fname)) {
    
    784 784
             sha256file($fname, { remove_cache => 1 });
    
    785 785
             $fname = undef;
    
    ... ... @@ -787,6 +787,7 @@ sub input_file_need_dl {
    787 787
         if ($action eq 'input_files_id') {
    
    788 788
             return undef if $input_file->{input_file_id};
    
    789 789
             return undef if $input_file->{sha256sum};
    
    790
    +        return undef if $input_file->{norec}{sha256sum};
    
    790 791
             return undef if $input_file->{exec};
    
    791 792
             return undef if $fname;
    
    792 793
             return 1 if $input_file->{URL};
    
    ... ... @@ -810,7 +811,9 @@ sub input_file_id {
    810 811
         my ($input_file, $t, $fname, $filename) = @_;
    
    811 812
         return $t->('input_file_id') if $input_file->{input_file_id};
    
    812 813
         return $input_file->{project} . ':' . $filename if $input_file->{project};
    
    813
    -    return $filename . ':' . $t->('sha256sum') if $input_file->{sha256sum};
    
    814
    +    if ($input_file->{sha256sum} || $input_file->{norec}{sha256sum}) {
    
    815
    +        return $filename . ':' . $t->('sha256sum');
    
    816
    +    }
    
    814 817
         my $opts = { norec => { output_dir => '/out', getting_id => 1, }};
    
    815 818
         return $filename . ':' . sha256_hex($t->('exec', $opts))
    
    816 819
                     if $input_file->{exec};
    
    ... ... @@ -898,13 +901,18 @@ sub input_files {
    898 901
                 next;
    
    899 902
             }
    
    900 903
             if ($input_file->{target} || $input_file->{target_append}
    
    901
    -                                  || $input_file->{target_prepend}) {
    
    904
    +                                  || $input_file->{target_prepend}
    
    905
    +                                  || $input_file->{target_replace}) {
    
    902 906
                 $input_file = { %$input_file };
    
    903 907
                 foreach my $t (qw/target target_append target_prepend/) {
    
    904 908
                     if ($input_file->{$t} && ref $input_file->{$t} ne 'ARRAY') {
    
    905 909
                         exit_error("$t should be an ARRAY:\n" . pp($input_file));
    
    906 910
                     }
    
    907 911
                 }
    
    912
    +            if ($input_file->{target_replace} &&
    
    913
    +                ref $input_file->{target_replace} ne 'HASH') {
    
    914
    +                exit_error("target_replace should be a HASH\n" . pp($input_file));
    
    915
    +            }
    
    908 916
                 if ($input_file->{target}) {
    
    909 917
                     $input_file->{target} = process_template_opt($project,
    
    910 918
                                                 $input_file->{target}, $options);
    
    ... ... @@ -923,6 +931,14 @@ sub input_files {
    923 931
                                                    $input_file->{target_append},
    
    924 932
                                                    $options) } ];
    
    925 933
                 }
    
    934
    +            if ($input_file->{target_replace}) {
    
    935
    +                foreach my $pattern (keys %{$input_file->{target_replace}}) {
    
    936
    +                    my $subst = $input_file->{target_replace}{$pattern};
    
    937
    +                    $input_file->{target} = [
    
    938
    +                        map { s/$pattern/$subst/r } @{$input_file->{target}}
    
    939
    +                    ];
    
    940
    +                }
    
    941
    +            }
    
    926 942
             }
    
    927 943
             if ($action eq 'getfnames') {
    
    928 944
                 my $getfnames_name;
    

  • test.pl
    1 1
     #!/usr/bin/perl -w
    
    2 2
     use strict;
    
    3 3
     use Path::Tiny;
    
    4
    -use Test::More tests => 40;
    
    4
    +use Test::More tests => 41;
    
    5 5
     use lib 'lib/';
    
    6 6
     
    
    7 7
     sub set_target {
    
    ... ... @@ -220,6 +220,14 @@ my @tests = (
    220 220
                 'out/r3' => "1 - build\n2 - build\n3 - build\n",
    
    221 221
             },
    
    222 222
         },
    
    223
    +    {
    
    224
    +        name => 'multi-steps build with changing targets',
    
    225
    +        target => [ 'target_a' ],
    
    226
    +        build => [ 'change-targets', 'build', { pkg_type => 'build' } ],
    
    227
    +        files => {
    
    228
    +          'out/change-targets.txt' => "no\nz\ntta\n",
    
    229
    +        },
    
    230
    +    },
    
    223 231
         {
    
    224 232
             name => 'build project in a module',
    
    225 233
             target => [],
    

  • test/projects/change-targets/config
    1
    +# vim: filetype=yaml sw=2
    
    2
    +
    
    3
    +targets:
    
    4
    +  tt_a:
    
    5
    +    option_a: 'tta'
    
    6
    +
    
    7
    +
    
    8
    +steps:
    
    9
    +
    
    10
    +  build:
    
    11
    +    filename: change-targets.txt
    
    12
    +    build: |
    
    13
    +      #!/bin/sh
    
    14
    +      cat preptarget.txt replacetarget-1.txt replacetarget-2.txt > [% dest_dir %]/[% c('filename') %]
    
    15
    +    input_files:
    
    16
    +      - name: preptarget
    
    17
    +        refresh_input: 1
    
    18
    +        project: change-targets
    
    19
    +        pkg_type: preptarget
    
    20
    +        target_prepend:
    
    21
    +          - target_b
    
    22
    +      - name: replacetarget
    
    23
    +        r: 1
    
    24
    +        refresh_input: 1
    
    25
    +        project: change-targets
    
    26
    +        pkg_type: replacetarget
    
    27
    +        target_replace:
    
    28
    +          '^target_a$': target_z
    
    29
    +      - name: replacetarget
    
    30
    +        r: 2
    
    31
    +        refresh_input: 1
    
    32
    +        project: change-targets
    
    33
    +        pkg_type: replacetarget
    
    34
    +        target_replace:
    
    35
    +          '^target_.*$': 'tt_a'
    
    36
    +
    
    37
    +  preptarget:
    
    38
    +    filename: preptarget.txt
    
    39
    +    preptarget: |
    
    40
    +      #!/bin/sh
    
    41
    +      echo [% c('option_a') %] > [% dest_dir %]/[% c('filename') %]
    
    42
    +    input_files: []
    
    43
    +
    
    44
    +  replacetarget:
    
    45
    +    filename: 'replacetarget-[% c("r") %].txt'
    
    46
    +    replacetarget: |
    
    47
    +      #!/bin/sh
    
    48
    +      echo [% c('option_a') %] > [% dest_dir %]/[% c('filename') %]
    
    49
    +    input_files: []

  • test/projects/mozmill-automation/config
    1 1
     version: '[% c("abbrev") %]'
    
    2 2
     hg_url: https://hg.mozilla.org/qa/mozmill-automation/
    
    3 3
     hg_hash: bbad7215c713
    
    4
    +compress_tar: ''
    
    4 5
     t: '[% sha256(exec("cat testrun_remote.py")) %]'
    
    5 6
     build: |
    
    6 7
       #!/bin/sh
    

  • test/rbm.conf
    ... ... @@ -15,6 +15,8 @@ targets:
    15 15
         - target_c
    
    16 16
         - target_a
    
    17 17
         - target_b
    
    18
    +  target_z:
    
    19
    +    option_a: z
    
    18 20
     steps:
    
    19 21
       rpm:
    
    20 22
         option_rpm: 1
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits