electricimp / Builder

Preprocessor
Other
21 stars 4 forks source link

Test failures and @if #14

Closed gbsallery closed 8 years ago

gbsallery commented 8 years ago

Hi,

I've been trying to use Builder to pre-process some source files for an Electric Imp project (as we wish to use Git version control and to perform automated testing, probably using SqJasmine). Unfortunately, I seem to have hit a snag with @if statements. The following could should, I believe, result in the contents of "raisin.agent.toplevel.ext" being included in the output:

@if env == 'stub'
    @include "imp.agent.ext"
@endif

@include "raisin.agent.toplevel.ext"

However, output terminates at the closing @endif. I have a couple of variant test cases for this, all of which seem to result in termination at the end of the first @if statement in the code.

My next step was going to be to add a test case to the Builder project (as I cannot find any test cases where output is expected to continue past the end of the @if block), but unfortunately a clean checkout of Builder results in numerous test failures when running npm test (at least on my Mac, running OS X El Capitan).

Can you shed any light on this? I'm not a node.js expert by any means, so it's entirely possible that I'm doing something daft regarding the test execution.

Thanks,

Gavin

ppetrosh commented 8 years ago

Hi Govin,

I just tried the latest Builder@master (macOS Sierra, Node v4.4.7):

$ npm test

Builder@1.0.0 test /working/cse/Builder node_modules/jasmine/bin/jasmine.js

Started ........................................................................................................

104 specs, 0 failures Finished in 31.045 seconds

All tests pass. Also I build a test case:

a.nut:

@if env == 'stub' @include "1.nut" @endif

@include "2.nut"

1.nut:

server.log("hi from 1.nut")

2.nut:

server.log("hi from 2.nut")

and after preprocessing a.nut with env defined to "stub" (node /usr/local/lib/node_modules/Builder/src/cli.js -l a.nut -Denv stub) I've got:

line 1 "1.nut"

server.log("hi from 1.nut")

line 4 "device.nut"

line 1 "2.nut"

server.log("hi from 2.nut")

Which seems to be a reasonable output to me. So I feel like I need more information or help from your side to reproduce the issue.

What's your Node.js version?

Thanks, Pavel

ppetrosh commented 8 years ago

As discussed with Gavin, it looks like a local environment issue and the Builder works fine on a different machine. So closing the ticket for now.