Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- normalized crc iteration logic - added browser demo - added command line tool crc32 - fixed unicode baseline script (node 6 changed default array printing) - fixed performance tests (benchmark module changed behavior) - updated travis versions for test - miscellaneous adjustments to tooling
- Loading branch information
1 parent
79a265b
commit e1c9c5e
Showing
31 changed files
with
805 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ test_files/*.py | |
test_files/*.js | ||
test_files/baseline* | ||
misc/coverage.html | ||
misc/*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
language: node_js | ||
node_js: | ||
- "5.0" | ||
- "4.2" | ||
- "6" | ||
- "5" | ||
- "4" | ||
- "0.12" | ||
- "0.10" | ||
- "0.8" | ||
before_install: | ||
- "npm install -g npm@next" | ||
- "npm install -g mocha crc-32 benchmark ansi" | ||
- "npm install -g mocha" | ||
- "npm install codepage" | ||
- "npm install blanket" | ||
- "npm install coveralls mocha-lcov-reporter" | ||
after_success: | ||
- "make coveralls-spin" | ||
- "make perf-all" | ||
# - "make perf-all" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,88 @@ | ||
LIB=crc32 | ||
REQS= | ||
ADDONS= | ||
AUXTARGETS= | ||
AUXTARGETS=demo/browser.js | ||
HTMLLINT=index.html | ||
|
||
ULIB=$(shell echo $(LIB) | tr a-z A-Z) | ||
DEPS=$(sort $(wildcard bits/*.js)) | ||
TARGET=$(LIB).js | ||
FLOWTARGET=$(LIB).flow.js | ||
|
||
## Main Targets | ||
|
||
.PHONY: all | ||
all: $(TARGET) $(AUXTARGETS) | ||
all: $(TARGET) $(AUXTARGETS) ## Build library and auxiliary scripts | ||
|
||
$(TARGET) $(AUXTARGETS): %.js : %.flow.js | ||
node -e 'process.stdout.write(require("fs").readFileSync("$<","utf8").replace(/^\s*\/\*:[^*]*\*\/\s*(\n)?/gm,"").replace(/\/\*:[^*]*\*\//gm,""))' > $@ | ||
node -e 'process.stdout.write(require("fs").readFileSync("$<","utf8").replace(/^[ \t]*\/\*[:#][^*]*\*\/\s*(\n)?/gm,"").replace(/\/\*[:#][^*]*\*\//gm,""))' > $@ | ||
|
||
$(LIB).flow.js: $(DEPS) | ||
$(FLOWTARGET): $(DEPS) | ||
cat $^ | tr -d '\15\32' > $@ | ||
|
||
bits/01_version.js: package.json | ||
echo "CRC32.version = '"`grep version package.json | awk '{gsub(/[^0-9a-z\.-]/,"",$$2); print $$2}'`"';" > $@ | ||
|
||
.PHONY: clean | ||
clean: clean-baseline | ||
rm -f $(TARGET) | ||
clean: clean-baseline ## Remove targets and build artifacts | ||
rm -f $(TARGET) $(FLOWTARGET) | ||
|
||
## Testing | ||
|
||
.PHONY: test mocha | ||
test mocha: test.js $(TARGET) baseline | ||
test mocha: test.js $(TARGET) baseline ## Run test suite | ||
mocha -R spec -t 20000 | ||
|
||
.PHONY: ctest | ||
ctest: | ||
ctest: ## Build browser test (into ctest/ subdirectory) | ||
cat misc/*.js > ctest/fixtures.js | ||
cp -f test.js ctest/test.js | ||
cp -f $(TARGET) ctest/ | ||
|
||
.PHONY: ctestserv | ||
ctestserv: ## Start a test server on port 8000 | ||
@cd ctest && python -mSimpleHTTPServer | ||
|
||
.PHONY: baseline | ||
baseline: ## Build test baselines | ||
@bash ./misc/make_baseline.sh | ||
|
||
.PHONY: clean-baseline | ||
clean-baseline: ## Remove test baselines | ||
@bash ./misc/make_baseline.sh clean | ||
|
||
## Code Checking | ||
|
||
.PHONY: lint | ||
lint: $(TARGET) $(AUXTARGETS) | ||
jshint --show-non-errors $(TARGET) $(AUXTARGETS) | ||
jshint --show-non-errors package.json | ||
jscs $(TARGET) $(AUXTARGETS) | ||
lint: $(TARGET) $(AUXTARGETS) ## Run jshint and jscs checks | ||
@jshint --show-non-errors $(TARGET) $(AUXTARGETS) | ||
@jshint --show-non-errors package.json | ||
@jshint --show-non-errors --extract=always $(HTMLLINT) | ||
@jscs $(TARGET) $(AUXTARGETS) | ||
|
||
.PHONY: flow | ||
flow: lint | ||
flow check --all --show-all-errors | ||
flow: lint ## Run flow checker | ||
@flow check --all --show-all-errors | ||
|
||
.PHONY: cov cov-spin | ||
cov: misc/coverage.html | ||
cov-spin: | ||
make cov & bash misc/spin.sh $$! | ||
|
||
COVFMT=$(patsubst %,cov_%,$(FMT)) | ||
.PHONY: $(COVFMT) | ||
$(COVFMT): cov_%: | ||
FMTS=$* make cov | ||
.PHONY: cov | ||
cov: misc/coverage.html ## Run coverage test | ||
|
||
misc/coverage.html: $(TARGET) test.js | ||
mocha --require blanket -R html-cov -t 20000 > $@ | ||
|
||
.PHONY: coveralls coveralls-spin | ||
coveralls: | ||
mocha --require blanket --reporter mocha-lcov-reporter -t 20000 | ./node_modules/coveralls/bin/coveralls.js | ||
|
||
coveralls-spin: | ||
make coveralls & bash misc/spin.sh $$! | ||
.PHONY: coveralls | ||
coveralls: ## Coverage Test + Send to coveralls.io | ||
mocha --require blanket --reporter mocha-lcov-reporter -t 20000 | node ./node_modules/coveralls/bin/coveralls.js | ||
|
||
.PHONY: perf | ||
perf: | ||
bash perf/perf.sh | ||
perf: ## Run Performance Tests | ||
@bash perf/perf.sh | ||
|
||
.PHONY: perf-all | ||
perf-all: | ||
bash misc/perf.sh | ||
|
||
.PHONY: baseline clean-baseline | ||
baseline: | ||
./misc/make_baseline.sh | ||
.PHONY: help | ||
help: | ||
@grep -hE '(^[a-zA-Z_-][ a-zA-Z_-]*:.*?|^#[#*])' $(MAKEFILE_LIST) | bash misc/help.sh | ||
|
||
clean-baseline: | ||
rm -f test_files/*.* | ||
#* To show a spinner, append "-spin" to any target e.g. cov-spin | ||
%-spin: | ||
@make $* & bash misc/spin.sh $$! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env node | ||
/* crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */ | ||
/* vim: set ts=2 ft=javascript: */ | ||
|
||
var X; | ||
try { X = require('../'); } catch(e) { X = require('crc-32'); } | ||
var fs = require('fs'); | ||
require('exit-on-epipe'); | ||
|
||
var args = process.argv.slice(2); | ||
|
||
var filename; | ||
if(args[0]) filename = args[0]; | ||
|
||
if(!process.stdin.isTTY) filename = filename || "-"; | ||
|
||
if(!filename) { | ||
console.error("crc32: must specify a filename ('-' for stdin)"); | ||
process.exit(1); | ||
} | ||
|
||
if(filename === "-h" || filename === "--help") { | ||
console.log("usage: " + process.argv[0] + " [filename]"); | ||
process.exit(0); | ||
} | ||
|
||
if(filename !== "-" && !fs.existsSync(filename)) { | ||
console.error("crc32: " + filename + ": No such file or directory"); | ||
process.exit(2); | ||
} | ||
|
||
if(filename === "-") process.stdin.pipe(require('concat-stream')(process_data)); | ||
else process_data(fs.readFileSync(filename)); | ||
|
||
function process_data(data) { | ||
console.log(X.buf(data)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env python | ||
# crc32.py -- calculate crc32 checksum of data | ||
# Copyright (C) 2016-present SheetJS | ||
from zlib import crc32 | ||
from sys import argv, stdin | ||
|
||
args=argv[1:] | ||
payload="" | ||
if len(args) == 0 or args[0] == "-": | ||
payload = stdin.read() | ||
else: | ||
payload = open(args[0],"rb").read() | ||
|
||
# NOTE: python 2 returns a signed value; python3 is unsigned | ||
print crc32(payload) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
CRC32.version = '0.4.0'; | ||
CRC32.version = '0.4.1'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.