Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spec code completion #5671

Merged
merged 6 commits into from Feb 14, 2020
Merged

Conversation

guillep
Copy link
Member

@guillep guillep commented Feb 13, 2020

Extend rubric and Spec to be able to set the code completion engine from the outside.

  • Code completion should be initialized lazily to the global one only.
  • Extended Code presenter and adaptor to set it in widget if available in presenter

Copy link
Contributor

@myroslavarm myroslavarm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be interesting to use this :)

@MarcusDenker
Copy link
Member

Ci shows lots of failing spec tests

@guillep
Copy link
Member Author

guillep commented Feb 13, 2020

testInstanceVersusSharedCompletionEngine

	| textEditor currentCompletion |
	[ currentCompletion := RubSmalltalkEditor completionEngineClass.
	textEditor := RubSmalltalkEditor new.
	self assert: textEditor completionEngine class equals: currentCompletion.
	
	RubSmalltalkEditor noCompletion.
	"here we show that an existing editor is not impacted by the shared behavior"
	self assert: textEditor completionEngine class equals: currentCompletion.
	textEditor := RubSmalltalkEditor new.
	self assert: textEditor completionEngine isNil.
	
	RubSmalltalkEditor completionEngineClass: CompletionEngine.
	self assert: textEditor completionEngine isNil.
	
	"but now when we create a new one it gets the correct engine"
	textEditor := RubSmalltalkEditor new.
	self assert: textEditor completionEngine class equals: CompletionEngine.
	
	
	] ensure: [ RubSmalltalkEditor completionEngineClass: currentCompletion ]

This test is breaking, but I find it super brittle...

- do not try to instantiate the completion engine if CompletionEngineClass is nil
@Ducasse
Copy link
Member

Ducasse commented Feb 13, 2020

I will ask you why you find it brittle.

@Ducasse
Copy link
Member

Ducasse commented Feb 13, 2020

Guille apparently the methods are not well categorized.

@guillep
Copy link
Member Author

guillep commented Feb 13, 2020

I will ask you why you find it brittle.

Well, I particularly do not like that the code depends on a singleton class like that.
But being more specific => I ran that code, and suddenly my system was broken. So I moved the initial state and last part of the test to setUp and tearDown like it should be. Even if the test fails, like that the test should ensure my system stays in a correct state.

Then, I find overly complex that the test does:

  • side effect 1
  • assert 1
  • side effect 2 that partially intersects with side effect 1
  • assert 1 should not be valid anymore
  • and now assert 2
    ...

I do not like that the test is a succession of side-effect dependencies with strange semantics.
Evolving that test is a pain :(. If I change side effect 1, it breaks some parts of the test, some others not, it's difficult to understand why...

Are those assert independent? Are they dependent on each other? If they are independent, why not using different tests?

@Ducasse
Copy link
Member

Ducasse commented Feb 13, 2020

Ok I understand some points. But the ensure section was not making sure that the state of the system was ok?
I mean is it better to have setup and teardown vs. ensure?

@Ducasse
Copy link
Member

Ducasse commented Feb 13, 2020

I agree with the sequence and overlapping part :)

@Ducasse
Copy link
Member

Ducasse commented Feb 13, 2020

Now I asked because I could have written such a test :)

@guillep
Copy link
Member Author

guillep commented Feb 13, 2020

I mean is it better to have setup and teardown vs. ensure?

I know you're right about that :).
I'm just a bit mad about the state of things so I over-complain ^^.

Now, the problem with this global state I think is this:

  • an exception is raised in the middle of this test
  • the execution is suspended in the middle of the block, but the ensure is not executed yet
    => otherwise you would be debugging something different from what caused the exception
  • the debugger opens, but boom => code completion is maybe in a broken state!

Just a singleton problem :)

@guillep
Copy link
Member Author

guillep commented Feb 13, 2020

Now, I added two tests that show how we can modify the code completion engine per instance. The test is not so interesting, it just shows we can ignore the global variable :).

@Ducasse
Copy link
Member

Ducasse commented Feb 14, 2020

I see I like the analysis. Indeed I did not think about the debugger before the ensure.

@Ducasse Ducasse merged commit 143ec63 into pharo-project:Pharo9.0 Feb 14, 2020
estebanlm added a commit to pharo-spec/Spec that referenced this pull request Feb 14, 2020
@guillep guillep deleted the spec-code-completion branch February 15, 2020 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants