Rake feature -- strange argument - ruby

I have the "foo.feature" file and I want to execute the commands in this file via Rake:
rake feature['foo.feature',100000]
The first argument (or what is it) is completely clear, but what about the other one? Is it an amount of scripts executions or something like this?
Unfortunately I am unable to find this in the docs.

If memory serves, that is the syntax used to call rake feature and deliver two arguments to the feature task, namely 'foo.feature' and 100000.
You'll want to look into your rakefile and see what is expected for the task in question.
For what it's worth, it's an unwieldily and error-prone syntax. There are better libraries to build scripts that accept arguments and options such as OptionParse or Thor. Even better, use rake as a replacement for make, and use something else to develop shell-based commands.

Related

scons pass arguments to a particular step

I have a very complex scons project. One of the targets include running a unittest application that is generated as part of the build.
I would like to be able to say:
scons <target> <some magic: arguments>
where some magic is something that will tell scons for which execution step the arguments are and the arguments are completely arbitrary arguments that the unittest application knows how to interpret.
the question is, is there already mechanism to do this, or I need to add code in my scons to achieve this - in both cases a pointers how to do it will be great.
Please check the User Guide at http://scons.org/doc/production/HTML/scons-user.html . You'll be interested in chapter 10 "Controlling a Build From the Command Line", which describes ways how to propagate values from the command-line to your SConscripts.
Reserve an Environment Variable, e.g. "UNITTST_ARGS", and use it to transport your arguments through to your SConscript, where you actually call your external unittest application.

Convert Chef recipe to series of Bash commands?

Typically, one wants to convert Bash scripts to Chef. But sometimes (like, right now) you need to do the opposite. Is there an automatic way to get the list of commands run for a given Chef cookbook on a given configuration?
I'm not trying to end up with something with the full functionality of the Chef cookbook. I want to end up with a small set of commands that reproduce this particular installation on this particular environment. (The reason in this case is I need to separate out the 'sudo' commands and get them run by someone else. I do have sudo access on a machine that I could run Chef on to carry out this task though.)
I doubt you can do that in general, and even if you could, it would likely be more work than implementing what you need in Chef.
For example, even something as simple as creating a configuration file is implemented in Chef as ruby code; you would need to figure out a way to turn that into echo "…" > /etc/whatever.com. Doing that for all resources would be a major undertaking.
It seems to me that what you should actually do is modify any Chef cookbook that you use to run commands as a different user.
Things like template and file are pretty easy: the file will be created as root, and then chown-ed to the correct user. execute resources (which run commands) can be configured to run the command with su simply by specifying the user:
execute "something" do
command "whoami"
user "nobody"
end
It might take you a while to figure out, but once you get the hang of it it's pretty easy; much easier than converting to bash.

Calling Rspec with syntax like ruby -I

I am trying to use https://github.com/rifraf/Vendorize which is run using a command like
D:\projects\SomeLibrary\lib>ruby -I..\..\Vendorize\lib -rvendorize some_lib.rb
It does something clever where it intercepts required files and logs them, but only the ones that get executed in your command line. On it's documentation pages it says
You can run the program several times with different options if the
required files depend on the options.
Or just run your tests…
I want to run all the tests with the -I function from the command line above, so that all the different avenues of code are run, and the libraries loaded (and logged). Given that I can run them like:
D:\projects\SomeLibrary\lib>rspec ..\spec\some_spec.rb
How do I do this? Thanks!
NB: I am a/ a ruby newbie and b/ running windows
I would try writing something like this at the top of some_spec.rb:
require_relative '..\..\Vendorize\lib\vendorize'
You might need to change that a bit depending on what your working directory is.
Then just runs your specs with rspec as you normally do without any extra commands.
If that doesn't work, then locate the rspec.rb executable and run:
ruby -I..\..\Vendorize\lib -rvendorize path/to/rspec.rb ..\spec\some_spec.rb

is it possible to pass through command-line options to a script in rspec

I have an RSpec script that tests a program in a different language I am developing. Since I can run and test 32 and 64-bit versions of this application, I would like to have a way to signal this on the command-line.
What I really want is to do something like this:
rspec -c myspec.rb lin32
or
rspec -c myspec.rb lin64
and have the lin32 or lin64 be passed as a string I can access in the ruby file itself. Is this possible? This site mentions environment variables but that is cumbersome. It also mentioned doing ARGV manipulation -- is this a possible way of doing it?
From David Chelimsky
You can't pass arbitrary arguments to the rspec command, but you can set an environment variable like this:
SLEEP=10 rspec test.rb
Then within the script, the value of ENV["SLEEP"] is "10", so you can say:
sleep(ENV["SLEEP"].to_f)
Try the -- parameter. It's used to tell an app to stop processing parameters and pass the remaining ones to a child process. I don't know if rspec understands it but it's worth a try.
`rspec -c myspec.rb -- lin32`
`rspec -c myspec.rb -- lin64`

Using rake with Teamcity gives a RegexError

Every time that I try use team city to build a .NET solution using rake I receive the same
"Format_exception_msg : Invalid escape character syntax: /path to rakefile/ (RegexError)
My natural assumption would be that I have in fact a invalid escape character somewhere in my rake code, I admit that I've never used ruby or rake before, but the script itself executes without problems and behaves as it should when executed on the command line without the use of teamcity.
Furthermore, I went through my code slowly commenting out lines to try to narrow down where the invalid character could be and the team city process continuted to fail even with a completely commented out rake file.
Thanks for the help, let me know if more information is needed.

Resources