WALA: Errors in starting examples - javascript

I am new to wala. Trying to configure it by following steps given at wala: gettingstarted.
However, I have to face errors on each example I am trying to run. Please look at following errors:
1- Example SWTTypeHierarchy
PANIC: roots.size()=0
2- Example PDFTypeHierarchy
spawning process [C:/Program Files (x86)/Graphviz2.38/bin/dot.exe,
-Tpdf, -o, D:\WALAOut\th.pdf, -v, D:\WALAOut\temp.dt] process terminated with exit code 0 read 919 bytes from error stream
3- Js frontend com.ibm.wala.cast.js.rhino.test-JUnit
I am not able to use launcher instead when I open it following error is there
" [JRE]: Unknown JRE type specified:
org.eclipse.jdt.internal.launching.macosx.MacOSXType"
I am not sure which step went wrong which have completely damage the execution. Please help

It is hard to help you with these generic problems. I will give it a try based on the limited information these error messages contain.
1) have you configured your wala.properties file?
2) you are missing dot for this visualization. Hence the error. You may also want to use http://pages.cs.wisc.edu/~ghost/gsview/ to view your graphs.
3) seems like a problem with the location of the jre, how did you configure your properties file?
The WALA examples are great to learn from, but sometimes getting one of them to run is more time consuming, than using the slicer example in their wiki page:
http://wala.sourceforge.net/wiki/index.php/UserGuide:Slicer
This should get you started more easily.

Related

Unable to execute karate script() method

I am trying to migrate one of selenium test to karate, while doing this I am using script() method defined in documentation which is used in karate for evaluating the given string as JavaScript within the browser but I am getting this
driver.executeScript("sauce:job-result=passed");
Also Sharing my feature file which getting failed:
Also Even I tried calling below statement in my script but still getting the same error
* script("console.log('hello world')")
I am using testImplementation("com.intuit.karate:karate-core:1.2.0.RC1") version with gatling
First - try version 1.2.0.RC6 that has some fixes for the console.log() issue.
I also must say that sauce:job-result=passed does not look like valid JavaScript to me. Please take some time to read the docs: https://github.com/karatelabs/karate/tree/master/karate-core#karate-vs-the-browser
If still stuck, follow this process. That is the only way to replicate and for us to determine what fixes we need to make (if any): https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue
See this answer for ideas on how to troubleshoot things at your end: https://stackoverflow.com/a/71952132/143475

Direct disk access using Node.js

I want to create Node.js module which provides direct disk access on Windows. It must be able to read, write and search physical drive or virtual device. Because built-in module fs depends on native code written in C++ which uses system function CreateFile which supports \\.\PhysicalDriveX string as an argument to gain access to physical drive, I've tried to do the same in Node.js. My code works fine, application successfully opens disk for read and write access, but there are problems with read and write commands.
When I want to read whole sector, or multiple sectors from disk, it works and displays bytes correctly. But, when I try to read half of a sector or a few bytes, it displays error:
Error: EINVAL: invalid argument, read
at Error (native)
at Object.fs.readSync (fs.js:731:19)
It was not an unsolvable problem to me. I've improved my read function, so it extends buffer to match ceiled requested sector size (i.e. if it needs to read disk from half of the first sector to half of the third sector, it will read whole first, second and third sector and then it will slice the buffer). In order to make it easier to use, I fixed the size of my buffer to 512 bytes, so the only argument of my read and write functions are sector number from which data will be read to buffer or in which data will be written from buffer. Function read works properly and I can get bytes from any sector of the drive.
The real problem is my write function. It can write data only to the first sector. If I try to write data to any other sector expect the first one, I get the following error:
Error: EPERM: operation not permitted, write
at Error (native)
at Object.fs.writeSync (fs.js:786:20)
I tried everything to get rid of this problem, but I coldn't. I tried to change drive, to change buffer size (extend it to cluster size instead of sector size), to use fs.write instead of fs.writeSync, I also tried to search online for solution, but I coldn't find an answer. In order to find out why it doesn't work, I debugged my program using built-in Node.js debugger. I found out that the thread suddenly jumps from fs.readSync to Error function without any reasonable explanation and the process terminates.
How can I properly use fs.writeSync function to write any sector to a physical drive? Am I doing something wrong, or there is a problem with Node.js?
We released a native add on for Node.js yesterday with helpers and documentation for doing direct IO on Node.js (cross-platform):
https://github.com/ronomon/direct-io
I think in your case you might need to look into special write restrictions on Windows (and the need for FSCTL_LOCK_VOLUME so that you can write to all sectors and not just the master boot record).
You also need aligned buffers.
The module will help you with both of these requirements.

