Contributing with tests

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
50 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Re: Contributing with tests

Célia Cacciatore
Hello, 

We corrected our bash script for amber version and made a new pull request on branch issue993.

Thanks,
Celia, Jonathan, Quentin, Romain

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Contributing with tests

Herby Vojčík
Ok, no need to use ML, if you do / need to ask something related to an existing issue or pullrequest, use comments in github tracker itself and @githubusername mentioning in them. So that the discussion is closer to the source.

Herby

Célia Cacciatore wrote:

> Hello,
>
> We corrected our bash script for amber version and made a new pull
> request on branch issue993.
>
> Thanks,
> Celia, Jonathan, Quentin, Romain
>
> --
> You received this message because you are subscribed to the Google
> Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [hidden email]
> <mailto:[hidden email]>.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Contributing with tests

Jonathan Geoffroy
In reply to this post by Célia Cacciatore
Hello,

We are trying to translate our bash script test in shell.js but we got an error:

amberResult = exec("node " + env['AMBER_VERSION_COMMAND'], {silent: true}).output

expectedAmberVersion
= exec("node --eval \"console.log(require('./" + env['JSON_PACKAGE_PATH'] + "').version)\"", {silent : true}).output
var sameVersion = (amberResult.indexOf(expectedAmberVersion) > -1)

sameVersion is always false. However expectedAmberVersion equals "0.13.0" and amberResult equals "Welcome to Amber version 0.13.0 (NodeJS 0.10.29)."
If we do: 
amberResult.indexOf("0.13.0") > -1
it returns true.
Do you have any idea where it can come from?

Thanks
Célia, Jonathan, Quentin, Romain. 

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Contributing with tests

Herby Vojčík


Jonathan Geoffroy wrote:

> Hello,
>
> We are trying to translate our bash script test in shell.js but we got
> an error:
>
> ||
> amberResult =exec("node
> "+env['AMBER_VERSION_COMMAND'],{silent:true}).output
>
> expectedAmberVersion =exec("node --eval
> \"console.log(require('./"+env['JSON_PACKAGE_PATH']+"').version)\"",{silent
> :true}).output

Well, this is really very mechanical rewrite :-). Why not just
  expectedAmberVersion = require('./'+env['JSON_PACKAGE_PATH']).version;
?

BTW unless you really need things like JSON_PACKAGE_PATH in environment, you can just declare it as variable
  var JSON_PACKAGE_PATH = './...';
and later just use it, like:
  expectedAmberVersion = require(JSON_PACKAGE_PATH).version;


> var sameVersion =(amberResult.indexOf(expectedAmberVersion)>-1)
>
> sameVersion is always false. However expectedAmberVersion equals
> "0.13.0" and amberResult equals "Welcome to Amber version 0.13.0
> (NodeJS 0.10.29)."
> If we do:
> ||
> amberResult.inde
xOf("0.13.0")>-1
> it returns true.
> Do you have any idea where it can come from?

Maybe because you actually use exec(...).output. It means it can contain the endline (so in fact it is "0.13.0\n").

> Thanks
> Célia, Jonathan, Quentin, Romain.

Herby

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Contributing with tests

Jonathan Geoffroy
Hello,

Thanks for your help, it works now!

I'm trying to refactor my own shelljs script. I have still some questions:
  1. as you can see in my previous answer, path to files are relative; so depending on where I run the script, it can succeed (if I run it from tests directory), or fail, because it doesn't find the file. How can I avoid this problem?
  2. Should I add my script  into package.json? ("test": "./tests/amberVersionTest.js") 
  3. I have two dependencies: shelljs and colors. Can I add there dependencies directly in the package.json dependencies? Is there a way to download there dependencies only if I run npm test ?
  4. Should I commit the shelljs script in the same branch, or create a new one named issue993-shelljs?
Thanks.

Célia, Jonathan, Quentin, Romain.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Contributing with tests

Herby Vojčík


Jonathan Geoffroy wrote:

>     Hello,
>
>
> Thanks for your help, it works now!
>
> I'm trying to refactor my own shelljs script. I have still some questions:
>
>  1. as you can see in my previous answer, path to files are relative;
>     so depending on where I run the script, it can succeed (if I run
>     it from /tests/ directory), or fail, because it doesn't find the
>     file. How can I avoid this problem?

Don't care. If you declare "must be run from it's directory", it's not your responsibility, it's responsibility of the runner of the script to run it from specific directory. And it's not at all wrong to accept only you core responsibility and avoid all the rest. Makes things work better. For more on this and similar good advices, see http://alanknightsblog.blogspot.sk/2011/10/principles-of-oo-design-or-everything-i.html.

>  2. Should I add my script into package.json? ("test":
>     "./tests/amberVersionTest.js")

Yes, you can. Of course, other scripts must add
them as well, and there can only be one "test": "..." there, so it needs some serialization (accepting one of them into master, merging master into other, updating "test" line so it contains "foo && bar".

BTW, I would test if it works on windows with pure "filename.js", as it fails normally from commandline - .js files are not run by node, but by WScript engine. So it is fails, the line should be "node ./tests/amberVersionTests.js" instead.

>  3. I have two dependencies: /shelljs/ and /colors. /Can I add there
>     dependencies directly in the package.json dependencies? Is there a
>     way to download there dependencies only if I run npm test ?

You should not do this manually, but use npm. Since you use them only for tests, they are not true dependencies, but devDependencies. You add those bu running `npm install shelljs colors --save-dev`.

>  4. Should I commit the shelljs script in the same branch, or create a
>     new one named issue993-shelljs?

You can use the sam
e one. Of course, good behaviour is that you (oiten, but at least before PR) merge master of main repo into your branch, and only then start developing / issue a pullrequest.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Contributing with tests

Herby Vojčík
> Don't care. If you declare "must be run from it's directory", it's not
from _its_ directory, of course :-/

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Contributing with tests

Herby Vojčík
In reply to this post by Herby Vojčík
> WScript engine. So it is fails, the line should be "node
So _if it_ fails. :-/

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Contributing with tests

Manfred Kröhnert
In reply to this post by Jonathan Geoffroy
Hi,


On Thu, Oct 16, 2014 at 12:26 PM, Jonathan Geoffroy <[hidden email]> wrote:
Hello,

Thanks for your help, it works now!

I'm trying to refactor my own shelljs script. I have still some questions:
  1. as you can see in my previous answer, path to files are relative; so depending on where I run the script, it can succeed (if I run it from tests directory), or fail, because it doesn't find the file. How can I avoid this problem?

In my opinion, the best and safest way for this case would be to create a temporary directory with a unique name and do all file related work in there and remove it once you are done (like the C function mktemp; check in a console with "man 3 mktemp").
It will provide you with a clean directory every time the script is run and even allows running the same script in parallel.

Best,
Manfred

 
  1. Should I add my script  into package.json? ("test": "./tests/amberVersionTest.js") 
  2. I have two dependencies: shelljs and colors. Can I add there dependencies directly in the package.json dependencies? Is there a way to download there dependencies only if I run npm test ?
  3. Should I commit the shelljs script in the same branch, or create a new one named issue993-shelljs?
Thanks.

Célia, Jonathan, Quentin, Romain.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Contributing with tests

Célia Cacciatore
In reply to this post by Célia Cacciatore
Hello,

We've finished our course on testing.

We would like to thank you all for your help and advices during the time we spent making our tests.
We hope they will be useful.

Thank you again !

Celia, Jonathan, Quentin, Romain

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
123