mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Add cpplint to test suite
This commit is contained in:
parent
5dab3c8482
commit
b86674f91f
@ -1,6 +1,8 @@
|
||||
{
|
||||
"strict": true,
|
||||
"node": true,
|
||||
"maxparams": 4,
|
||||
"maxcomplexity": 11,
|
||||
"globals": {
|
||||
"describe": true,
|
||||
"it": true
|
||||
|
@ -43,7 +43,8 @@
|
||||
"mocha": "^2.1.0",
|
||||
"mocha-jshint": "^0.0.9",
|
||||
"istanbul": "^0.3.5",
|
||||
"coveralls": "^2.11.2"
|
||||
"coveralls": "^2.11.2",
|
||||
"node-cpplint": "^0.4.0"
|
||||
},
|
||||
"license": "Apache 2.0",
|
||||
"engines": {
|
||||
|
@ -162,4 +162,4 @@ namespace sharp {
|
||||
return window_size;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace sharp
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef SHARP_COMMON_H
|
||||
#define SHARP_COMMON_H
|
||||
#ifndef SRC_COMMON_H_
|
||||
#define SRC_COMMON_H_
|
||||
|
||||
namespace sharp {
|
||||
|
||||
@ -66,6 +66,6 @@ namespace sharp {
|
||||
*/
|
||||
int InterpolatorWindowSize(char const *name);
|
||||
|
||||
} // namespace
|
||||
} // namespace sharp
|
||||
|
||||
#endif
|
||||
#endif // SRC_COMMON_H_
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef SHARP_METADATA_H
|
||||
#define SHARP_METADATA_H
|
||||
#ifndef SRC_METADATA_H_
|
||||
#define SRC_METADATA_H_
|
||||
|
||||
#include "nan.h"
|
||||
|
||||
NAN_METHOD(metadata);
|
||||
|
||||
#endif
|
||||
#endif // SRC_METADATA_H_
|
||||
|
@ -10,8 +10,29 @@
|
||||
#include "common.h"
|
||||
#include "resize.h"
|
||||
|
||||
using namespace v8;
|
||||
using namespace sharp;
|
||||
using v8::Handle;
|
||||
using v8::Local;
|
||||
using v8::Value;
|
||||
using v8::Object;
|
||||
using v8::Integer;
|
||||
using v8::String;
|
||||
using v8::Array;
|
||||
using v8::Function;
|
||||
using v8::Exception;
|
||||
|
||||
using sharp::ImageType;
|
||||
using sharp::DetermineImageType;
|
||||
using sharp::InitImage;
|
||||
using sharp::InterpolatorWindowSize;
|
||||
using sharp::HasProfile;
|
||||
using sharp::HasAlpha;
|
||||
using sharp::ExifOrientation;
|
||||
using sharp::IsJpeg;
|
||||
using sharp::IsPng;
|
||||
using sharp::IsWebp;
|
||||
using sharp::IsTiff;
|
||||
using sharp::counterProcess;
|
||||
using sharp::counterQueue;
|
||||
|
||||
enum class Canvas {
|
||||
CROP,
|
||||
@ -20,11 +41,11 @@ enum class Canvas {
|
||||
};
|
||||
|
||||
enum class Angle {
|
||||
D0,
|
||||
D90,
|
||||
D180,
|
||||
D270,
|
||||
DLAST
|
||||
D0,
|
||||
D90,
|
||||
D180,
|
||||
D270,
|
||||
DLAST
|
||||
};
|
||||
|
||||
struct ResizeBaton {
|
||||
@ -111,6 +132,7 @@ class ResizeWorker : public NanAsyncWorker {
|
||||
libuv worker
|
||||
*/
|
||||
void Execute() {
|
||||
|
||||
// Decrement queued task counter
|
||||
g_atomic_int_dec_and_test(&counterQueue);
|
||||
// Increment processing task counter
|
||||
@ -316,7 +338,7 @@ class ResizeWorker : public NanAsyncWorker {
|
||||
if (vips_flatten(image, &flattened, "background", background, NULL)) {
|
||||
vips_area_unref(reinterpret_cast<VipsArea*>(background));
|
||||
return Error(baton, hook);
|
||||
};
|
||||
}
|
||||
vips_area_unref(reinterpret_cast<VipsArea*>(background));
|
||||
vips_object_local(hook, flattened);
|
||||
image = flattened;
|
||||
@ -510,7 +532,9 @@ class ResizeWorker : public NanAsyncWorker {
|
||||
// Post extraction
|
||||
if (baton->topOffsetPost != -1) {
|
||||
VipsImage *extractedPost;
|
||||
if (vips_extract_area(image, &extractedPost, baton->leftOffsetPost, baton->topOffsetPost, baton->widthPost, baton->heightPost, NULL)) {
|
||||
if (vips_extract_area(image, &extractedPost,
|
||||
baton->leftOffsetPost, baton->topOffsetPost, baton->widthPost, baton->heightPost, NULL
|
||||
)) {
|
||||
return Error(baton, hook);
|
||||
}
|
||||
vips_object_local(hook, extractedPost);
|
||||
@ -942,7 +966,7 @@ NAN_METHOD(resize) {
|
||||
baton->output = *String::Utf8Value(options->Get(NanNew<String>("output"))->ToString());
|
||||
|
||||
// Join queue for worker thread
|
||||
NanCallback *callback = new NanCallback(args[1].As<v8::Function>());
|
||||
NanCallback *callback = new NanCallback(args[1].As<Function>());
|
||||
NanAsyncQueueWorker(new ResizeWorker(callback, baton));
|
||||
|
||||
// Increment queued task counter
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef SHARP_RESIZE_H
|
||||
#define SHARP_RESIZE_H
|
||||
#ifndef SRC_RESIZE_H_
|
||||
#define SRC_RESIZE_H_
|
||||
|
||||
#include "nan.h"
|
||||
|
||||
NAN_METHOD(resize);
|
||||
|
||||
#endif
|
||||
#endif // SRC_RESIZE_H_
|
||||
|
@ -70,6 +70,6 @@ NAN_METHOD(counters) {
|
||||
NAN_METHOD(libvipsVersion) {
|
||||
NanScope();
|
||||
char version[9];
|
||||
snprintf(version, 9, "%d.%d.%d", vips_version(0), vips_version(1), vips_version(2));
|
||||
snprintf(version, sizeof(version), "%d.%d.%d", vips_version(0), vips_version(1), vips_version(2));
|
||||
NanReturnValue(NanNew<String>(version));
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef SHARP_UTILITIES_H
|
||||
#define SHARP_UTILITIES_H
|
||||
#ifndef SRC_UTILITIES_H_
|
||||
#define SRC_UTILITIES_H_
|
||||
|
||||
#include "nan.h"
|
||||
|
||||
@ -8,4 +8,4 @@ NAN_METHOD(concurrency);
|
||||
NAN_METHOD(counters);
|
||||
NAN_METHOD(libvipsVersion);
|
||||
|
||||
#endif
|
||||
#endif // SRC_UTILITIES_H_
|
||||
|
47
test/unit/cpplint.js
Executable file
47
test/unit/cpplint.js
Executable file
@ -0,0 +1,47 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var assert = require('assert');
|
||||
|
||||
var cpplint = require('node-cpplint/lib/');
|
||||
|
||||
describe('cpplint', function() {
|
||||
|
||||
// List C++ source files
|
||||
fs.readdirSync(path.join(__dirname, '..', '..', 'src')).forEach(function (source) {
|
||||
var file = path.join('src', source);
|
||||
it(file, function(done) {
|
||||
// Lint each source file
|
||||
cpplint({
|
||||
files: [file],
|
||||
linelength: 140,
|
||||
filters: {
|
||||
legal: {
|
||||
copyright: false
|
||||
},
|
||||
build: {
|
||||
include: false,
|
||||
include_order: false,
|
||||
namespaces: false
|
||||
},
|
||||
whitespace: {
|
||||
blank_line: false,
|
||||
comments: false,
|
||||
parens: false
|
||||
}
|
||||
}
|
||||
}, function(err, report) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
var expected = {};
|
||||
expected[file] = [];
|
||||
assert.deepEqual(expected, report);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user