[elbe-devel] [PATCH 04/25] elbe: implement a hidden --test-commands parameter

Manuel Traut manuel.traut at linutronix.de
Fri Dec 8 16:44:33 CET 2017


On Tue, Dec 05, 2017 at 05:41:59PM +0100, Torben Hohn wrote:
> On Fri, Dec 01, 2017 at 04:51:01PM +0100, Manuel Traut wrote:
> > it can be used by test-sytems to identify if all commands are runnable,
> > e.g. can resolve their imports.
> > 
> > Signed-off-by: Manuel Traut <manut at linutronix.de>
> > ---
> >  elbe | 10 +++++++++-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> > 
> > diff --git a/elbe b/elbe
> > index 269b1920..48056013 100755
> > --- a/elbe
> > +++ b/elbe
> > @@ -18,13 +18,13 @@
> >  # You should have received a copy of the GNU General Public License
> >  # along with ELBE.  If not, see <http://www.gnu.org/licenses/>.
> >  
> > +import os
> >  import sys
> >  
> >  import elbepack.commands
> >  from elbepack.version import elbe_version, running_os
> >  from elbepack.directories import init_directories, get_cmdlist
> >  
> > -
> >  def usage():
> >      print 'elbe v' + elbe_version
> >      print 'need a subcommand: e.g. \'elbe initvm\'. \n\
> > @@ -48,6 +48,14 @@ if sys.argv[1] == "--version":
> >  
> >  cmd_list = get_cmdlist()
> >  
> > +if sys.argv[1] == "--test-commands":
> > +    for cmd in cmd_list:
> > +        os.system ("./elbe %s" % cmd)
> > +
> > +    print("all commands tested")
> > +    sys.exit(0)
> 
> What does this test ?

if all imports can be resolved, if there are any typos in the code.

> it will return sucess in any case,

yes, but if you pipe away stdout you can easily find things like this:

Traceback (most recent call last):
  File "./elbe", line 68, in <module>
    mod = __import__(modname)
  File "/home/local/projects/elbe/elbe/elbepack/commands/mkcdrom.py", line 25, in <module>
    from elbepack.elbeproject import ElbeProject
  File "/home/local/projects/elbe/elbe/elbepack/elbeproject.py", line 28, in <module>
    from elbepack.rfs import BuildEnv
  File "/home/local/projects/elbe/elbe/elbepack/rfs.py", line 34, in <module>
    from elbepack.efilesystem import BuildImgFs
  File "/home/local/projects/elbe/elbe/elbepack/efilesystem.py", line 30, in <module>
    from elbepack.hdimg import do_hdimg
  File "/home/local/projects/elbe/elbe/elbepack/hdimg.py", line 27, in <module>
    from elbepack.fstab import fstabentry, mountpoint_dict
  File "/home/local/projects/elbe/elbe/elbepack/fstab.py", line 26
    if blubb

> it relies on the current path.

yes, because it makes no sense to use outside devel.

> please remove.

okay, as suggested before, we need to rework the test directory, i think it
will be better placed there.

> It might make sense to implement elbe get_commands. so that we could do:
> 
> for i in `elbe get_commands`; do
>     elbe $i
> done
> 
> or something.
> 
> testing command modules requires a bit more delicate code to make that
> more useful. and this code should not reside in the elbe porcelain.

sure - but it did a good job during the py3 conversion.

I'll drop this patch in v2.

> > +
> > +
> >  if not sys.argv[1] in cmd_list:
> >      print "Unknown subcommand !\n"
> >      usage()
> > -- 
> > 2.15.1
> > 
> > 
> > _______________________________________________
> > elbe-devel mailing list
> > elbe-devel at linutronix.de
> > https://lists.linutronix.de/mailman/listinfo/elbe-devel
> 
> -- 
> Mit freundlichen Grüßen
> Torben Hohn
> 
> Linutronix GmbH
> 
> Standort: Bremen
> 
> Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
> 
> Firmensitz / Registered Office: D-88690 Uhldingen, Bahnhofstr. 3
> Registergericht / Local District Court: Amtsgericht Freiburg i. Br.; HRB
> Nr. / Trade register no.: 700 806
> 
> Geschäftsführer / Managing Directors: Heinz Egger, Thomas Gleixner
> 
> Eine Bitte von uns: Sollten Sie diese E-Mail irrtümlich erhalten haben,
> benachrichtigen Sie uns in diesem Falle bitte sobald wie es Ihnen
> möglich ist, durch Antwort-Mail. Vielen Dank!





More information about the elbe-devel mailing list