Skip to content

Commit

Permalink
Merge branch 'release/0.9.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
crucialfelix committed Dec 19, 2015
2 parents 1d527ad + 0d87e44 commit 2af8fef
Show file tree
Hide file tree
Showing 17 changed files with 295 additions and 52 deletions.
2 changes: 2 additions & 0 deletions examples/boot-server.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

// In your project you will import it like this:
// var sc = require('supercolliderjs');

Expand Down
2 changes: 2 additions & 0 deletions examples/call-and-response.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

// In your project you will import it like this:
// var sc = require('supercolliderjs');

Expand Down
2 changes: 2 additions & 0 deletions examples/call-api-from-node.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

/*
Example usage in a node-js app to call supercollider API functions
Expand Down
2 changes: 2 additions & 0 deletions examples/osc-once.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

/*
This example shows the low-level function server.oscOnce
Expand Down
1 change: 1 addition & 0 deletions examples/run-sclang-emitter.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node

/**
* this shows how to capture output of sclang
Expand Down
1 change: 1 addition & 0 deletions examples/run-sclang.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node

// Usually in your project you would import like this:
// var sc = require('supercolliderjs');
Expand Down
10 changes: 5 additions & 5 deletions examples/sclang-interpret.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node

/**
* a less verbose way to boot up sclang
Expand All @@ -9,10 +10,9 @@ var supercolliderjs = require('../index.js');
var options = {
// no STDIN, all input will be programmatic
stdin: false,
// echo STDOUT to console
echo: true,
// debug is on so you will see all traffic posted to the console
debug: true
echo: false,
// turn debug on if you want to see all stdout posted to the console
debug: false
};

// this catches out of band errors:
Expand Down Expand Up @@ -51,4 +51,4 @@ supercolliderjs.lang.boot(options)
sc.interpret('1 + 1.integerDoesntHaveThisMethod')
.then(resultHandler, errorHandler);

}).fail(onError);
}, onError);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "supercolliderjs",
"description": "Tools for working with the SuperCollider music language environment",
"version": "0.9.2",
"version": "0.9.3",
"author": "Chris Sattinger <[email protected]>",
"contributors": [
{
Expand Down
118 changes: 118 additions & 0 deletions src/lang/internals/__tests__/fixtures/errors-but-did-compile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
init_OSC
empty
compiling class library...
NumPrimitives = 589
compiling dir: '/usr/local/share/SuperCollider/SCClassLibrary'
compiling dir: '/usr/local/share/SuperCollider/Extensions'
compiling dir: '/home/colin/.local/share/SuperCollider/downloaded-quarks/API'
compiling dir: '/home/colin/.local/share/SuperCollider/downloaded-quarks/crucial-library'
compiling dir: '/home/colin/.local/share/SuperCollider/downloaded-quarks/ddwCommon'
compiling dir: '/home/colin/.local/share/SuperCollider/downloaded-quarks/ddwGUIEnhancements'
compiling dir: '/home/colin/.local/share/SuperCollider/downloaded-quarks/ddwMixerChannel'
compiling dir: '/home/colin/.local/share/SuperCollider/downloaded-quarks/JITMIDIKtl'
compiling dir: '/home/colin/quarks/cs-supercollider-lib'
compiling dir: '/home/colin/projects/taw/quarks/taw'
pass 1 done
ERROR: Class extension for nonexistent class 'Document'
In file:'/deprecated/3.7/deprecated-3.7.sc'
ERROR: Class extension for nonexistent class 'Document'
In file:'/home/colin/.local/share/SuperCollider/downloaded-quarks/ddwGUIEnhancements/Document-scanFor.sc'
numentries = 1624748 / 27374880 = 0.059
6955 method selectors, 3936 classes
method table size 13771996 bytes, big table size 109499520
Number of Symbols 18069
Byte Code Size 576045
compiled 648 files in 2.33 seconds

Info: 16 methods are currently overwritten by extensions. To see which, execute:
MethodOverride.printAll

compile done
ERROR: A primitive was not bound. 0 588
Instance of Method { (0x1a95f60, gc=01, fmt=00, flg=11, set=04)
instance variables [15]
raw1 : Float 0.000000 00000000 0038000C
raw2 : Float 0.000000 00000200 02010002
code : instance of Int8Array (0x1a96120, size=4, set=3)
selectors : nil
constants : nil
prototypeFrame : instance of Array (0x1a960a0, size=2, set=3)
context : nil
argNames : instance of SymbolArray (0x1a96020, size=2, set=3)
varNames : nil
sourceCode : nil
ownerClass : class Meta_Font (0x1a923e0)
name : Symbol 'prDefaultFamilyForStyle'
primitiveName : Symbol '_QFont_DefaultFamilyForStyle'
filenameSymbol : Symbol '/usr/local/share/SuperCollider/SCClassLibrary/Common/GUI/Base/QFont.sc'
charPos : Integer 1909
}
WARNING: Qt font initialisation failed
LID: event loop started
Class tree inited in 0.12 seconds

*************************
startup.scd is running...
*************************

Cleaning up temp synthdefs...
ERROR: Message 'highlight' not understood.
RECEIVER:
class QtGUI (0x1aeffa0) {
instance variables [19]
name : Symbol 'QtGUI'
nextclass : instance of Meta_QuadC (0x148b5e0, size=19, set=5)
superclass : Symbol 'Object'
subclasses : nil
methods : nil
instVarNames : nil
classVarNames : instance of SymbolArray (0x1af0060, size=1, set=3)
iprototype : nil
cprototype : instance of Array (0x1af00e0, size=1, set=3)
constNames : nil
constValues : nil
instanceFormat : Integer 0
instanceFlags : Integer 0
classIndex : Integer 173
classFlags : Integer 0
maxSubclassIndex : Integer 173
filenameSymbol : Symbol '/usr/local/share/SuperCollider/SCClassLibrary/Common/GUI/Base/QtGUI.sc'
charPos : Integer 0
classVarIndex : Integer 383
}
ARGS:
CALL STACK:
DoesNotUnderstandError:reportError 0xe3fef0
arg this = <instance of DoesNotUnderstandError>
Nil:handleError 0xdc2450
arg this = nil
arg error = <instance of DoesNotUnderstandError>
Thread:handleError 0xe08450
arg this = <instance of Thread>
arg error = <instance of DoesNotUnderstandError>
Object:throw 0x1e68730
arg this = <instance of DoesNotUnderstandError>
Object:doesNotUnderstand 0xdf6d50
arg this = <instance of Meta_QtGUI>
arg selector = 'highlight'
arg args = [*0]
< closed FunctionDef > (no arguments or variables)
Function:doOnStartUp 0xe76f10
arg this = <instance of Function>
ArrayedCollection:do 0xe8df70
arg this = [*14]
arg function = <instance of Function>
var i = 11
List:do 0xe8dfd0
arg this = <instance of List>
arg function = <instance of Function>
Meta_StartUp:run 0xe3c6b0
arg this = <instance of Meta_StartUp>
Main:startup 0x1e4be10
arg this = <instance of Main>
var didWarnOverwrite = false
^^ The preceding error dump is for ERROR: Message 'highlight' not understood.
RECEIVER: QtGUI


sc3>
9 changes: 9 additions & 0 deletions src/lang/internals/__tests__/fixtures/forward-stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SUPERCOLLIDERJS:725282d0-a31c-11e5-9a22-59ba9f49924a:CAPTURE:START

ERROR: Quarks-install: path does not exist /Users/crucial/wrong

SUPERCOLLIDERJS:725282d0-a31c-11e5-9a22-59ba9f49924a:CAPTURE:END

SUPERCOLLIDERJS:725282d0-a31c-11e5-9a22-59ba9f49924a:START:Result
SUPERCOLLIDERJS:725282d0-a31c-11e5-9a22-59ba9f49924a:CHUNK:"nil"
SUPERCOLLIDERJS:725282d0-a31c-11e5-9a22-59ba9f49924a:END:Result
5 changes: 5 additions & 0 deletions src/lang/internals/__tests__/fixtures/trig-not-defined.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ERROR: Variable 'trig' not defined.
in file 'selected text'
line 9 char 47:

Klank.ar(z, Decay.ar(Impulsar.ar(trig), decay, WhiteNoise.ar(noise)), freqScale, 0.0, timeScale
49 changes: 49 additions & 0 deletions src/lang/internals/__tests__/sclang-io-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ describe('sclang-io', function() {
expect(io.state).toEqual(STATES.READY);
});

it('should detect succesful compile despite errors in startup', function() {
var io = new SclangIO();
io.setState(STATES.BOOTING);
feedIt('errors-but-did-compile.txt', io);
// its COMPILED but didn't go to READY on sc3>
expect(io.state).toEqual(STATES.READY);
});

it('should detect programmatic compiling', function() {
var io = new SclangIO();
io.setState(STATES.READY);
Expand Down Expand Up @@ -122,4 +130,45 @@ describe('sclang-io', function() {
*/
});