Get code of specific line in Javascript file

When catching an error, I want to get with the stack trace the actual code of the line that triggered the error.
Given that I have the path to the file and the line number throwing the error, what's the best way to also get the actual code of that line?
Beyond the obvious of "looking it up in the file", there are a few things you can do to get it automatically. Checkout the Tracekit project on GitHub. For errors it captures, it will do an AJAX request for the script and find the relevant lines in the text.
Alternatively, if you're looking for a way to handle this automatically, you should consider a service like TrackJS that will capture all the relevant scripts and apply sourcemaps for you. I am one of the original developers and I've used it on many projects to fix bugs ridiculously fast :)

How to find the location of an error when line numbers cannot be used

I am finding it difficult to locate where an error occurs in javascript on a client I have no access to. Currently I trap the error with onerror and send the arguments to a log on the server.
Unfortunately the line number is no help because numerous javascript files get included, causing the line number to not correspond to anything I have access to.
So if I get something like "n is not defined", and n occurs many times in the function, I have no way to locate where it happened.
I have been trying to reference the code on the line throwing the error say "x=n * 5 + 4", then I could search for that code, but have had no luck referencing the actual code on a line from within javascript.
So how does one locate the line that threw the error in this situation?
client uses firefox only, if that matters.
I have no access to client
This is not one error I am stuck on, but working on how to track an error in this situation
Your best bet would be to use Firefox's debugger.
Open dev tools
Go to the debugger, select the .js file you want, and hit the little {} button in the bottom left (depending on version yours may be in a different location) -- this will prettify the JavaScript
Set breakpoints by clicking next to line numbers
From here on out you have to do this old-fashioned. Cast a breakpoint net around your trouble code, then keep narrowing down the lines until you find the occurrence that causes the error.
Of course, once you find the line it still won't be 1-to-1 with the original code, but hopefully the breakpoint exercise will at least reduce the scope of code/logic you have to dig through.
use your debugger to enable breaking on error. once you break, look at your locals for clues about your location. go up the stack and look at each frame.
you should be able to trace n up the stack and find out why it was null
the little {} that william suggested is also helpful

Test parse errors in intern do not include the line that describes the error

tl;dr When there is an error with a test written in intern I don't seem to get error messages that describe on which line the error occurred. I've found a workaround but its not really the ideal solution as it involves messing with code in dependent projects. Does any one have a better way / am I just doing it wrong? Thanks!
Details :
I've seen several times that when there is an issue with parsing a test written in intern (for example failing to close brackets, quotes etc.) that the actual line where the error occurred is not reported, and there is only an error like this (I've subbed in for the actual path as its a work project, but you get the gist):
SyntaxError: Unexpected identifier
at Function.vm.runInThisContext (<myproject>/node_modules/intern/node_modules/istanbul/lib/hook.js:163:16)
at <myproject>/node_modules/intern/node_modules/dojo/dojo.js:745:8
at fs.js:266:14
at Object.oncomplete (fs.js:107:15)
I poked around a little and discovered that there's an undocumented(? - its not in here) parameter for vm.runInThisContext, which if enabled actually provides details of the original error (here and here) - there's some discussion about how this will play out but if I switch dojo.js and hook.js in istanbul (if its running) to use this parameter, I get error messages like this :
<myproject>/test/publisherConfigSpec.js:16
errorCb cat = dfd.rejectOnError(function(error) {
^^^
SyntaxError: Unexpected identifier
at Function.vm.runInThisContext (<myproject>/node_modules/intern/node_modules/istanbul/lib/hook.js:163:16)
at <myproject>/node_modules/intern/node_modules/dojo/dojo.js:745:8
at fs.js:266:14
at Object.oncomplete (fs.js:107:15)
which is the output I want (or at least massively improves my chances of finding and fixing the error) but its not ideal to be messing about with the node dependencies, and it seems to me that it may be too much in flux for a pull request (see most recent update to the API) Is there an alternative way of getting useful output when there's an error parsing the test code input?
Thanks for any advice :)
The output that Node.js provides for SyntaxError is obviously not great, but we probably won’t use undocumented features (they’re undocumented for a reason!) in any official release of Intern to make it work differently. Non-syntax errors (runtime errors) will be caught and reported competently by Intern to whatever reporters you are using.
In this case, I’d advise you to use an editor that includes support for syntax checking: Komodo Edit/IDE, WebStorm, SublimeText, Eclipse, vim… if you get to the point where you are trying to run syntactically invalid code, your code editor is failing you by not telling you soon enough that you’ve made a mistake.

Categories

Resources