Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomato committed Jan 18, 2015
0 parents commit 8fda7eb
Show file tree
Hide file tree
Showing 26 changed files with 6,222 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"disallowEmptyBlocks": true,
"disallowMixedSpacesAndTabs": true,
"disallowSpaceAfterObjectKeys": true,
"disallowSpaceAfterPrefixUnaryOperators": ["!", "~", "++", "--", "+", "-"],
"disallowSpaceBeforeBinaryOperators": [","],
"disallowSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInsideParentheses": true,
"disallowTrailingWhitespace": true,
"disallowPaddingNewlinesInBlocks": true,
"requireCapitalizedConstructors": true,
"requireCommaBeforeLineBreak": true,
"requireLineFeedAtFileEnd": true,
"requireParenthesesAroundIIFE": true,
"requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"return",
"try",
"catch",
"function"
],
"requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
"requireSpaceBeforeBlockStatements": true,
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInFunctionDeclaration": {
"beforeOpeningCurlyBrace": true
},
"validateIndentation": 4,
"validateLineBreaks": "LF"
}
32 changes: 32 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"esnext": true,
"evil": false,
"indent": 4,
"moz": true,
"multistr": true,
"sub": true,
"trailing": true,
"undef": true,
"predef": [
"addCustomEqualityTester",
"afterAll",
"afterEach",
"ARGV",
"beforeAll",
"beforeEach",
"describe",
"expect",
"fdescribe",
"fit",
"imports",
"it",
"jasmine",
"pending",
"print",
"printerr",
"spyOn",
"window",
"xdescribe",
"xit"
]
}
21 changes: 21 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Philip Chimento

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
76 changes: 76 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
EXTRA_DIST =
CLEANFILES =

# Executable

dist_bin_SCRIPTS = bin/jasmine

do_subst = sed \
-e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \
-e 's,[@]GJS_PATH[@],$(GJS_PATH),g'\
$(NULL)
bin/jasmine: bin/jasmine.in Makefile
$(AM_V_GEN)$(MKDIR_P) bin && \
$(do_subst) < $< > $@ && \
chmod +x $@
EXTRA_DIST += bin/jasmine.in
CLEANFILES += bin/jasmine

# Source code

dist_pkgdata_DATA = \
src/command.js \
src/consoleReporter.js \
src/jasmineBoot.js \
src/options.js \
src/timer.js \
$(NULL)

# Jasmine library

dist_pkgdata_DATA += lib/jasmine.js

# The following rule is not meant to be executed as part of the build process.
# It is used to build our custom version of the Jasmine library by downloading
# the upstream file and applying our patches, and is meant for use only when
# upgrading to a new upstream version.
# This rule will explicitly not work if $(srcdir) is not writable.
$(srcdir)/lib/jasmine.js:
curl -o $@ https://raw.githubusercontent.com/jasmine/jasmine/v2.1.3/lib/jasmine-core/jasmine.js
patch <$(srcdir)/lib/local-modifications.patch $@
EXTRA_DIST += lib/local-modifications.patch

# Tests

TESTS = \
test/commandSpec.js \
test/consoleReporterSpec.js \
test/defaultReporterSpec.js \
test/focusedSpecIntegrationTest.js \
test/jasmineBootSpec.js \
test/jasmineIntegrationTest.js \
test/verboseReporterSpec.js \
$(NULL)
EXTRA_DIST += $(TESTS)
TEST_EXTENSIONS = .js

## This uses the local, uninstalled copy of Jasmine. If you were going to use
## this in your own package, you would do it like so and omit the -I flag:
## JS_LOG_COMPILER = jasmine
JS_LOG_COMPILER = $(builddir)/bin/jasmine
AM_JS_LOG_FLAGS = -I $(srcdir)/src -I $(srcdir)/lib
AM_TESTS_ENVIRONMENT = export SRCDIR='$(srcdir)'; export RUN_THOROUGH_TESTS=yes;

# Test fixtures

EXTRA_DIST += \
test/fixtures/notASpec.txt \
test/fixtures/someSpec.js \
test/fixtures/otherSpec.js \
$(NULL)

# Git ignore files

MAINTAINERCLEANFILES = $(GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL)

-include $(top_srcdir)/git.mk
108 changes: 108 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Jasmine for GJS

[Jasmine](https://github.com/jasmine/jasmine) is a BDD (behavior-driven
development) framework for JavaScript.

## Contents

