AppleScript is now deliberately annoying me to death
AppleScript is now deliberately annoying me to death
- Subject: AppleScript is now deliberately annoying me to death
- From: has <email@hidden>
- Date: Thu, 03 Mar 2016 18:43:07 +0000
Hey folks,
I swear, one of us is insane and I could use 5-minutes' help to
determine if it's me or AS. I've just checked in a minor revision to the
AS libraries I've been working on. The changes themselves are nothing
interesting - just me adding tests and making bugfixes - but something
that has been driving me up the wall recently is that every now and
again a unittest script suddenly and repeatedly quits part way through
running tests with bizarre, nonsensical errors like this:
1.2 ParseFormatNumber's formatNumber_realDecimal: " number 1011
from «script "TestTools"»
Given the whole point of a unit testing framework is NOT to fall over
unexpectedly with unknown errors when run, this is a bit of a problem,
and part of the reason it's taking me forever to get this stuff done and
dusted and off my hands and [hopefully] into Apple's.
What makes me think it's really AS, not me, that is completely nuts is
that it never (normally) fails when running the tests directly in
Terminal, only when running them in Script Editor (or via `osascript`
for comparison). The only real difference is that Terminal runs the
`osatest` executable directly, whereas SE/osascript runs it via `do
shell script`. What's even more surreal is that the error goes away as
soon as even a minor edit (e.g. just adding a comment) is made to the
test script; then after making some more edits a new nonsensical error
will appear just to keep life interesting.
I've spent as much time chasing this nonsense down in TestTools as using
it to test and debug the actual libraries and I'm more than a little
honked off. To be clear, the error is not coming from `osatest` nor the
unittest script itself (I've checked); it seems to be coming from
somewhere deep down in the AppleScript component itself. I would
appreciate if some of you good folks who are also on 10.11 (which is
what `osatest` is currently built for) could grab this particular
revision (5eb49c5) from GitHub and see if you can replicate it too:
https://github.com/hhas/applescript-stdlib
I probably won't check in any more changes this week, so you could just
go download the ZIP if you don't want to muck about with `git` itself.
Once you've got it, drop all the libraries and the unittests folder into
`~/Library/Script Libraries`. Open the `Date.unittest.scpt` file in the
unittests folder in Script Editor and try running it. That particular
script is currently working fine OMM (plus all its tests are passing,
yay!), so it should return report text ending in "Result: 7 tests
passed, 0 failed, 0 broken, 0 skipped." To run the same test in
Terminal, run the following command (all one line):
~/Library/Script\
Libraries/TestTools.scptd/Contents/Resources/bin/osatest
~/Library/Script\ Libraries/unittests/Date.unittest.scpt
Assuming that all works right (which it should), next open the
`Number.unittest.scpt` in Script Editor and run that and see if it runs
to completion or fails with an error like this:
error "TestTools library can’t run unit tests: osatest
'/Users/has/Library/Script Libraries/unittests/Number.unittest.scpt'
Begin tests at 2016-03-03 18:27:53 +0000
1.1 ParseFormatNumber's formatNumber_integer: OK (performed 5
assertions)
1.2 ParseFormatNumber's formatNumber_realDecimal: " number 1011
from «script "TestTools"»
Then try it in Terminal too:
~/Library/Script\
Libraries/TestTools.scptd/Contents/Resources/bin/osatest
~/Library/Script\ Libraries/unittests/Number.unittest.scpt
*Normally* it runs fine in Terminal even when failing in SE, but this
particular random revision's a real peach and most unusually gives me
the following:
osatest '/Users/has/Library/Script
Libraries/unittests/Number.unittest.scpt'
Begin tests at 2016-03-03 18:26:44 +0000
1.1 ParseFormatNumber's formatNumber_integer: OK (performed 5
assertions)
1.2 ParseFormatNumber's formatNumber_realDecimal: Segmentation
fault: 11
Once you've done that, open `Number.unittest.scpt` in SE again and add
the following comment to the top of the file:
-- You don't have to be crazy to use AppleScript, oh wait...
Save and run it once more, and see if it works now (it does OMM).
Assuming you and your computer are still sane and sentient afterward,
please post back here and let me know how it went. I may be cracked, but
it'd be nice to know it's not me who's downright broken.
Many thanks,
has
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden