Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 485282

Summary: [tern] Tests can get the wrong results due to other tests putting contents in the global scope
Product: [ECD] Orion Reporter: Curtis Windatt <curtis.windatt.public>
Component: JS ToolsAssignee: Curtis Windatt <curtis.windatt.public>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Michael_Rennie, steve_northover
Version: 10.0   
Target Milestone: 11.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Curtis Windatt CLA 2016-01-06 11:24:10 EST
This was surfaced by me adding new quickfix tests (Bug 485179).  All of the tests are running in the same Tern server.  The tests are pretty good about reusing the same file name, and deleting the contents of that file during setup.  However, the last test in each suite will leave its contents in that file.

If the contents of that file puts something in the global scope, Tern still knows about it during other test suites and can give different results.

In my case, the quick fix all test was putting "var a=1;" into quick_fix_tests.js.  Later in the Tern Commands tests we are looking for the declaration of variable 'a'.  While there is a declaration in the current file, Tern chooses the one in the global scope from quick_fix_tests.js.
Comment 1 Curtis Windatt CLA 2016-01-06 11:29:56 EST
Steve noticed this behaviour before in the editor where he had multiple files in the workspace with global scope contents and Tern would choose one.

Options exist to fix this:
1) Make sure we remove the file from Tern during after() rather than during test setup.
2) Reset the tern server entirely to remove all files before() each suite
3) Modify the tests to pass
Comment 2 Curtis Windatt CLA 2016-01-06 12:49:28 EST
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=e07107573723ebdffac71248772d015455cf3125
Fixes the calls to start/reset the server in the testing worker.

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=57a15a69f1ced12bf959d0bf2428885b879d68fd
Adds a server.start call to every test suite that actually uses the worker.

I did not see any performance issues from this change.