This module allows you to run Jasmine specs for your GJS code.
The output will be displayed in your terminal.

## Installation

From Git:

```sh
git clone https://github.com/ptomato/jasmine-gjs
cd jasmine-gjs
./autogen.sh
make
sudo make install
```

From a tarball:

```sh
tar xJf jasmine-gjs-2.1.3.tar.xz
cd jasmine-gjs-2.1.3
./configure
make
sudo make install
```

## Usage

To run your test suite, pass its directory to the `jasmine` command:

```bash
jasmine mytestsuitedir
```

To run an individual spec:

```bash
jasmine path/to/spec.js
```

## Options

`--no-color`: Don't output color in the terminal.

`--verbose`: Output verbose results, formatted similarly to Mocha's
output.
(The default output is formatted the same as Jasmine's Node.JS runner's
output.)

## Integration with Autotools

If using autotools, you might want to integrate your test suite into
your makefiles.
Put this code in your `Makefile.am`:

```make
TESTS = path/to/spec1.js path/to/spec2.js
TEST_EXTENSIONS = .js
JS_LOG_COMPILER = jasmine
```

Don't forget to `EXTRA_DIST` your spec files too. Now Jasmine will run
your spec files one by one as part of `make check`.

If you use on-disk test fixtures, you should note that someone may be
building your software with separate source and build trees.
In that case, you have to make sure that your fixtures can be found both
when running tests from the source directory and from a separate build
directory.
I suggest defining an environment variable in your makefile that tells
where the fixtures can be found.
For example, in Jasmine GJS's own tests, this line is in `Makefile.am`:

```make
AM_TESTS_ENVIRONMENT = export SRCDIR='$(srcdir)';
```

The test code then reads the environment variable like this:

```js
let envSrcdir = GLib.getenv('SRCDIR');
const SRCDIR = envSrcdir? envSrcdir + '/' : '';

doSomethingWithFixture(SRCDIR + 'path/to/fixture');
```

## Support

Please file issues here at
[GitHub](https://github.com/ptomato/jasmine-gjs/issues).

## Credits

The idea of Jasmine for GJS was first explored by my coworkers Devin
Ekins and Sam Spilsbury:
[eos-jasmine](https://github.com/endlessm/eos-jasmine).
This code, however, is unashamedly cribbed from Pivotal Labs'
[jasmine-npm](https://github.com/jasmine/jasmine-npm).

Copyright (c) 2015 Philip Chimento.
This software is licensed under the MIT License &mdash; because Jasmine
and Jasmine NPM are too.
22 changes: 22 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.

srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.

autoreconf -if || exit $?

if test "$#" = 0 -a "x$NOCONFIGURE" = "x"; then
echo "**Warning**: I am going to run 'configure' with no arguments."
echo "If you wish to pass any to it, please specify them on the"
echo \'$0\'" command line."
echo
fi

if test "x$NOCONFIGURE" = "x"; then
echo Running $srcdir/configure "$@" ...
$srcdir/configure "$@" \
&& echo "Now type 'make' to compile" || exit 1
else
echo Skipping configure process.
fi
18 changes: 18 additions & 0 deletions bin/jasmine.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!@GJS_PATH@

const System = imports.system;

imports.searchPath.unshift('@pkgdatadir@');

const Command = imports.command;

const Timer = imports.timer;
Timer.installAPI(window);

// Do not conflict with global "jasmine" object
const JasmineBoot = imports.jasmineBoot;
let _jasmine = new JasmineBoot.Jasmine();
_jasmine.installAPI(window);

Command.run(_jasmine, ARGV);
System.exit(0);
19 changes: 19 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
AC_INIT([Jasmine GJS], [2.1.3])
AM_INIT_AUTOMAKE([1.11 -Wall foreign dist-xz no-dist-gzip parallel-tests])
AM_SILENT_RULES([yes])

# Check for programs we need during build

AC_PROG_MKDIR_P
PKG_PROG_PKG_CONFIG

AC_MSG_CHECKING([for GJS])
AS_IF([pkg-config --exists gjs-1.0], [AC_MSG_RESULT([yes])],
[AC_MSG_ERROR([You need GJS to install Jasmine for GJS!])])
GJS_PATH=`pkg-config --variable=gjs_console gjs-1.0`
AC_SUBST([GJS_PATH])

# Output build system

AC_CONFIG_FILES([Makefile])
AC_OUTPUT
Loading

0 comments on commit 8fda7eb

Please sign in to comment.