Browse Source

Updated demo-js output to only include sentry frames

Armin Ronacher 7 years ago
parent
commit
ba04e06672

+ 1 - 0
.eslintignore

@@ -1,4 +1,5 @@
 **/dist/**/*
 **/vendor/**/*
 **/tests/sentry/lang/javascript/fixtures/**/*
+**/tests/sentry/lang/javascript/example-project/**/*
 /examples/

+ 6 - 3
src/sentry/lint/engine.py

@@ -45,8 +45,8 @@ def get_files(path):
 def get_modified_files(path):
     return [
         s
-        for s in check_output(['git', 'diff-index', '--cached', '--name-only', 'HEAD'])
-        .split('\n') if s
+        for s in check_output(['git', 'diff-index', '--cached', '--name-only', 'HEAD']).split('\n')
+        if s
     ]
 
 
@@ -68,7 +68,6 @@ def get_js_files(file_list=None):
     if file_list is None:
         file_list = ['tests/js', 'src/sentry/static/sentry/app']
     return [x for x in get_files_for_list(file_list) if x.endswith(('.js', '.jsx'))]
-    return file_list
 
 
 def get_python_files(file_list=None):
@@ -178,6 +177,10 @@ def js_format(file_list=None):
         return False
 
     js_file_list = get_js_files(file_list)
+
+    # manually exclude some bad files
+    js_file_list = [x for x in js_file_list if '/javascript/example-project/' not in x]
+
     return run_formatter(
         [
             prettier_path, '--write', '--single-quote', '--bracket-spacing=false',

+ 1 - 0
tests/sentry/lang/javascript/example-project/.gitignore

@@ -0,0 +1 @@
+node_modules

+ 12 - 0
tests/sentry/lang/javascript/example-project/Makefile

@@ -0,0 +1,12 @@
+all: update
+
+install:
+	yarn install
+
+minify: install
+	./node_modules/.bin/uglifyjs --mangle --wrap test --source-map test.map --source-map-include-sources --prefix relative --output test.min.js test.js
+
+update: minify
+	node triggerError.js
+
+.PHONY: all install minify update

+ 1 - 0
tests/sentry/lang/javascript/example-project/minifiedError.json

@@ -0,0 +1 @@
+[]

+ 23 - 0
tests/sentry/lang/javascript/example-project/normalError.json

@@ -0,0 +1,23 @@
+[
+  {
+    "abs_path": "http://example.com/static/test.js",
+    "filename": "test.js",
+    "function": "onFailure",
+    "lineno": 4,
+    "colno": 9
+  },
+  {
+    "abs_path": "http://example.com/static/test.js",
+    "filename": "test.js",
+    "function": "invoke",
+    "lineno": 14,
+    "colno": 3
+  },
+  {
+    "abs_path": "http://example.com/static/test.js",
+    "filename": "test.js",
+    "function": "test",
+    "lineno": 19,
+    "colno": 3
+  }
+]

+ 6 - 0
tests/sentry/lang/javascript/example-project/package.json

@@ -0,0 +1,6 @@
+{
+  "dependencies": {
+    "stacktrace-js": "^2.0.0",
+    "uglify": "^0.1.5"
+  }
+}

+ 22 - 0
tests/sentry/lang/javascript/example-project/test.js

@@ -0,0 +1,22 @@
+function onSuccess(data) {}
+
+function onFailure(data) {
+  throw new Error('failed!');
+}
+
+function invoke(data) {
+  var cb = null;
+  if (data.failed) {
+    cb = onFailure;
+  } else {
+    cb = onSuccess;
+  }
+  cb(data);
+}
+
+function test() {
+  var data = {failed: true, value: 42};
+  invoke(data);
+}
+
+module.exports = test;

+ 1 - 0
tests/sentry/lang/javascript/example-project/test.map

@@ -0,0 +1 @@
+{"version":3,"file":"test.min.js","sources":["?","test.js"],"names":["exports","global","onSuccess","data","onFailure","Error","invoke","cb","failed","test","value","module","this"],"mappings":"CAAC,SAASA,EAASC,GAASA,EAAO,QAAUD,CCA7C,SAASE,GAAUC,IAEnB,QAASC,GAAUD,GACjB,KAAM,IAAIE,OAAM,WAGlB,QAASC,GAAOH,GACd,GAAII,GAAK,IACT,IAAIJ,EAAKK,OAAQ,CACfD,EAAKH,MACA,CACLG,EAAKL,EAEPK,EAAGJ,GAGL,QAASM,KACP,GAAIN,IAAQK,OAAQ,KAAME,MAAO,GACjCJ,GAAOH,GAGTQ,OAAOX,QAAUS,ODrBiE,WAAW,MAAOG","sourcesContent":[null,"function onSuccess(data) {}\n\nfunction onFailure(data) {\n  throw new Error('failed!');\n}\n\nfunction invoke(data) {\n  var cb = null;\n  if (data.failed) {\n    cb = onFailure;\n  } else {\n    cb = onSuccess;\n  }\n  cb(data);\n}\n\nfunction test() {\n  var data = {failed: true, value: 42};\n  invoke(data);\n}\n\nmodule.exports = test;\n"]}

+ 2 - 0
tests/sentry/lang/javascript/example-project/test.min.js

@@ -0,0 +1,2 @@
+(function(n,t){t["test"]=n;function e(n){}function i(n){throw new Error("failed!")}function u(n){var t=null;if(n.failed){t=i}else{t=e}t(n)}function f(){var n={failed:true,value:42};u(n)}module.exports=f})({},function(){return this}());
+//# sourceMappingURL=test.map

Some files were not shown because too many files changed in this diff