link cppuint library only when doing a "make check" - configuration

You can run unit tests in our application by doing a make check. However, the cppuint library is hardcoded into LDFLAGS in Makefile.am. Is there a way of linking in the cppuint library in configure.am only when doing a make check and not linking with when doing a regular make?

Nothing pre-canned. You can probably do it with make tricks.
However, I would say you probably do not want to go this route. Doing this means relinking on "make check" but also relinking again on "make all" or "make install".
Another approach would be to make your test suite use a special test version of the executable, with a different name. And for this one you could use a per-target setting to add the library to the link flags.

Related

Live templates in PhpStorm not useful

I installed "Live Templates for Angular" plugin in PhpStorm. I think something is wrong with suggestion (triggered with Ctrl + Space). I have to write whole snippet a-component to get to right suggestion.
Can I improve it somehow in settings?
Here is a gif:
It's because the template name (abbreviation) has a dash - in it ... and when completing IDE treats a and component as separate parts until whole match is found (in case you were doing some subtraction operation with two variables). At very least that's my understanding of this behaviour based on my own usage experience.
You may just change the abbreviation and remove - from there and it will be much better recognized as valid completion item. But that may not be ideal in long run (potentially may have issues when plugin will be updated with new templates etc.)
To bypass it ... just use Live Template specific completion where only Live Templates will be listed. For that invoke shortcut assigned to Code | Insert Live Template... action (Ctrl + J on Windows using Default keymap) at any time when you're typing your Live Template abbreviation.
Please make sure the applicable context yet.
Apply to the specified type of file, or check everywhere.
Like below:

How to fix the error "Rename refactoring can't be applied in this context" in Netbeans?

I'm currently working on a HTML5 projects in netbeans and wanted to change a variable name with multiple occurrence. However, when I clicked refactor and then rename, the IDE tells me that:
Rename refactoring can't be applied in this context.
So is it possible to refactor variable names in HTML5 projects in Netbeans?
The JavaScript refactoring options are very limited, typically it works only in context of single file and you can invoke it by placing cursor on the target variable/function and pressing Ctrl+R (sorry, not sure about the shortcut on Mac) and then typing a new name. This is not full refactoring, only "limited rename" and again, it will rename variables only in given file, not the whole project.
Please note that in NetBeans if you open Refactor from the main menu, there is also Rename action with the same shortcut displayed but the shortcut is actually doing something else than the menu item.

How to configure FlashDevelop for unit test builds?

I'm using AsUnit for unit-testing my current AS3 project. My Main() is basically:
if ( UnitTest )
runUnitTests();
else
runMainProgram();
where I change UnitTest before building depending on whether I want to run the program or run the unit tests. Is there a way that makes it easier to switch between the two modes?
Optimally, I'd use F5 for building with UnitTest=false and another hotkey for building with UnitTest=false. What is the closest I can get with FlashDevelop?
You can do the following in FlashDevelop
if(CONFIG::debug) {
trace("Debug");
} else if(CONFIG::release) {
trace("Release");
}
These correspond to the drop down in the toolbar next to the play button.
See this link: http://www.flashdevelop.org/wikidocs/index.php?title=AS3_Conditional_Compilation
In terms of the shortcut, just create a macro that switches the release mode then hits play. From there you can add any shortcut you would like to your macro. So one shortcut will launch the course into debug/release mode as required.
Also note, you can have other CONFIG::bla's - so you might want to have CONFIG:unit1, CONFIG:unit2, etc, etc. See above link.
Easy solution:
duplicate the FlashDevelop project file (.as3proj) and name it "MyProject_tests.as3proj",
open this project, create a new ProjectTests class and set it as the main class,
change the output SWF in project settings.
Add another project file. To run the test using it as the primary. "Document class" the context menu on the file.
Like Chris mentioned, you can use FlashDevelop's Compiler Constants to do what you need, though it is a bit cumbersome turning these constants on and off.
However, there is a FlashDevelop plugin called Config::Toggle that makes that significantly quicker by providing an additional panel where you can enable/disable boolean constants with 1 click. The linked website describes the value of the plugin far better than I ever could. Hope that helps.

Watch file(s) for modifications algorithm

I was simply wondering how file watching algorithms are implemented. For instance, let's say I want to apply a filter (i.e., search/replace a string) to a file every time it is modified, what technique should I use? Obviously, I could run an infinite loop that would check every file in a directory for modifications, but it might not be very efficient. Is there any way to get notified directly by the OS instead? For the sake of demonstration, let's assume a *nix OS and whatever language (C/Ruby/Python/Java/etc.).
Linux has inotify, and judging from the wikipedia links, Windows has something similar called 'Directory Management'. Without something like inotify, you can only poll..
In Linux there is the Inotify subsystem which will alert you to file modification.
JavaSE 7 will have File Change Notification as part of NIO.2 updates.
There are wrappers to inotify that make it easy to use from high-level languages. For example, in ruby you can do the following with rb-inotify:
notifier = INotify::Notifier.new
# tell it what to watch
notifier.watch("path/to/foo.txt", :modify) {puts "foo.txt was modified!"}
notifier.watch("path/to/bar", :moved_to, :create) do |event|
puts "#{event.name} is now in path/to/bar!"
end
There's also pyinotify but I was unable to come up with an example as concise as the above.

When developing an R package, do I have to recompile the package every time I make a change?

I am developing a package in R
When I am debugging a particular function or set of functions, what is the best way to test the function?
Do I have to either use source('function.R') or R CMD build each time I want to check my changes?
(extra credit for associated emacs ess key-bindings)
See also http://github.com/hadley/devtools/ which provides some tools to make this task easier.
for example, after making changes to source code, you build, install, and reload a package with the function install():
library(devtools)
install("package_name")
devtools also makes it easier to:
Reload complete package:
load_all("pkg")
Create or update documentation using roxygen2
document("pkg")
run all scripts in /inst/test/:
test("pkg")
build and R CMD check:
check("pkg")
Take a look at ?insertSource, which is a new function in R 2.12.0, plus the other functions in the See Also section of that help page. Also, check out ?assignInNamespace if your package has a Namespace.
The above presumes you are talking about updating and debugging R sources, not compiled code.
I generally have used the source() route to load new versions of functions I am improving/debugging, alongside the usual R debugging tools. But I haven't got Namespaces in my packages as yet. My fingers have gotten quite used to the C-c C-l keybinding in emacs+ess for sourcing a buffer over the years.
You might want to have a look at the 'mvbutils' package. I use it to live-edit my packages all the time; I can add, remove, and edit functions and documentation while the package is loaded, and the changes are reflected both in the loaded version, in the installed version (so they're kept in the next R session), and [when I tell it] in the "source package". I only re-build via R CMD when I want to distribute a zipped version to someone else. To test code, I use the 'debug' package, which works fine on a loaded package.
I even use 'mvbutils' to live-edit 'mvbutils', which can be a bit hairy sometimes.
The 'mvbutils' documentation could really do with a full demo of this in action, but in theory the existing doco should show you how to proceed.
Can't help you with Emacs, sorry...
I had got the same issue and I solved it while using RStudio.
In the editor, I check the option "Source on save" for my R file that contains function. As I'm used to save my file each time I edit it (a good habit I think), the corresponding functions loaded in my R workspace is always up to date.