pillar icon indicating copy to clipboard operation
pillar copied to clipboard

BookTestGeneratorTest and ScreenshotTransformerTest should not break the first they are run.

Open Ducasse opened this issue 6 years ago • 4 comments

BookTestGeneratorTest >> testMethodCreationFailingCodeBlock ScreenshotTransformerTest >> testTransformerCreatesFile

Are apparently failing the first time they are executed

Ducasse avatar Feb 24 '20 10:02 Ducasse

Put an halt before running them the first time!

Ducasse avatar Feb 24 '20 10:02 Ducasse

I skipped testTransformerCreatesFile

Ducasse avatar Apr 30 '20 09:04 Ducasse

un and strange

When I execute the tests of booktester they pass and generate code like that in a class

test6

self assert: (('1' + 2)>>>14) isPaired

And from time to time the exact same tests generates

"protocol: #'as yet unclassified'"

test6

self assert: Error signal description: 'A code block failed'. 
"ProcessAlreadyTerminating was raised with: "
"by the codeblock: ('1' + 2)>>>14”

When I look at the process browser…. there is our friend calypso atomic update.

Ducasse avatar Apr 30 '20 09:04 Ducasse

compileMethod: aResult
	| isCorrect |
	[ (self class environment
		at: aResult fragmentedText first first trimBoth asSymbol)
		compileSilently:
			aResult fragmentedText second
				,
					'
	' , aResult fragmentedText third
		classified: 'book tester'.
	isCorrect := true ]
		on: Exception
		do: [ :ex | 
			aResult explanation: ex asString.
			isCorrect := false ].
	^ isCorrect

Seem correct

Now may be the problem is around here

createTestMethodFrom: aCodeblock
	"The test method is compiled using the following template, either it raises no exception:
	test(cbIndex)
	
		self assert: (ourAssociation) isPaired
	
	or it raises one:
	test(cbIndex)
	
		self assert: false description: [ theCodeBlock test raised the exception: (theException) ]"

	[ (self class environment at: fileName asSymbol)
		compile:
			'test' , cbIndex asString
				,
					'
	
	self assert: (' , aCodeblock textForExample withSeparatorsCompacted
				, ') isPaired'
		classified: 'Compiled ok tests' ]
		on: Exception
		do: [ :e | 

			et si tu mettais un halt ici? Ce serait intéressant de voir la stack/processus qui fait ceci

			(self class environment at: fileName asSymbol)
				compile:
					(String
						streamContents: [ :s | 
							s << 'test' << cbIndex asString.
							s
								cr;
								cr;
								tab.
							s
								<< 'self assert: Error signal description: ''A code block failed''. '.
							s
								cr;
								tab.
							s << '"' << e class name << ' was raised with: '
								<< (e messageText copyWithout: $") << '"'.
							s
								cr;
								tab.
							s << '"' << 'by the codeblock: '
								<< (aCodeblock textForExample withSeparatorsCompacted copyWithout: $")
								<< '"' ])
				classified: 'Broken book tests’ ]

Ducasse avatar Apr 30 '20 09:04 Ducasse