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

boklm (@boklm) git at gitlab.torproject.org
Wed May 17 06:05:58 UTC 2023



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:

- doc/rbm_input_files.asc
- lib/RBM.pm
- test.pl
- + test/projects/change-targets/config
- test/projects/mozmill-automation/config
- test/rbm.conf


Changes:

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


=====================================
lib/RBM.pm
=====================================
@@ -779,7 +779,7 @@ sub input_file_need_dl {
     my ($input_file, $t, $fname, $action) = @_;
     return undef if $action eq 'getfpaths';
     if ($fname
-        && $input_file->{sha256sum}
+        && ($input_file->{sha256sum} || $input_file->{norec}{sha256sum})
         && $t->('sha256sum') ne sha256file($fname)) {
         sha256file($fname, { remove_cache => 1 });
         $fname = undef;
@@ -787,6 +787,7 @@ sub input_file_need_dl {
     if ($action eq 'input_files_id') {
         return undef if $input_file->{input_file_id};
         return undef if $input_file->{sha256sum};
+        return undef if $input_file->{norec}{sha256sum};
         return undef if $input_file->{exec};
         return undef if $fname;
         return 1 if $input_file->{URL};
@@ -810,7 +811,9 @@ sub input_file_id {
     my ($input_file, $t, $fname, $filename) = @_;
     return $t->('input_file_id') if $input_file->{input_file_id};
     return $input_file->{project} . ':' . $filename if $input_file->{project};
-    return $filename . ':' . $t->('sha256sum') if $input_file->{sha256sum};
+    if ($input_file->{sha256sum} || $input_file->{norec}{sha256sum}) {
+        return $filename . ':' . $t->('sha256sum');
+    }
     my $opts = { norec => { output_dir => '/out', getting_id => 1, }};
     return $filename . ':' . sha256_hex($t->('exec', $opts))
                 if $input_file->{exec};
@@ -898,13 +901,18 @@ sub input_files {
             next;
         }
         if ($input_file->{target} || $input_file->{target_append}
-                                  || $input_file->{target_prepend}) {
+                                  || $input_file->{target_prepend}
+                                  || $input_file->{target_replace}) {
             $input_file = { %$input_file };
             foreach my $t (qw/target target_append target_prepend/) {
                 if ($input_file->{$t} && ref $input_file->{$t} ne 'ARRAY') {
                     exit_error("$t should be an ARRAY:\n" . pp($input_file));
                 }
             }
+            if ($input_file->{target_replace} &&
+                ref $input_file->{target_replace} ne 'HASH') {
+                exit_error("target_replace should be a HASH\n" . pp($input_file));
+            }
             if ($input_file->{target}) {
                 $input_file->{target} = process_template_opt($project,
                                             $input_file->{target}, $options);
@@ -923,6 +931,14 @@ sub input_files {
                                                $input_file->{target_append},
                                                $options) } ];
             }
+            if ($input_file->{target_replace}) {
+                foreach my $pattern (keys %{$input_file->{target_replace}}) {
+                    my $subst = $input_file->{target_replace}{$pattern};
+                    $input_file->{target} = [
+                        map { s/$pattern/$subst/r } @{$input_file->{target}}
+                    ];
+                }
+            }
         }
         if ($action eq 'getfnames') {
             my $getfnames_name;


=====================================
test.pl
=====================================
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 use strict;
 use Path::Tiny;
-use Test::More tests => 40;
+use Test::More tests => 41;
 use lib 'lib/';
 
 sub set_target {
@@ -220,6 +220,14 @@ my @tests = (
             'out/r3' => "1 - build\n2 - build\n3 - build\n",
         },
     },
+    {
+        name => 'multi-steps build with changing targets',
+        target => [ 'target_a' ],
+        build => [ 'change-targets', 'build', { pkg_type => 'build' } ],
+        files => {
+          'out/change-targets.txt' => "no\nz\ntta\n",
+        },
+    },
     {
         name => 'build project in a module',
         target => [],


=====================================
test/projects/change-targets/config
=====================================
@@ -0,0 +1,49 @@
+# vim: filetype=yaml sw=2
+
+targets:
+  tt_a:
+    option_a: 'tta'
+
+
+steps:
+
+  build:
+    filename: change-targets.txt
+    build: |
+      #!/bin/sh
+      cat preptarget.txt replacetarget-1.txt replacetarget-2.txt > [% dest_dir %]/[% c('filename') %]
+    input_files:
+      - name: preptarget
+        refresh_input: 1
+        project: change-targets
+        pkg_type: preptarget
+        target_prepend:
+          - target_b
+      - name: replacetarget
+        r: 1
+        refresh_input: 1
+        project: change-targets
+        pkg_type: replacetarget
+        target_replace:
+          '^target_a$': target_z
+      - name: replacetarget
+        r: 2
+        refresh_input: 1
+        project: change-targets
+        pkg_type: replacetarget
+        target_replace:
+          '^target_.*$': 'tt_a'
+
+  preptarget:
+    filename: preptarget.txt
+    preptarget: |
+      #!/bin/sh
+      echo [% c('option_a') %] > [% dest_dir %]/[% c('filename') %]
+    input_files: []
+
+  replacetarget:
+    filename: 'replacetarget-[% c("r") %].txt'
+    replacetarget: |
+      #!/bin/sh
+      echo [% c('option_a') %] > [% dest_dir %]/[% c('filename') %]
+    input_files: []


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


=====================================
test/rbm.conf
=====================================
@@ -15,6 +15,8 @@ targets:
     - target_c
     - target_a
     - target_b
+  target_z:
+    option_a: z
 steps:
   rpm:
     option_rpm: 1



View it on GitLab: https://gitlab.torproject.org/tpo/applications/rbm/-/compare/bf35e085111a6ffce0c8f5eac49f9ae70ed377fc...37c204c31a8457d364dfdc13c7e84e13d1671680

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/rbm/-/compare/bf35e085111a6ffce0c8f5eac49f9ae70ed377fc...37c204c31a8457d364dfdc13c7e84e13d1671680
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20230517/a6a7c0ef/attachment-0001.htm>


More information about the tbb-commits mailing list