Generating a SpecRunner for jasmine using grunt - gruntjs

When i add and remove tests i often have to create/edit a SpecRunner.html file.
I know i can run a test server using karma. But for developing tests i prefer to inspect the results in the browser. I've tried using karma and i currently run tests with grunt; but sometimes i prefer the console better for writing tests.
Are there yeoman generators that will generate a specrunner for me automatically at this point in time?
I've found this npm package: https://npmjs.org/package/atropa-jasmine-spec-runner-generator-html
but it doesn't seem widely supported or runs via grunt.

grunt-template-jasmine-requirejs is a good option for Angular/Backbone projects. It is meant to work with grunt-contrib-jasmine, but it will generate a spec runner html file for you on the fly using grunt.
Specify the output in the gruntfile
jasmine:{
template: require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfigFile: 'src/test/js/require-unit-config.js'
},
test:{
options:{
outfile:'mySpecRunner.html'
}
}
}

Related

Can I invoke gulp from a cake-build file?

I have an ASP.NET solution where I perform some tasks using gulp (e.g. less-compilation). Inside Visual Studio the corresponding gulp-task is bound to the BeforeBuild event, so it is automatically started whenever I build the solution.
I was experimenting with cake for building and packaging the solution. While building the solution works fine using either the DotNetBuild() or MSBuild() tasks, the gulp tasks are not executed during the build.
It seems that gulp (and probably also other task runners) are not automatically "integrated" in the build process.
Does cake somehow support invoking gulp during the build?
(Of course, it should ideally also restore gulp itself (using npm / package.json) if it is not available.)
Note: This answer was copied from the
Cake issue response
by Mattias Karlsson (with his permission).
Just did a quick look so I might be missing something, but checking the
csproj file, the BeforeBuild MSBuild target seems to be empty?
Visual Studio 2015 has a built-in task runner for Gulp/Grunt so this
might be what's kicking in.
Currently we don't have aliases for NPM or Gulp (that would be an
great addin though), but what you could do is to invoke Gulp yourself
via the StartProcess alias. I tweaked your build.cake slighly below:
var target = Argument("target", "Default");
DirectoryPath solutionDir = MakeAbsolute(Directory("./"));
FilePath solution = solutionDir.CombineWithFilePath("WebApplication1.sln");
DirectoryPath projectDir = solutionDir.Combine("WebApplication1");
FilePath lessOutput = projectDir.CombineWithFilePath("css/style.css");
Task("Default")
.Does(() =>
{
NuGetRestore(solution);
if (FileExists(lessOutput))
{
Information("Cleaning old less output {0}", lessOutput);
DeleteFile(lessOutput);
}
StartProcess("cmd", new ProcessSettings {
Arguments = "/c \"set CI=true && npm install && gulp compile-less\"",
WorkingDirectory = projectDir
});
if (!FileExists(lessOutput))
{
throw new Exception("Less failed to create " + lessOutput);
}
Information("Less created {0}", lessOutput);
MSBuild(solution);
});
RunTarget(target);
This assumes you have Node & Gulp installed globally (you install Gulp
globally via running npm install -g gulp), also this was 5 min quick
and dirty, so you would want to divide clean/restore/less into separate
cake tasks. I set environment CI=true because some node modules
could require user interaction on restore otherwise.
Discarding MSBuild / NuGet restore above will output something like:
Cleaning old less output C:/temp/cake_issue_672/WebApplication1/WebApplication1/css/style.css
[11:26:12] Using gulpfile C:\temp\cake_issue_672\WebApplication1\WebApplication1\gulpfile.js
[11:26:12] Starting 'compile-less'...
[11:26:13] Finished 'compile-less' after 29 ms
Less created C:/temp/cake_issue_672/WebApplication1/WebApplication1/css/style.css
This might not be the solution you were working for, but it "should"
work.
UPDATE: There is now an addin for Cake for running Gulp Tasks. You can find it here
As to why using the MSBuild Alias in Cake is not invoking the BeforeBuild target we are not sure. Could I ask that you raise an issue here so that we can discuss it. Ideally, a sample project that demonstrates the problem could be provided so that we can investigate.
To answer your overall question though...
No, currently, there are no Cake Aliases/Addin's that support running Gulp Tasks as part of the build pipeline. That is not to say that this couldn't be done, simply that it hasn't been on our radar yet.
Having said that, given that you can write any arbitrary C# as part of your build script, there is no reason that you couldn't spawn out a process to invoke gulp with the necessary arguments to do the work.

