Jump to content

Document frickin huge scripts that are not mine


BigDaddyO
 Share

Recommended Posts

This probably runs along the lines of the mystical Easy Button, but is there anything existing that will help document .au3 scripts?

we are working on a really big project that we are automating with AutoIt and have outsourced the majority of the scripting.  I'm combining all the code into a single automated process that will allow kicking off the entire regression in a scheduled fashion.

My difficulties are that running a test script by itself works fine, but when you start combining and running the individual test functions one after the other things start to get screwy and values aren't right, and all sorts of freaky stuff starts happening.

 

So, I'm wondering if there is any existing tool out there that I can run against a main script that will trace and scour a script and all #include files to build a flow, almost like a visio type flow.

What functions are called and in what order

what variables are used within a function

what of those variables are global vs local, if Global are they being updated within the function?

are there any functions that are not used

are there any functions AutoIt, UDF, and otherwise that are not being checked for a return value prior to use.  example:  they are using $MyArray[_ArraySearch()] but if the _ArraySearch fails it returns -1 which crashes the script.

 

Thanks

Link to comment
Share on other sites

Looks like you want an Astatine crystal delivered to your door 👻

Seriously I'm afraid you're on your own.

Finding such errors (or bugs or whatever you call that) would need to process the whole code to establish variants, invariants, pre- & post-conditions (all meanings taken from the original paper by Floyd http://www.cse.chalmers.se/edu/year/2017/course/TDA384_LP1/files/lectures/additional-material/AssigningMeanings1967.pdf) for every line of code AND formally find all places where the needed conditions could be violated. That AND is a big thing!

This is the same process (albeit that with Floyd it's expressed formally) that any programmer uses to mentally check that his/her code looks correct by simple line by line scrutiny (an error-prone process, as we all know).

While this would essentially solve your problems, that is a really huge task even for relatively simple code. Note that this is the exact converse of a newer and much more powerful formal method (the method B ) whith starts from formalized high level specifications, then adding more lower details until source code can be output, along with a formal (mathematical) proof that it is 100% correct w.r.t. formal specifications. The reference book about B is Assigning programs to meanings, by J. R. Abrial, but this is a hard to read text even for specialists of logic.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

5 hours ago, BigDaddyO said:

example:  they are using $MyArray[_ArraySearch()] but if the _ArraySearch fails it returns -1 which crashes the script.

..make sure each function is self sufficient with proper error returns. That if an expected value is not as such ( $aArray is not an array, etc. ) is checked for. All these will take extra .01 ms. or so, but is worth it in the long run. Tidy and that's it. 

 

5 hours ago, BigDaddyO said:

wondering if there is any existing tool out there

no clue. Don't remember seeing any.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

You could give CodeScanner a whirl (link in my sig below); it won't answer all your queries, but should help in tackling some of them.

Link to comment
Share on other sites

  • Developers
5 hours ago, AdamUL said:

You could try using Tidy with the /gd switch to generate docs for each test script.  The report is a text file, but it might be something you could work with.  

https://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/Tidy.html

I hadn't looked at it for quite a while and saw the func xref wasn't working anymore correctly, so fixed that in the current beta. There also seem to be too many variable shown in that xref at the moment and will have a look at that later, but that does indeed show you a nice xref of which Func/Variable is "defined where" and "used where". 

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers
5 hours ago, Jos said:

There also seem to be too many variable shown in that xref at the moment and will have a look at that later, but that does indeed show you a nice xref of which Func/Variable is "defined where" and "used where". 

Current Tidy Beta v19.1127.1402.2  will only list variables that start with $ or @ in the xref variable report.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 1 month later...
  • Developers
8 hours ago, Gabrielos said:

Is it possible to change which variables get listed?

Not sure what you are asking here.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I know that you have probably thought of this

- split it up,  Place all scripts in folder, prefix 05-nn...,10-nn

- To be run in order

-Run someting like Documenter on the scripts (Old probable will need updating)

    +will list all functions[line], all variables in function{line] and all unused functions and variables

Link to comment
Share on other sites

  • Developers
4 hours ago, jitb said:

+will list all functions[line], all variables in function{line] and all unused functions and variables

This yes, which is what tidy does. As to the rest: no clue what you really want there yet, but have a go I would sat. ;) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...