Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

looking at tests was: cpan warning

by Aldebaran (Curate)
on Jan 13, 2023 at 23:46 UTC ( [id://11149582]=note: print w/replies, xml ) Need Help??


in reply to Re^3: cpan warning for XML::DoubleEncodedEntities
in thread cpan warning for XML::DoubleEncodedEntities

looking at tests

Thanks for your reply, kcott. As the world turns, you or Athanasius are the monks who take a first gander with what I am posting in SoPW. I want you to know that I respect you, and I try to adopt your perl style when you offer it. I traffic in a lot of exotic wide characters that I barely understand unless I can relate them to what I know, and when I'm knocking on the monastery door, my encodings are usually less than successful, and anything but well-ordered. I don't think the game is always winnable with some data sets, and I get them too. I'm working on better ways to represent translated data on the command line, but that's still in the works.

I'd like to take 2 hot seconds to thank the author(s) of Astro::SIMBAD::Client. If there is anything here that reads as criticism, it is that I'm trying to make good software better. I'm delighted that the utility exists.

For this, I'd generally use the prove utility. On the Astro::SIMBAD::Client page, there's a direct link to the tarball, there's also a link to the GitHub repository if you prefer that. Unpack the tarball and run the usual "perl Makefile.PL" ...

Q1) How do I make a merge request on this project to change the documentation?

I've been around the track a couple times with this software, and I'm starting to get the sense of it. I've learned that SOAP is a relative of SMTP. If half the things I know about SMTP apply to SOAP, then I would say that it is an issue that is superceded by the current script.

So where does the text come from that hits STDOUT during:

fritz@laptop:~/Documents/perlmonks/Astro-SIMBAD-Client-0.047$ perl Ma +kefile.PL The following optional modules were not available: * SOAP::Lite is not available. This module is required for the query() method. If you do not intend to use this method, SOAP::Lite is not needed. It is not necessary to install these now. If you decide to install the +m later, this software will make use of them when it finds them. The simbadc script is a simple wrapper for Astro::SIMBAD::Client, whic +h may be used interactively or as a Unix filter. >>>> NOTICE <<<<

Specifically, adiosing the lines:

The following optional modules were not available: * SOAP::Lite is not available. This module is required for the query() method. If you do not intend to use this method, SOAP::Lite is not needed. It is not necessary to install these now. If you decide to install the +m later, this software will make use of them when it finds them.

Q1) (^^^specifically) How do I make a merge request on this project to change the documentation?

I get a really good look at basic.t in the debugger at the precipice before it succeeds:

>> n # http://simbad.u-strasbg.fr/: SIMBAD4 1.8 - 2022-12 main::(basic.t:36): 1; >> y $smb = Astro::SIMBAD::Client=HASH(0x558df742b510) 'autoload' => 1 'debug' => 0 'delay' => 3 'emulate_soap_queries' => 1 'format' => HASH(0x558df797c188) 'script' => '' 'txt' => '---\\nname: \'%IDLIST(NAME|1)\'\\ntype: \'%OTYPE\'\\nl +ong: \'%OTYPELIST\'\\nra: %COO(d;A)\\ndec: %COO(d;D)\\nplx: %PLX(V)\\ +npm:\\n - %PM(A)\\n - %PM(D)\\nradial: %RV(V)\\nredshift: %RV(Z)\\n +spec: %SP(S)\\nbmag: %FLUXLIST(B)[%flux(F)]\\nvmag: %FLUXLIST(V)[%flu +x(F)]\\nident:\\n%IDLIST[ - \'%*\'\\n]' 'vo' => 'id(NAME|1),otype,ra(d),dec(d),plx_value,pmra,pmdec,rv_v +alue,z_value,sp_type,flux(B),flux(V)' 'parser' => HASH(0x558df796e728) 'script' => '' 'txt' => '' 'vo' => '' 'post' => 1 'scheme' => 'http' 'server' => 'simbad.u-strasbg.fr' 'type' => 'txt' 'verbatim' => 0 >> #p $smb{server} >> r 1..5 Debugged program terminated. Use q to quit or R to restart,

This is using the following save/source file:

#source 2.basic.txt #source 2.basic.txt n n n n n n n n n n n n n n s v s n n #v n #save 3.basic.txt #v b 1147 n n n n n n n n n n y #p $smb{server} r #save 4.basic.txt

Q2) p $smb{server} wasn't the right syntax to print that value. What is? (I'm rusty)

Moving on to proving.

fritz@laptop:~/Documents/perlmonks/Astro-SIMBAD-Client-0.047$ prove - +vb t/basic.t t/basic.t .. ok 1 - require Astro::SIMBAD::Client; ok 2 - Instantiate Astro::SIMBAD::Client ok 3 - Initial debug setting is 0 ok 4 - Able to set debug to 1 ok 5 - Default scheme is 'http' # http://simbad.u-strasbg.fr/: http://simbad.u-strasbg.fr/simbad/: 500 + Can't connect to simbad.u-strasbg.fr:80 (Name or service not known) +at t/basic.t line 35. 1..5 ok All tests successful. Files=1, Tests=5, 11 wallclock secs ( 0.03 usr 0.01 sys + 0.19 cusr + 0.03 csys = 0.26 CPU) Result: PASS fritz@laptop:~/Documents/perlmonks/Astro-SIMBAD-Client-0.047$