Automatically running PHPUnit tests with Arcanist (Phabricator)

A "simple" question: how can I automatically run PHPunit tests with Arcanist?
According to the documentation I should first load a custom library. As stated here I should create a .arcconfig file and load the appropriate library.
So: I've create a dir "arc_libs" in my project and in the dir "src" I used arc liberate to generate the needed files. My config is now:
{
"project.name" : "arc_libs",
"phabricator.uri" : "https://phabricator.xxx.xxx.net/",
"unit.engine" : "PhpunitTestEngine",
"load" : ["arc_libs/src"]
}
The libary DOES get loaded because I can run arc unit
[matthijs#xx xxx]$ arc unit
No tests to run.
But as you can see there are no tests to run. We keep our tests in "project_root/tests" and as far as I understand the documentation I should create a __tests__ dir in "the module" (probably my arc_libs dir ?)
However I want to run my existing PHPunit test files, not new tests I need to create. I tried using a symlink etc but I cannot get it to work. Arcanist doesn't detect my tests.
So my question: How can I automatically run my EXISTING PHPunit tests with arcanist?
(note we use arc diff that should run arc unit automatically)
The documentation you linked won't be very useful - it's aimed at Phabricator developers who want to test their libraries. There is some user-facing documentation for customising unit test tasks, but it's not great. Fortunately, it's quite easy to get Arcanist to run your project's unit tests using the included PhpunitTestEngine:
Prepare a phpunit.xml file in your project root. This should be a standard PHPUnit configuration file. You can test this by running phpunit -c phpunit.xml.
Add a phpunit_config option to your .arcconfig:
{
"phabricator.uri": "https://phabricator.xxx.xxx.net/",
"unit.engine": "PhpunitTestEngine",
"phpunit_config": "phpunit.xml"
}
Run arc unit to test it out.
Although user documentation is thin on the ground, the source code for PhpunitTestEngine has some comments and is fairly concise. If you run into problems, reading through the test engine code can help you track it down.
$ arc unit --help
unit [options] [paths]
unit [options] --rev [rev]
Supports: git, svn, hg
Run unit tests that cover specified paths. If no paths are specified,
unit tests covering all modified files will be run.
By default, arc lint and arc unit are meant to be used as part of a process of making changes, so by default it only acts on changed files. Odds are, you don't have any changed files. You probably want to specify some paths, or run arc unit --everything to run all tests.

Combine sbt tasks from different scopes

I use sbt with the native packager plugin, in order to build Debian packages for our Play 2.2 applications. We use the debian:publish in order to upload the packages to our Artifactory server, and the publish command to publish the regular Java jars.
I'd like to be able to use the regular publish command to published both the jar files and the Debian packages. I think I need to somehow combine the publish task in the Debian scope with the regular one in the Compile scope, but I can't really find any documentation on how to do that.
I came up with the following code, which works, but seems to me to be the 'wrong' way to do it:
publish := { // Also publish deb files
val value = publish.value
(publish in Debian).value
}
Especially the second line seems wrong, since it's ignoring the value. The val is there to quiet a warning, which is another smell.
Is there a better way to do this?
You can use triggeredBy. In your build.sbt add following line:
publish in Debian <<= (publish in Debian).triggeredBy(publish in Compile)
PS. I think the way you did it is also fine. If you're worried about the warning you can assign the result to some val.
Here, the dependsOn task is appropriate, if you don't care about the return value:
publish := publish.dependsOn(publish in Debian).value

adobe brackets-shell : cef extract failed

I followed all the step is mention in given below url to build my project( I am using win7 OS).
https://github.com/adobe/brackets-shell/wiki/Building-brackets-shell.
actullly i want to create brackets installer (installed wix 3.7).
but i am getting cef-extract failed error.
even though i also used grunt cef-extract --force.
after that its throunging new error.
create -project failed after that i am not able to process further.
can some one help me.
thanks in advanced.
Regards
ashish .
If you include the exact console output you're seeing, it would be much easier to help you. But based on snags other people have encountered recently, you can try these things:
Make sure your PATH includes Python 2.7 (otherwise "create-project" will fail).
Delete all these folders to be sure you're starting from a clean slate: deps, Debug, include, libcef_dll, Release, Resources.
Just run the high-level tasks grunt setup and grunt build, following the Building brackets-shell instructions. (There's a known bug where grunt cef-extract fails when run standalone).

LESS CSS on Windows

Trying to set up LESS for CSS on my Windows box, I've installed ruby and rubygems and followed the instructions exactly.
I have put teststyle.less in C:\.
When I type
lessc teststyle.less
to compile it into a .css file, I get an error:
The filename, directory name, or volume label syntax is incorrect.
Out of those familiar with LESS, do any of you have a solution to my problem?
Did I mess up the install?
If you don't want to use GUI to compile LESS on Windows, there is a clean way to get lessc command on Windows command line. It only requires you to install node.js, which is required by original lessc anyway.
So, install node.js (http://nodejs.org/) and install "less" module for node.js. The latter provides lessc executable (lessc.cmd on Windows) as well, so you should only make sure it gets under your PATH in Windows.
If you don't have node.js yet, here are step-by-step instructions:
Install node.js (http://nodejs.org/)
In new command-line, go to node.js installation directory (where node.exe is located), and execute > npm install less (make sure you do so from node.js installation directory only)
Latter downloads less module for node.js, as well as lessc.cmd to node_modules/.bin/ directory. Add this directory to PATH
Now, in new command line you may enjoy the use of lessc as usual
Source: http://pragmatictim.blogspot.fr/2012/08/developing-with-less-on-windows-getting.html
You should look at http://www.dotlesscss.org/, less ported to C# and specifically designed for .NET. You can use either a handler or compile.
Been using it for about six months, it's great.
Oops...saw windows and assumed dot net, perhaps that's not your environment. If not, never mind...
Edit:
lessc does work on Windows now. See the Github page about commandline LESS tools for installation and usage instructions. The Github page with a list of LESS GUI tools might also be interesting.
Original answer:
The lessc command line tool for less.js doesn't work on Windows. If you want command line compiling of your LESS files you should check out this post.
Also be sure to check out WinLess. WinLess is a compiler (with GUI) for LESS. WinLess can watch your LESS files, and automatically compile them when they have changed.
If you are using Visual Studio for your projects you should also check out the BuildEventScript of winless.org.
Be sure to check which compiler is being used when you are using different programs to compile your LESS code. If you are using programs which use different compilers you should watch out for interoperability issues (LESS code working correctly with one compiler, but not with another).
FYI, I found this Windows command line tool to compile LESS into CSS useful. It uses less.js to do the compilation. The command syntax is not very graceful, but it works well.
https://github.com/duncansmart/less.js-windows
I just started using Crunch to compile Bootstrap and its pretty awesome. Its built on Adobe Air, which you will have to install if you don't already have it.
I think I found the problem. In my first installation I installed to C:\Program Files\Ruby
so I uninstalled and tried the default 'C:\Ruby' install path. Seems to fix the problem and it now works correctly. Thanks.
I have a recompiled version of DotlessCss that can accept less code from standard input and output the css code to the standard output. I have attached it at the following link LESS CSS Compiler for Windows
Only this https://github.com/leafo/lessphp PHP compiler didn't crashed with my crazy project structure with CSS imports in LESS, etc.
Very simple shell command for compiling LESS to CSS:
plessc input.less > output.css
You can use Prepros App for windows. It can compile less, sass, jade, stylus, markdown, coffeescript and haml with live browser refresh.

Resources