From 3eed60494ecff6c32ce1d34f3ea8b6b6f8536bf5 Mon Sep 17 00:00:00 2001 From: Julien Delplanque Date: Mon, 30 Sep 2019 13:29:22 +0200 Subject: [PATCH 1/8] Updated title. --- documentation/DevelopmentGuide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/DevelopmentGuide.md b/documentation/DevelopmentGuide.md index 8a24f09..f010efd 100644 --- a/documentation/DevelopmentGuide.md +++ b/documentation/DevelopmentGuide.md @@ -7,7 +7,7 @@ A first part will cover the design of the project and a second part will be a tu - [Developer documentation](#developer-documentation) * [Design](#design) * [TinyCurrentLogger dynamic variable](#tinycurrentlogger-dynamic-variable) - * [Add a new leaf transcript](#add-a-new-leaf-transcript) + * [Add a new leaf logger](#add-a-new-leaf-logger) ## Design @@ -28,7 +28,7 @@ To record logs, the user will use extension methods implemented on `Object` as The `TinyCurrentLogger` has a default value that is the default instance of `TinyLogger`. This value can be changed using the `value:during:` message as explained in the user documentation. -## Add a new leaf transcript +## Add a new leaf logger In this section we will add a new leaf logger recording logs in a remote server via a HTTP request on a REST API. From 1df8fbf9f5565f4a43c72149bcb2400eae37c479 Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Fri, 8 Nov 2019 14:07:10 +0100 Subject: [PATCH 2/8] Ignore isAbstract methods for coverage. --- src/TinyLogger/TinyAbstractLogger.class.st | 1 + src/TinyLogger/TinyLeafLogger.class.st | 1 + 2 files changed, 2 insertions(+) diff --git a/src/TinyLogger/TinyAbstractLogger.class.st b/src/TinyLogger/TinyAbstractLogger.class.st index 52f318f..699a710 100644 --- a/src/TinyLogger/TinyAbstractLogger.class.st +++ b/src/TinyLogger/TinyAbstractLogger.class.st @@ -26,6 +26,7 @@ Class { { #category : #testing } TinyAbstractLogger class >> isAbstract [ + ^ self = TinyAbstractLogger ] diff --git a/src/TinyLogger/TinyLeafLogger.class.st b/src/TinyLogger/TinyLeafLogger.class.st index a4e9c28..d3bff1a 100644 --- a/src/TinyLogger/TinyLeafLogger.class.st +++ b/src/TinyLogger/TinyLeafLogger.class.st @@ -37,6 +37,7 @@ TinyLeafLogger class >> for: aTinyLogger [ { #category : #testing } TinyLeafLogger class >> isAbstract [ + ^ self = TinyLeafLogger ] From 62a82e8e22302712e65d58590e37a2ebadd847ec Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Fri, 8 Nov 2019 14:08:01 +0100 Subject: [PATCH 3/8] Remove false positives to lints. Those are to week to renamings. --- src/TinyLogger/ManifestTinyLogger.class.st | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/TinyLogger/ManifestTinyLogger.class.st b/src/TinyLogger/ManifestTinyLogger.class.st index 5b987a6..dcc7689 100644 --- a/src/TinyLogger/ManifestTinyLogger.class.st +++ b/src/TinyLogger/ManifestTinyLogger.class.st @@ -13,13 +13,3 @@ Class { #superclass : #PackageManifest, #category : #'TinyLogger-Manifest' } - -{ #category : #'code-critics' } -ManifestTinyLogger class >> ruleRBCodeCruftLeftInMethodsRuleV1FalsePositive [ - ^ #(#(#(#RGClassDefinition #(#TinyTranscriptLogger)) #'2018-11-25T02:59:41.364573+01:00') ) -] - -{ #category : #'code-critics' } -ManifestTinyLogger class >> ruleRBCollectionMessagesToExternalObjectRuleV1FalsePositive [ - ^ #(#(#(#RGMethodDefinition #(#TinyLogger #addLogger: #false)) #'2018-11-25T20:54:01.067573+01:00') #(#(#RGMethodDefinition #(#TinyLogger #removeLogger: #false)) #'2018-11-25T20:54:59.231573+01:00') ) -] From cfeeecb775f0ae7d3125602d19060e9cd6a97184 Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Fri, 8 Nov 2019 14:58:26 +0100 Subject: [PATCH 4/8] Improve test coverage. Fixes #32 --- src/TinyLogger-Tests/TinyLoggerTest.class.st | 27 ++++++++++++++++++++ src/TinyLogger/TinyAbstractLogger.class.st | 1 + src/TinyLogger/TinyFileLogger.class.st | 3 ++- src/TinyLogger/TinyLeafLogger.class.st | 2 +- src/TinyLogger/TinyLogger.class.st | 2 +- src/TinyLogger/TinyStdoutLogger.class.st | 1 + src/TinyLogger/TinyTranscriptLogger.class.st | 1 + 7 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/TinyLogger-Tests/TinyLoggerTest.class.st b/src/TinyLogger-Tests/TinyLoggerTest.class.st index 1ab1c1c..126f6cd 100644 --- a/src/TinyLogger-Tests/TinyLoggerTest.class.st +++ b/src/TinyLogger-Tests/TinyLoggerTest.class.st @@ -90,6 +90,12 @@ TinyLoggerTest >> testClearLog [ self assert: (logger fileLoggers noneSatisfy: [ :fileLogger | fileLogger fileReference exists ]) ] +{ #category : #test } +TinyLoggerTest >> testCurrentLogger [ + self assert: TinyCurrentLogger value isNotNil. + self assert: TinyCurrentLogger value class equals: TinyLogger +] + { #category : #test } TinyLoggerTest >> testEnsureFileLogger [ logger removeAllLoggers. @@ -160,6 +166,27 @@ TinyLoggerTest >> testExecuteRecordedAs [ stream close ] ] +{ #category : #test } +TinyLoggerTest >> testExecuteRecordedAs2 [ + | contents stream | + self skipInPharo6. + logger + timestampFormatBlock: [ :s | s nextPutAll: 'No time' ]; + removeAllLoggers; + addStdoutLogger. + stream := '' writeStream. + [ Stdio stub stdout willReturn: stream. + TinyCurrentLogger value: logger during: [ Object new execute: [ 'test' record ] recordedAs: 'This is a new test' ]. + contents := Stdio stdout contents asString. + + "Ensure we have the right indentation." + self assert: (contents includesSubstring: 'No time : Begin: This is a new test +No time : test +No time : End: This is a new test') ] + ensure: [ Stdio recoverFromGHMutation. + stream close ] +] + { #category : #test } TinyLoggerTest >> testFileLoggers [ logger diff --git a/src/TinyLogger/TinyAbstractLogger.class.st b/src/TinyLogger/TinyAbstractLogger.class.st index 699a710..38945bf 100644 --- a/src/TinyLogger/TinyAbstractLogger.class.st +++ b/src/TinyLogger/TinyAbstractLogger.class.st @@ -49,5 +49,6 @@ TinyAbstractLogger >> record: aString [ { #category : #accessing } TinyAbstractLogger >> timestampFormatBlock [ + ^ self subclassResponsibility ] diff --git a/src/TinyLogger/TinyFileLogger.class.st b/src/TinyLogger/TinyFileLogger.class.st index 4a49aeb..55b7391 100644 --- a/src/TinyLogger/TinyFileLogger.class.st +++ b/src/TinyLogger/TinyFileLogger.class.st @@ -45,6 +45,7 @@ TinyFileLogger class >> for: aLogger named: aString [ { #category : #accessing } TinyFileLogger class >> kind [ + ^ 'file' ] @@ -84,7 +85,7 @@ TinyFileLogger >> fileReference [ TinyFileLogger >> fileStreamDo: aBlock [ "For now we re-open the file all the time to avoid problems when we change its image of computer/OS or if the user delete the file. Maybe later we can find a better solution but in any case we should test such weird behaviors." - ^ self fileReference + self fileReference ensureCreateFile; writeStreamDo: [ :s | s setToEnd. diff --git a/src/TinyLogger/TinyLeafLogger.class.st b/src/TinyLogger/TinyLeafLogger.class.st index d3bff1a..bec0fe7 100644 --- a/src/TinyLogger/TinyLeafLogger.class.st +++ b/src/TinyLogger/TinyLeafLogger.class.st @@ -43,6 +43,7 @@ TinyLeafLogger class >> isAbstract [ { #category : #accessing } TinyLeafLogger class >> kind [ + ^ self subclassResponsibility ] @@ -68,7 +69,6 @@ TinyLeafLogger >> parentLogger [ { #category : #accessing } TinyLeafLogger >> parentLogger: aLogger [ - parentLogger == aLogger ifTrue: [ ^ self ]. parentLogger := aLogger ] diff --git a/src/TinyLogger/TinyLogger.class.st b/src/TinyLogger/TinyLogger.class.st index f8266d1..6595fc2 100644 --- a/src/TinyLogger/TinyLogger.class.st +++ b/src/TinyLogger/TinyLogger.class.st @@ -98,7 +98,7 @@ TinyLogger class >> default: anObject [ { #category : #initialization } TinyLogger class >> reset [ - ^ self default: nil + self default: nil ] { #category : #'public API' } diff --git a/src/TinyLogger/TinyStdoutLogger.class.st b/src/TinyLogger/TinyStdoutLogger.class.st index ddf6ebb..e9b893a 100644 --- a/src/TinyLogger/TinyStdoutLogger.class.st +++ b/src/TinyLogger/TinyStdoutLogger.class.st @@ -22,6 +22,7 @@ Class { { #category : #accessing } TinyStdoutLogger class >> kind [ + ^ 'stdout' ] diff --git a/src/TinyLogger/TinyTranscriptLogger.class.st b/src/TinyLogger/TinyTranscriptLogger.class.st index 3f94a60..afd34ef 100644 --- a/src/TinyLogger/TinyTranscriptLogger.class.st +++ b/src/TinyLogger/TinyTranscriptLogger.class.st @@ -19,6 +19,7 @@ Class { { #category : #accessing } TinyTranscriptLogger class >> kind [ + ^ 'transcript' ] From 47be50104a7d0d4368f9b2182ecca20fa55e69d1 Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Fri, 8 Nov 2019 15:02:04 +0100 Subject: [PATCH 5/8] Fix test --- src/TinyLogger-Tests/TinyLoggerTest.class.st | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/TinyLogger-Tests/TinyLoggerTest.class.st b/src/TinyLogger-Tests/TinyLoggerTest.class.st index 126f6cd..2a009a0 100644 --- a/src/TinyLogger-Tests/TinyLoggerTest.class.st +++ b/src/TinyLogger-Tests/TinyLoggerTest.class.st @@ -180,9 +180,13 @@ TinyLoggerTest >> testExecuteRecordedAs2 [ contents := Stdio stdout contents asString. "Ensure we have the right indentation." - self assert: (contents includesSubstring: 'No time : Begin: This is a new test + self + assert: contents withInternalLineEndings + equals: + 'No time : Begin: This is a new test No time : test -No time : End: This is a new test') ] +No time : End: This is a new test +' withInternalLineEndings ] ensure: [ Stdio recoverFromGHMutation. stream close ] ] From f514bc6df71886eda9bc974042fd8bbb700b8a0a Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Fri, 8 Nov 2019 15:04:20 +0100 Subject: [PATCH 6/8] =?UTF-8?q?Add=20script=20+=20ignore=20OSX=C2=A0Files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ scripts/mutationTesting.st | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 scripts/mutationTesting.st diff --git a/.gitignore b/.gitignore index 943995e..be1ab9b 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ SqueakDebug.log # Metacello-github cache /github-cache github-*.zip + +**/.DS_STORE \ No newline at end of file diff --git a/scripts/mutationTesting.st b/scripts/mutationTesting.st new file mode 100644 index 0000000..95cdc38 --- /dev/null +++ b/scripts/mutationTesting.st @@ -0,0 +1,26 @@ +Metacello new + githubUser: 'jecisc' project: 'TinyLogger' commitish: 'v1.x.x' path: 'src'; + baseline: 'TinyLogger'; + load. + +Metacello new + baseline: 'MuTalk'; + repository: 'github://pavel-krivanek/mutalk/src'; + load. + +analysis := MutationTestingAnalysis + testCasesFrom: 'TinyLogger-Tests' asPackage definedClasses + mutating: 'TinyLogger' asPackage definedClasses + using: MutantOperator contents + with: AllTestsMethodsRunningMutantEvaluationStrategy new. +analysis run. +alive := analysis generalResult aliveMutants. + +browser := GLMTabulator new. +browser + row: #results; + row: #diff. +browser transmit to: #results. +browser transmit to: #diff; from: #results; andShow: [ :a | + a diff display: [ :mutant | {((RBParser parseMethod: (mutant mutant originalSource)) formattedCode) . ((RBParser parseMethod: (mutant mutant modifiedSource)) formattedCode)}] ]. +browser openOn: alive. \ No newline at end of file From b30fb32fbad2260fff953d69044488ed3ec0a031 Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Fri, 8 Nov 2019 15:07:37 +0100 Subject: [PATCH 7/8] Use method working in Pharo 7 --- src/TinyLogger-Tests/TinyLoggerTest.class.st | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TinyLogger-Tests/TinyLoggerTest.class.st b/src/TinyLogger-Tests/TinyLoggerTest.class.st index 2a009a0..21ef3ff 100644 --- a/src/TinyLogger-Tests/TinyLoggerTest.class.st +++ b/src/TinyLogger-Tests/TinyLoggerTest.class.st @@ -181,12 +181,12 @@ TinyLoggerTest >> testExecuteRecordedAs2 [ "Ensure we have the right indentation." self - assert: contents withInternalLineEndings + assert: contents withUnixLineEndings equals: 'No time : Begin: This is a new test No time : test No time : End: This is a new test -' withInternalLineEndings ] +' withUnixLineEndings ] ensure: [ Stdio recoverFromGHMutation. stream close ] ] From ffedaad186424877dbccbb255bcaa07aac753c95 Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Fri, 8 Nov 2019 15:14:57 +0100 Subject: [PATCH 8/8] v1.1.3 --- CHANGELOG.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 029734b..08a66df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,15 @@ - +# [v1.1.3](https://github.com/jecisc/TinyLogger/compare/v1.1.2...v1.1.3) (2019-11-08) + +## Infrastructure + +* Improve test coverage using MuTalk (mutation testing) ([716cd41](https://github.com/jecisc/TinyLogger/commit/716cd41655614326b4e20a426bdb58ce5f0f2031)) +* Fix a title in the documentation ([1d6af61](https://github.com/jecisc/TinyLogger/commit/1d6af61b6114533ab20ef3ffaad252f95925d3a8)) + # [v1.1.2](https://github.com/jecisc/TinyLogger/compare/v1.1.1...v1.1.2) (2019-09-25) ## Infrastructure @@ -10,11 +18,11 @@ # [v1.1.1](https://github.com/jecisc/TinyLogger/compare/v1.1.0...v1.1.1) (2019-09-18) -# Bug fixes +## Bug fixes * Do not depend on whole Mocketry ([a50d354](https://github.com/jecisc/TinyLogger/commit/a50d3543bf00e76d780d7d3f2fb205280364b637)) -# Infrastructure +## Infrastructure * Deprecated method in Pharo 8 ([7f2ab1c](https://github.com/jecisc/TinyLogger/commit/7f2ab1c7a6fc43d23801faed40383e2b6d4279c3))