We've got a couple issues here. Does the # commented line represent a test?

As we look deeper, the answer is: yes and no. I might call it a "test on the sly:"

eval { diag join ': ', $smb->__build_url(), scalar $smb->release(); 1; } or do { my $err = $@; diag join ': ', $smb->__build_url(), $err; };

So, when I fired up that prove command, I populated the southern end of this routine with values. Yes, the error was successfully reported, and I don't know that I would want to write software that gets blamed for failing when the internet is off, so it represents a bit of a quandary for me.

As it is, I kick my network manager in the rear, and then repeat:

alias bounce alias bounce='sudo service network-manager restart ' fritz@laptop:~/Documents/perlmonks/Astro-SIMBAD-Client-0.047$ bounce [sudo] password for fritz: fritz@laptop:~/Documents/perlmonks/Astro-SIMBAD-Client-0.047$ prove -v +b t/basic.t t/basic.t .. ok 1 - require Astro::SIMBAD::Client; ok 2 - Instantiate Astro::SIMBAD::Client ok 3 - Initial debug setting is 0 ok 4 - Able to set debug to 1 ok 5 - Default scheme is 'http' # http://simbad.u-strasbg.fr/: SIMBAD4 1.8 - 2022-12 1..5 ok All tests successful. Files=1, Tests=5, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.20 cusr + 0.01 csys = 0.24 CPU) Result: PASS fritz@laptop:~/Documents/perlmonks/Astro-SIMBAD-Client-0.047$

Q3) How would we lend this routine official test status?

Q4) How would we write code to trap this error and then do something useful about it (that is, bouncing the network, waiting 15 seconds and trying again)?

Q5) How do you get privileges for a script that didn't start with them?

I'm not sure what the answer is to Q5, but I won't call it a proper answer if it involves me tapping around the keyboard to enter a password. It occurs to me that there might need to be a place where scripts can read the word that makes them sudoed, for example:

fritz@laptop:~/Documents/repo1$ cat 1.example.config.txt [deepl] url=https://api-free.deepl.com/v2/translate key=redacted [pass] password=shazam!!! fritz@laptop:~/Documents/repo1$

Q6) Are there more subtle ways to do this?

I can't see a "Q2) ...?". :-)

I've always got more questions. I'm trying to pick the right battles. :-)

Cheers

Replies are listed 'Best First'.
Re: looking at tests was: cpan warning
by hippo (Bishop) on Jan 14, 2023 at 11:09 UTC
    I've learned that SOAP is a relative of SMTP.

    That's certainly not how I would phrase it. Perhaps you can explain how you think they are "relatives"?

    Specifically, adiosing the lines:

    The following optional modules were not available: * SOAP::Lite is not available. This module is required for the query() method. If you do not intend to use this method, SOAP::Lite is not needed. It is not necessary to install these now. If you decide to install the +m later, this software will make use of them when it finds them.

    I never use Module::Build when I have the choice but it looks to me like that is Module::Build boilerplate. The only way you are going to remove this is to change the distribution's dependencies such that SOAP::Lite is no longer a recommended dependency.

    Does the # commented line represent a test?

    No. It is a diagnostic message output by the test script which is not part of TAP. You can safely ignore it if all your tests pass. I think this means we can safely bypass Q3, Q4 and Q5. :-)

    Q6) Are there more subtle ways to do this?

    Dear $DEITY I hope not. That's an unattended privilege escalation and is 100% asking for trouble. Don't even go there.


    🦛

      I never use Module::Build when I have the choice but it looks to me like that is Module::Build boilerplate. The only way you are going to remove this is to change the distribution's dependencies such that SOAP::Lite is no longer a recommended dependency.

      I think I remember the author writing that this was a change he might make. I don't think anyone really knows what soap::lite is. If you do, you're a vanishing breed. My understanding is that the ultimate script does what it needs without any more soap.

      No. It is a diagnostic message output by the test script which is not part of TAP. You can safely ignore it if all your tests pass. I think this means we can safely bypass Q3, Q4 and Q5. :-)

      Yeah, so I agree that an install script is definitely not where we want to be scripting elevations of privileges. But I'm gonna bring those questions back in a setting where it makes sense.

      Dear $DEITY I hope not. That's an unattended privilege escalation and is 100% asking for trouble. Don't even go there.

      Alles klar...btw, I got fired because I wouldn't use google for our group documents. Amis....

Re: looking at tests was: cpan warning
by kcott (Archbishop) on Jan 14, 2023 at 01:55 UTC
    ... you or Athanasius are the monks who take a first gander with what I am posting in SoPW. I want you to know that I respect you, ...

    ++ Thanks for your kind words.

    Both Athanasius and I are in Australia. I suspect our daytime coincides with your nighttime, astronomy activities; other monks in Americas/Europe are possibly tucked up in bed when you post.

    Q1 .. Q6

    I don't think I've had any direct experience with any of these, but here are some hopefully useful links.

    — Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11149582]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-03-29 00:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found