Skip to content

Commit 0201ebc

Browse files
author
Therapon Skoteiniotis
committed
Merge branch 'development'
* development: test(test): Added unit test for the binary timestamp bugfix fix(source): Fixed the parse binary timestamp bug: added parse integer step for the seconds portion docs(debug): removed names from documentation build(debug): Debugger setup and docs
2 parents b50bc35 + f478a33 commit 0201ebc

File tree

9 files changed

+141
-5
lines changed

9 files changed

+141
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ flycheck_*.el
5656
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
5757

5858
# User-specific stuff:
59+
.idea/
5960
.idea/**/workspace.xml
6061
.idea/**/tasks.xml
6162

DEBUGGER.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
# Debugging Intern Tests
3+
4+
This is a rough guide on how to use Chrome to debug intern tests. If you know of a better way, please update.
5+
6+
## Configure Chrome
7+
8+
1. [Enable maps in Chrome](https://developers.google.com/web/tools/chrome-devtools/javascript/source-maps#enable_source_maps_in_settings)
9+
10+
## Debugging an Intern Test
11+
12+
1. add `debugger;` to set a breakpoint in your source code
13+
1. build your source code using `grunt build:amd:debug`
14+
* `build:amd:debug` generates map files for `.ts` source code that other build targets do not.
15+
1. run the test suite using `node --inspect-brk node_modules/intern/client.js config=tests/intern-debug`
16+
* note that we are using a *different* intern config file that disables code coverage
17+
1. Open Chrome and paste `chrome://inspect/#devices` in the address bar.
18+
1. Under the section titled `Remote Target` you should see
19+
```
20+
node_modules/intern/client.js file:///Users/joe/ion-js/node_modules/intern/client.js
21+
inspect
22+
```
23+
with the last word `inspect` being a link. Click on it and the debugger pops-up in a new window
24+
25+
26+
## Caveats
27+
28+
1. The `inspect` link gets refreshed every time you run `node` with `--inspect-brk`
29+
1. Source files are not always refreshed by chrome. You might have to [clear your Chrome browsers cache](https://support.google.com/accounts/answer/32050?hl=en)
30+

Gruntfile.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = function(grunt) {
2828
},
2929
},
3030
clean: ['dist/',
31-
// 'docs/', removing for now till we move to ghpages
31+
'docs/',
3232
'coverage-final.json',
3333
'browser/scripts/ion/'
3434
],
@@ -65,13 +65,24 @@ module.exports = function(grunt) {
6565
}
6666
},
6767
ts: {
68+
'amd-es6-debug': {
69+
src: ['src/**/*.ts'],
70+
outDir: 'dist/amd/es6',
71+
options: {
72+
target: "es6",
73+
module: "amd",
74+
declaration: true,
75+
sourceMap: true // generate .map files for debugging
76+
}
77+
},
78+
6879
'amd-es6': {
6980
src: ['src/**/*.ts'],
7081
outDir: 'dist/amd/es6',
7182
options: {
7283
target: "es6",
7384
module: "amd",
74-
declaration: true
85+
declaration: true,
7586
}
7687
},
7788
'commonjs-es6': {
@@ -192,6 +203,7 @@ module.exports = function(grunt) {
192203
grunt.registerTask('trans:browser', ['browserify:prod', 'uglify']); // browserify (assumes 'build' was run)
193204
grunt.registerTask('build:cjs', ['ts:commonjs-es6']);
194205
grunt.registerTask('build:amd', ['ts:amd-es6']);
206+
grunt.registerTask('build:amd:debug', ['ts:amd-es6-debug']);
195207
grunt.registerTask('build', ['clean', 'build:amd', 'build:cjs','trans:browser', 'copy:all']);
196208

197209

src/IonParserBinaryRaw.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,11 @@ function read_timestamp_value(span: Span, len: number) : Timestamp {
489489
minutes = read_var_unsigned_int(span);
490490
if (span.position() >= end) break;
491491

492-
seconds = read_decimal_value(span, end - span.position());
492+
seconds = read_var_unsigned_int(span);
493493
precision = Precision.SECONDS;
494+
if (span.position() >= end) break;
495+
496+
seconds += read_decimal_value(span, end - span.position());
494497
break;
495498
}
496499
}

tests/intern-debug.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at:
7+
*
8+
* http://aws.amazon.com/apache2.0/
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
12+
* language governing permissions and limitations under the License.
13+
*/
14+
define({
15+
defaultTimeout: 2000, // ms
16+
excludeInstrumentation: true, // disable codecoverate instrucmentation to allow debugging
17+
filterErrorStack: true,
18+
suites: [
19+
'tests/unit/textNulls',
20+
'tests/unit/spans',
21+
'tests/unit/iontests',
22+
'tests/unit/IonCatalogTest',
23+
'tests/unit/IonImportTest',
24+
'tests/unit/IonLocalSymbolTableTest',
25+
'tests/unit/IonDecimalTest',
26+
'tests/unit/IonWriteableTest',
27+
'tests/unit/IonTimestampTest',
28+
'tests/unit/IonTextTest',
29+
'tests/unit/IonTextWriterTest',
30+
'tests/unit/IonUnicodeTest',
31+
'tests/unit/IonLowLevelBinaryWriterTest',
32+
'tests/unit/IonBinaryWriterTest',
33+
'tests/unit/IonBinaryTimestampTest',
34+
],
35+
});

tests/intern.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ define({
3030
'tests/unit/IonUnicodeTest',
3131
'tests/unit/IonLowLevelBinaryWriterTest',
3232
'tests/unit/IonBinaryWriterTest',
33+
'tests/unit/IonBinaryTimestampTest',
3334
],
3435
});
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at:
7+
*
8+
* http://aws.amazon.com/apache2.0/
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
12+
* language governing permissions and limitations under the License.
13+
*/
14+
define([
15+
'intern',
16+
'intern!object',
17+
'intern/chai!assert',
18+
'dist/amd/es6/IonTests',
19+
],
20+
function(intern, registerSuite, assert, ion) {
21+
22+
var suite = {
23+
name: 'BinaryTimestamp'
24+
};
25+
26+
suite['Binary Timestamp Round Trip'] = function() {
27+
// First part - writing timestamp into binary datagram
28+
var Ion = ion;
29+
var writer = Ion.makeBinaryWriter();
30+
var timestamp = new Ion.Timestamp(5, 0, 2017, 06, 07, 18, 29, '17.901');
31+
writer.writeStruct();
32+
writer.writeFieldName('test_timestamp');
33+
writer.writeTimestamp(timestamp);
34+
writer.endContainer();
35+
writer.close();
36+
var binaryData = writer.getBytes();
37+
38+
/* Datagram content
39+
* {
40+
* test_timestamp:2017-06-07T18:29:17.901Z
41+
* }
42+
*/
43+
44+
// Second part - reading timestamp from binary datagram created above
45+
var reader = Ion.makeReader(binaryData);
46+
reader.next();
47+
reader.stepIn();
48+
reader.next();
49+
var timestampValue = reader.timestampValue();
50+
51+
assert.equal(timestamp.toString(), timestampValue.toString());
52+
}
53+
54+
registerSuite(suite);
55+
}
56+
);

tests/unit/IonBinaryWriterTest.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,6 @@ define([
516516
writer.writeFieldName('t');
517517
writer.writeTimestamp(new ion.Timestamp(ion.Precision.DAY, 0, 2000, 1, 1));
518518
writer.endContainer();
519-
debugger;
520519
},
521520
[
522521
// Symbol table

tests/unit/iontests.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ define([
110110
var reader = ion.makeReader(buffer);
111111
console.log("Exhausting " + path);
112112
if (path.endsWith('clobsWithWhitespace.ion')) {
113-
//debugger;
114113
}
115114
exhaust(reader);
116115
resolve();

0 commit comments

Comments
 (0)