describe('SyntaxErrors', function() {

it('should parse a SyntaxError from stdout', function() {
var io = new SclangIO();
io.setState(STATES.READY);

var text = readFile('trig-not-defined.txt');
var error = io.parseSyntaxErrors(text);

expect(error).toBeTruthy();
expect(error.msg).toBe('Variable \'trig\' not defined.');
expect(error.file).toBe('selected text');
expect(error.line).toBe(9);
expect(error.charPos).toBe(47);
});

pit('on successful interpret, should still post output to stdout', function() {
var io = new SclangIO();
io.setState(STATES.READY);

// stick a blank Promise into register so it will
// parse the response
io.registerCall('725282d0-a31c-11e5-9a22-59ba9f49924a', {
resolve: () => {},
reject: () => {}
});

return new Promise((resolve) => {
// this is what is really being tested:
// does it post to STDOUT
io.on('stdout', (out) => {
console.log('STDOUT:', out);
resolve(true);
});

var text = readFile('forward-stdout.txt');
io.parse(text);
});
});
});

});
20 changes: 17 additions & 3 deletions src/lang/internals/sclang-io.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class SclangIO extends EventEmitter {
fn: function() {
var parsed = self.parseCompileErrors((self.parseErrors || []).join('\n'));
self.compiledDirs = parsed.dirs;
delete self.parseErrors;
self.parseErrors = [];
self.setState(STATES.COMPILED);
}
},
Expand All @@ -121,7 +121,7 @@ class SclangIO extends EventEmitter {
re: /Welcome to SuperCollider ([0-9a-zA-Z\.]+)\. /m,
fn: function(match) {
self.version = match[1];
var parsed = self.parseCompileErrors((self.parseErrors || []).join('\n'));
var parsed = self.parseCompileErrors((self.parseErrors).join('\n'));
self.compiledDirs = parsed.dirs;
delete self.parseErrors;
self.setState(STATES.READY);
Expand Down Expand Up @@ -159,6 +159,12 @@ class SclangIO extends EventEmitter {
self.version = match[1];
self.setState(STATES.READY);
}
},
{
re: /^[\s]*sc3>[\s]*$/m,
fn: function(/*match, text*/) {
self.setState(STATES.READY);
}
}
],
ready: [
Expand Down Expand Up @@ -216,6 +222,13 @@ class SclangIO extends EventEmitter {

if (guid in self.calls) {
if (response.type === 'Result') {
// anything posted during CAPTURE should be forwarded
// to stdout
stdout = self.capturing[guid].join('\n');
delete self.capturing[guid];
if (stdout) {
self.emit('stdout', stdout);
}
self.calls[guid].resolve(obj);
} else {
if (response.type === 'SyntaxError') {
Expand Down Expand Up @@ -276,10 +289,11 @@ class SclangIO extends EventEmitter {
parseSyntaxErrors(text) {
var
msgRe = /^ERROR: syntax error, (.+)$/m,
msgRe2 = /^ERROR: (.+)$/m,
fileRe = /in file '(.+)'/m,
lineRe = /line ([0-9]+) char ([0-9]+):$/m;

var msg = msgRe.exec(text),
var msg = msgRe.exec(text) || msgRe2.exec(text),
line = lineRe.exec(text),
file = fileRe.exec(text),
code = text.split('\n').slice(4, -3).join('\n').trim();
Expand Down
2 changes: 1 addition & 1 deletion src/sc-classes/SystemOverwrites/plusQuarks.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
});
LanguageConfig.store(this.configPath);
LanguageConfig.store(LanguageConfig.currentPath);
cache = Dictionary.new;
this.clearCache;
}
*link { |path|
path = path.withoutTrailingSlash;
Expand Down
26 changes: 26 additions & 0 deletions src/server/__tests__/server-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ jest.dontMock('../ServerState');
jest.dontMock('../internals/SendOSC');
jest.dontMock('rx');
import * as _ from 'underscore';
import {EventEmitter} from 'events';

var Server = require('../server').Server;

Expand All @@ -17,6 +18,31 @@ describe('Server', function() {
});
});

describe('boot sequence', function() {
pit('should detect "server ready" even if the output is broken into chunks', function() {

var one = 'SuperCollider 3 se';
var two = 'rver ready.';

var server = new Server();
spyOn(server, '_spawnProcess').andReturn();
// make a fake this.process.stdout / stderr
server.process = {
stdout: new EventEmitter(),
stderr: new EventEmitter()
};

return new Promise((resolve) => {
// spawn process is mocked
// should get triggered by the stdout and then resolve
server.boot().then(resolve);

server.process.stdout.emit('data', one);
server.process.stdout.emit('data', two);
});
});
});

describe('oscOnce', function() {
pit('should fullfill', function() {
var s = new Server();
Expand Down
Loading

0 comments on commit 2af8fef

Please sign in to comment.