Skip to content
This repository was archived by the owner on Jul 25, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ before_install:
- npm install -g node-gyp
- git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git && export PATH=$PATH:$(pwd)/depot_tools
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CXX=g++-4.8; fi
- cd ..
- npm install widl-nan
- cd -
before_script:
- python ./tools/lint.py
64 changes: 64 additions & 0 deletions test/Util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (c) 2016 Intel Corporation. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.

'use strict';

var Path = require('path');
var Fs = require('fs');
var Crypto = require('crypto');
var Rimraf = require('rimraf');

function Util() {}

Util.prototype.ensureTestRoot =
function() {
var rootPath = Path.join(__dirname, '..', 'test-tmp');
rootPath = Path.normalize(rootPath);
if (!this.isDir(rootPath)) {
Fs.mkdirSync(rootPath);
}
if (this.isDir(rootPath)) {
return rootPath;
}
return null;
};

Util.prototype.isFile =
function(dir) {
try {
if (Fs.statSync(dir).isFile()) {
return true;
}
} catch (e) {
return false;
}
};

Util.prototype.isDir =
function(dir) {
try {
if (Fs.statSync(dir).isDirectory()) {
return true;
}
} catch (e) {
return false;
}
};

Util.prototype.createTmpDir =
function() {
var tmpDir = null;
var rootPath = this.ensureTestRoot();
if (rootPath) {
var tmpDirName = Crypto.randomBytes(5).toString('hex');
tmpDir = rootPath + Path.sep + tmpDirName;
if (this.isDir(tmpDir)) {
Rimraf.sync(tmpDir);
}
Fs.mkdirSync(tmpDir);
}
return tmpDir;
};

module.exports = new Util();
14 changes: 14 additions & 0 deletions test/command-line/sample.widl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06
exception InvalidName {
DOMString reason;
};

exception NoSuchPet { };

interface Person {

// A simple attribute that can be set to any value the range an unsigned
// short can take.
attribute unsigned short age;

};
Loading