Unable to disable extern indentation with clang-format - c++

I'm not sure if this is a limitation or bug with clang-format (built from source, clang-format version 12.0.0 (git#github.com:llvm/llvm-project.git d4ce062340064c3f73b8f6136c7350a5abe83cac)), but I am unable to disable indentation after extern "C" {.
My current .clang-format:
Language: Cpp
Standard: Latest
UseTab: Never
IndentWidth: 4
AccessModifierOffset: -2
SpaceBeforeParens: Never
ColumnLimit: 80
SpacesBeforeTrailingComments: 1
BreakBeforeBraces: Allman
FixNamespaceComments: true
SortIncludes: true
SortUsingDeclarations: true
IncludeBlocks: Regroup
IndentPPDirectives: AfterHash
IndentCaseLabels: true
IndentExternBlock: NoIndent
NamespaceIndentation: All
AlignTrailingComments: true
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignConsecutiveBitFields: true
AlignConsecutiveMacros: true
AlignAfterOpenBracket: AlwaysBreak
AllowShortFunctionsOnASingleLine: None
AllowShortBlocksOnASingleLine: Never
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortLambdasOnASingleLine: None
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
PenaltyBreakBeforeFirstCallParameter: 500 # basically always break
# Note: must have my custom build (https://github.com/jasperswallen/llvm-project/tree/pointeralignment-right) to properly enable these options
BreakBeforeConceptDeclarations: true
PointerAlignment: Right
This example file is the "formatted" result:
#ifdef __cplusplus
extern "C"
{
#endif
void example(void);
#ifdef __cplusplus
}
#endif
but I want something like:
#ifdef __cplusplus
extern "C"
{
#endif
void example(void);
#ifdef __cplusplus
}
#endif
It seems like IndentExternBlock: NoIndent should be the correct option to force this, but it's still indenting even with that set.
Is it possible that BreakBeforeBraces: Allman is overriding this setting? I assumed that IndentExternBlock would override braces unless set to AfterExternBlock.

This is a bug 37272, but there is just a little chance that it will be fixed because this option (IndentExternBlock) was forced by expand preset function. Please review the following problematic commit.
We can see that llvm developers broke config inheritance and nobody cares about a year. It means that we have to fix config inheritance in a way that won't depend on llvm developers. Please review the following solution:
scripts/clang/config-format/config-source.yml
Language: Cpp
BreakBeforeBraces: Allman
scripts/clang/config-format/config-updates.yml
BraceWrapping:
AfterExternBlock: false
BreakBeforeBraces: Custom
IndentExternBlock: false
scripts/clang/config-format/update.sh
#!/bin/bash
set -e
DIR=$(dirname "${BASH_SOURCE[0]}")
cd "$DIR"
SOURCE="config-source.yml"
UPDATES="config-updates.yml"
DESTINATION="../../../.clang-format"
echo "# This file has been auto generated, please don't edit directly." \
> "$DESTINATION"
SOURCE_STYLE=$(yq -cs ".[0]" < "$SOURCE")
clang-format -style="$SOURCE_STYLE" --dump-config | \
yq -sy ".[0] * .[1]" - "$UPDATES" >> "$DESTINATION"
Please install yq. After running ./scripts/clang/config-format/update.sh you will receive proper .clang-config for your requirements.

Related

Clang-tidy change check options for clang-analyzer-optin.cplusplus.UninitializedObject

I am trying to change the Pedantic option in clang-analyzer-optin.cplusplus.UninitializedObject by create a .clang-tidy file
optin-cplusplus-uninitializedobject
here is the YAML version of .clang-tidy config-file:
Checks: >
cppcoreguidelines-*,
WarningsAsErrors: "*"
CheckOptions:
- { key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor, value: true }
- { key: clang-analyzer-optin.cplusplus.UninitializedObject.Pedantic, value: true }
when trying to -dump-config option I can see that the clang-analyzer-* check is used:
---
Checks: "clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,\\n"
WarningsAsErrors: '*'
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
modernize-replace-auto-ptr.IncludeStyle: llvm
cppcoreguidelines-no-malloc.Reallocations: '::realloc'
cppcoreguidelines-owning-memory.LegacyResourceConsumers: '::free;::realloc;::freopen;::fclose'
cppcoreguidelines-avoid-magic-numbers.IgnoreAllFloatingPointValues: 'false'
cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions: 'false'
cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField: 'false'
cert-dcl16-c.NewSuffixes: 'L;LL;LU;LLU'
cppcoreguidelines-macro-usage.CheckCapsOnly: 'false'
modernize-loop-convert.MaxCopySize: '16'
cppcoreguidelines-pro-bounds-constant-array-index.GslHeader: ''
cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors: 'false'
cppcoreguidelines-narrowing-conversions.IgnoreConversionFromTypes: ''
cert-str34-c.DiagnoseSignedUnsignedCharComparisons: 'false'
cert-err33-c.CheckedFunctions: '::aligned_alloc;::asctime_s;::at_quick_exit;::atexit;::bsearch;::bsearch_s;::btowc;::c16rtomb;::c32rtomb;::calloc;::clock;::cnd_broadcast;::cnd_init;::cnd_signal;::cnd_timedwait;::cnd_wait;::ctime_s;::fclose;::fflush;::fgetc;::fgetpos;::fgets;::fgetwc;::fopen;::fopen_s;::fprintf;::fprintf_s;::fputc;::fputs;::fputwc;::fputws;::fread;::freopen;::freopen_s;::fscanf;::fscanf_s;::fseek;::fsetpos;::ftell;::fwprintf;::fwprintf_s;::fwrite;::fwscanf;::fwscanf_s;::getc;::getchar;::getenv;::getenv_s;::gets_s;::getwc;::getwchar;::gmtime;::gmtime_s;::localtime;::localtime_s;::malloc;::mbrtoc16;::mbrtoc32;::mbsrtowcs;::mbsrtowcs_s;::mbstowcs;::mbstowcs_s;::memchr;::mktime;::mtx_init;::mtx_lock;::mtx_timedlock;::mtx_trylock;::mtx_unlock;::printf_s;::putc;::putwc;::raise;::realloc;::remove;::rename;::scanf;::scanf_s;::setlocale;::setvbuf;::signal;::snprintf;::snprintf_s;::sprintf;::sprintf_s;::sscanf;::sscanf_s;::strchr;::strerror_s;::strftime;::strpbrk;::strrchr;::strstr;::strtod;::strtof;::strtoimax;::strtok;::strtok_s;::strtol;::strtold;::strtoll;::strtoul;::strtoull;::strtoumax;::strxfrm;::swprintf;::swprintf_s;::swscanf;::swscanf_s;::thrd_create;::thrd_detach;::thrd_join;::thrd_sleep;::time;::timespec_get;::tmpfile;::tmpfile_s;::tmpnam;::tmpnam_s;::tss_create;::tss_get;::tss_set;::ungetc;::ungetwc;::vfprintf;::vfprintf_s;::vfscanf;::vfscanf_s;::vfwprintf;::vfwprintf_s;::vfwscanf;::vfwscanf_s;::vprintf_s;::vscanf;::vscanf_s;::vsnprintf;::vsnprintf_s;::vsprintf;::vsprintf_s;::vsscanf;::vsscanf_s;::vswprintf;::vswprintf_s;::vswscanf;::vswscanf_s;::vwprintf_s;::vwscanf;::vwscanf_s;::wcrtomb;::wcschr;::wcsftime;::wcspbrk;::wcsrchr;::wcsrtombs;::wcsrtombs_s;::wcsstr;::wcstod;::wcstof;::wcstoimax;::wcstok;::wcstok_s;::wcstol;::wcstold;::wcstoll;::wcstombs;::wcstombs_s;::wcstoul;::wcstoull;::wcstoumax;::wcsxfrm;::wctob;::wctrans;::wctype;::wmemchr;::wprintf_s;::wscanf;::wscanf_s;'
cppcoreguidelines-explicit-virtual-functions.AllowOverrideAndFinal: 'false'
google-readability-braces-around-statements.ShortStatementLines: '1'
cppcoreguidelines-pro-type-member-init.IgnoreArrays: 'false'
cppcoreguidelines-avoid-magic-numbers.IgnoredFloatingPointValues: '1.0;100.0;'
cppcoreguidelines-macro-usage.IgnoreCommandLineMacros: 'true'
cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle: llvm
cppcoreguidelines-narrowing-conversions.WarnWithinTemplateInstantiation: 'false'
cppcoreguidelines-owning-memory.LegacyResourceProducers: '::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile'
cppcoreguidelines-narrowing-conversions.WarnOnFloatingPointNarrowingConversion: 'true'
cppcoreguidelines-narrowing-conversions.WarnOnEquivalentBitWidth: 'true'
cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues: '1;2;3;4;'
cppcoreguidelines-non-private-member-variables-in-classes.IgnorePublicMemberVariables: 'false'
modernize-loop-convert.MinConfidence: reasonable
cppcoreguidelines-avoid-magic-numbers.IgnorePowersOf2IntegerValues: 'false'
cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted: 'false'
google-readability-namespace-comments.ShortNamespaceLines: '10'
google-readability-namespace-comments.SpacesBeforeComments: '2'
cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: 'true'
cppcoreguidelines-avoid-magic-numbers.IgnoreBitFieldsWidths: 'true'
cppcoreguidelines-no-malloc.Allocations: '::malloc;::calloc'
cppcoreguidelines-narrowing-conversions.WarnOnIntegerNarrowingConversion: 'true'
cppcoreguidelines-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion: 'true'
cppcoreguidelines-prefer-member-initializer.UseAssignment: 'false'
cppcoreguidelines-explicit-virtual-functions.FinalSpelling: final
llvm-qualified-auto.AddConstToQualified: 'false'
modernize-loop-convert.NamingStyle: CamelCase
cppcoreguidelines-pro-type-member-init.UseAssignment: 'false'
cppcoreguidelines-init-variables.MathHeader: '\<math.h\>'
google-readability-function-size.StatementThreshold: '800'
llvm-else-after-return.WarnOnConditionVariables: 'false'
cppcoreguidelines-init-variables.IncludeStyle: llvm
modernize-pass-by-value.IncludeStyle: llvm
cppcoreguidelines-explicit-virtual-functions.OverrideSpelling: override
cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor: 'true'
modernize-use-nullptr.NullMacros: 'NULL'
cppcoreguidelines-no-malloc.Deallocations: '::free'
cppcoreguidelines-macro-usage.AllowedRegexp: '^DEBUG\_\*'
cppcoreguidelines-narrowing-conversions.PedanticMode: 'false'
llvm-else-after-return.WarnOnUnfixable: 'false'
...
when executing -verify-config:
command-line option '-config': warning: unknown check option 'clang-analyzer-optin.cplusplus.UninitializedObject.Pedantic' [-verify-config]
How to change Pedantic option to true in .clang-tidy file?the description in optin-cplusplus-uninitializedobject is not clear for me

No line break after while-statement with clang-format

I want to configure clang-format (version 14.0.6) that it leaves single-line while-statement without adding a line break for the trailing semicolon (C++):
For example, clang-format should just leave a "one-liner" as it is:
while (checkWaitCondition() != true);
But unfortunately clang-format adds by default a line break (plus an indentation of 4 spaces):
while (checkWaitCondition() != true)
;
I tried the options AllowShortBlocksOnASingleLine + AllowShortLoopsOnASingleLine, but without any impact...
Does anyone have an idea how I can prevent, that clang-format breaks the semicolon into the next line?
I use this .clang-format configuration file:
BasedOnStyle: WebKit
IndentWidth: 4
Language: Cpp
AlignAfterOpenBracket: Align
AllowShortFunctionsOnASingleLine: Empty
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Allman
BreakInheritanceList: BeforeComma
ColumnLimit: 120
Cpp11BracedListStyle: true
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
NamespaceIndentation: All
PenaltyReturnTypeOnItsOwnLine: 1000000
SortIncludes: false
DeriveLineEnding: false
UseCRLF: false
I found the reason, why clang-format ignored the settings for AllowShortBlocksOnASingleLine and AllowShortLoopsOnASingleLine: I had another .clang-format file in a lower directory, which overwrote my test-configuration...
With both flags set to true, the format works as expected, with the following setting in the .clang-format file:
AllowShortLoopsOnASingleLine: true
AllowShortBlocksOnASingleLine: true
Produces the following format:
while (checkWaitCondition() != true) { }
But for my purpose, I want to use the continue statement from now, to improve the readability:
while (checkWaitCondition() != true) { continue; }

Azure Pipeline can't find test results files to publish

The task PublishTestResults#2 doesn't find my test result files. Why not?
I am running Python tests with unittest using xmlrunner to generate output files in JUnit format.
This is the relevant output of the publish task:
2020-01-25T01:12:07.7443604Z ##[debug]pattern: 'testresults/TEST-*.xml'
2020-01-25T01:12:07.7476652Z ##[debug]findPath: './acceptance-tests/OOM-exception/testresults'
2020-01-25T01:12:07.7477167Z ##[debug]statOnly: 'false'
2020-01-25T01:12:07.7478528Z ##[debug]findPath: 'acceptance-tests/OOM-exception/testresults'
2020-01-25T01:12:07.7478992Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'true'
2020-01-25T01:12:07.7479362Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2020-01-25T01:12:07.7479710Z ##[debug]findOptions.followSymbolicLinks: 'true'
2020-01-25T01:12:07.7482715Z ##[debug] acceptance-tests/OOM-exception/testresults (directory)
2020-01-25T01:12:07.7489267Z ##[debug] acceptance-tests/OOM-exception/testresults/TEST-test_OOM_exceptions.OOM_exceptions-20200125011206.xml (file)
2020-01-25T01:12:07.7489642Z ##[debug]2 results
2020-01-25T01:12:07.7490249Z ##[debug]found 2 paths
2020-01-25T01:12:07.7490606Z ##[debug]applying include pattern
2020-01-25T01:12:07.7491144Z ##[debug]adjustedPattern: './acceptance-tests/OOM-exception/testresults/TEST-*.xml'
2020-01-25T01:12:07.7498261Z ##[debug]0 matches
2020-01-25T01:12:07.7504039Z ##[debug]0 final results
2020-01-25T01:12:07.7504342Z ##[debug]Detected 0 test result files
This output shows that the test file actually exists in the correct location. I have tried various variations of the testResultsFiles parameter including the default **/TEST-*.xml.
By the way, the tests themselves succeed and all tests are actually run.
This is the relevant part from my YAML-pipeline:
- task: UsePythonVersion#0
inputs:
versionSpec: '3.8'
- script: python3 -m pip install --upgrade pip setuptools
- script: pip install -r requirements.txt
workingDirectory: '$(testFilesFolder)'
- script: python3 -m xmlrunner discover --output testresults
continueOnError: true
workingDirectory: '$(testFilesFolder)'
- task: PublishTestResults#2
inputs:
testResultsFormat: 'JUnit' # Options: JUnit, NUnit, VSTest, xUnit, cTest
testResultsFiles: 'testresults/TEST-*.xml'
searchFolder: '$(testFilesFolder)'
failTaskOnFailedTests: true
This is the full output of the task:
2020-01-25T01:12:07.5996494Z ##[debug]Evaluating condition for step: 'PublishTestResults'
2020-01-25T01:12:07.5996980Z ##[debug]Evaluating: SucceededNode()
2020-01-25T01:12:07.5997134Z ##[debug]Evaluating SucceededNode:
2020-01-25T01:12:07.5997333Z ##[debug]=> True
2020-01-25T01:12:07.5997489Z ##[debug]Result: True
2020-01-25T01:12:07.5997666Z ##[section]Starting: PublishTestResults
2020-01-25T01:12:07.6000996Z ==============================================================================
2020-01-25T01:12:07.6001109Z Task : Publish Test Results
2020-01-25T01:12:07.6001211Z Description : Publish test results to Azure Pipelines
2020-01-25T01:12:07.6001273Z Version : 2.162.2
2020-01-25T01:12:07.6001329Z Author : Microsoft Corporation
2020-01-25T01:12:07.6001445Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/test/publish-test-results
2020-01-25T01:12:07.6001514Z ==============================================================================
2020-01-25T01:12:07.7287680Z ##[debug]agent.TempDirectory=/home/vsts/work/_temp
2020-01-25T01:12:07.7311778Z ##[debug]loading inputs and endpoints
2020-01-25T01:12:07.7316458Z ##[debug]loading INPUT_TESTRUNNER
2020-01-25T01:12:07.7326771Z ##[debug]loading INPUT_TESTRESULTSFILES
2020-01-25T01:12:07.7328668Z ##[debug]loading INPUT_SEARCHFOLDER
2020-01-25T01:12:07.7329586Z ##[debug]loading INPUT_MERGETESTRESULTS
2020-01-25T01:12:07.7330846Z ##[debug]loading INPUT_FAILTASKONFAILEDTESTS
2020-01-25T01:12:07.7332115Z ##[debug]loading INPUT_PUBLISHRUNATTACHMENTS
2020-01-25T01:12:07.7332777Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2020-01-25T01:12:07.7334111Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2020-01-25T01:12:07.7334752Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2020-01-25T01:12:07.7339261Z ##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
2020-01-25T01:12:07.7340893Z ##[debug]loaded 10
2020-01-25T01:12:07.7358665Z ##[debug]Agent.ProxyUrl=undefined
2020-01-25T01:12:07.7367753Z ##[debug]Agent.CAInfo=undefined
2020-01-25T01:12:07.7368399Z ##[debug]Agent.ClientCert=undefined
2020-01-25T01:12:07.7368766Z ##[debug]Agent.SkipCertValidation=undefined
2020-01-25T01:12:07.7398326Z ##[debug]check path : /home/vsts/work/_tasks/PublishTestResults_0b0f01ed-7dde-43ff-9cbb-e48954daf9b1/2.162.2/task.json
2020-01-25T01:12:07.7398974Z ##[debug]adding resource file: /home/vsts/work/_tasks/PublishTestResults_0b0f01ed-7dde-43ff-9cbb-e48954daf9b1/2.162.2/task.json
2020-01-25T01:12:07.7399510Z ##[debug]system.culture=en-US
2020-01-25T01:12:07.7415772Z ##[debug]testRunner=JUnit
2020-01-25T01:12:07.7421062Z ##[debug]testResultsFiles=testresults/TEST-*.xml
2020-01-25T01:12:07.7422659Z ##[debug]mergeTestResults=false
2020-01-25T01:12:07.7423114Z ##[debug]platform=null
2020-01-25T01:12:07.7423434Z ##[debug]configuration=null
2020-01-25T01:12:07.7423787Z ##[debug]testRunTitle=null
2020-01-25T01:12:07.7424308Z ##[debug]publishRunAttachments=true
2020-01-25T01:12:07.7424851Z ##[debug]failTaskOnFailedTests=true
2020-01-25T01:12:07.7426678Z ##[debug]searchFolder=./acceptance-tests/OOM-exception/
2020-01-25T01:12:07.7427036Z ##[debug]testRunner: JUnit
2020-01-25T01:12:07.7428343Z ##[debug]testResultsFiles: testresults/TEST-*.xml
2020-01-25T01:12:07.7428601Z ##[debug]mergeResults: false
2020-01-25T01:12:07.7428805Z ##[debug]platform: null
2020-01-25T01:12:07.7428998Z ##[debug]config: null
2020-01-25T01:12:07.7429181Z ##[debug]testRunTitle: null
2020-01-25T01:12:07.7429385Z ##[debug]publishRunAttachments: true
2020-01-25T01:12:07.7429576Z ##[debug]failTaskOnFailedTests: true
2020-01-25T01:12:07.7436004Z ##[debug]defaultRoot: './acceptance-tests/OOM-exception/'
2020-01-25T01:12:07.7436605Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'true'
2020-01-25T01:12:07.7437018Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2020-01-25T01:12:07.7437421Z ##[debug]findOptions.followSymbolicLinks: 'true'
2020-01-25T01:12:07.7437851Z ##[debug]matchOptions.debug: 'false'
2020-01-25T01:12:07.7438389Z ##[debug]matchOptions.nobrace: 'true'
2020-01-25T01:12:07.7439173Z ##[debug]matchOptions.noglobstar: 'false'
2020-01-25T01:12:07.7439555Z ##[debug]matchOptions.dot: 'true'
2020-01-25T01:12:07.7440082Z ##[debug]matchOptions.noext: 'false'
2020-01-25T01:12:07.7440915Z ##[debug]matchOptions.nocase: 'false'
2020-01-25T01:12:07.7441403Z ##[debug]matchOptions.nonull: 'false'
2020-01-25T01:12:07.7441842Z ##[debug]matchOptions.matchBase: 'false'
2020-01-25T01:12:07.7442248Z ##[debug]matchOptions.nocomment: 'false'
2020-01-25T01:12:07.7442699Z ##[debug]matchOptions.nonegate: 'false'
2020-01-25T01:12:07.7443144Z ##[debug]matchOptions.flipNegate: 'false'
2020-01-25T01:12:07.7443604Z ##[debug]pattern: 'testresults/TEST-*.xml'
2020-01-25T01:12:07.7476652Z ##[debug]findPath: './acceptance-tests/OOM-exception/testresults'
2020-01-25T01:12:07.7477167Z ##[debug]statOnly: 'false'
2020-01-25T01:12:07.7478528Z ##[debug]findPath: 'acceptance-tests/OOM-exception/testresults'
2020-01-25T01:12:07.7478992Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'true'
2020-01-25T01:12:07.7479362Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2020-01-25T01:12:07.7479710Z ##[debug]findOptions.followSymbolicLinks: 'true'
2020-01-25T01:12:07.7482715Z ##[debug] acceptance-tests/OOM-exception/testresults (directory)
2020-01-25T01:12:07.7489267Z ##[debug] acceptance-tests/OOM-exception/testresults/TEST-test_OOM_exceptions.OOM_exceptions-20200125011206.xml (file)
2020-01-25T01:12:07.7489642Z ##[debug]2 results
2020-01-25T01:12:07.7490249Z ##[debug]found 2 paths
2020-01-25T01:12:07.7490606Z ##[debug]applying include pattern
2020-01-25T01:12:07.7491144Z ##[debug]adjustedPattern: './acceptance-tests/OOM-exception/testresults/TEST-*.xml'
2020-01-25T01:12:07.7498261Z ##[debug]0 matches
2020-01-25T01:12:07.7504039Z ##[debug]0 final results
2020-01-25T01:12:07.7504342Z ##[debug]Detected 0 test result files
2020-01-25T01:12:07.7507804Z ##[debug]which 'dotnet'
2020-01-25T01:12:07.7513265Z ##[debug]found: '/usr/bin/dotnet'
2020-01-25T01:12:07.7515323Z ##[debug]which '/usr/bin/dotnet'
2020-01-25T01:12:07.7515798Z ##[debug]found: '/usr/bin/dotnet'
2020-01-25T01:12:07.7516162Z ##[debug]which '/usr/bin/dotnet'
2020-01-25T01:12:07.7516568Z ##[debug]found: '/usr/bin/dotnet'
2020-01-25T01:12:07.7518901Z ##[debug]/usr/bin/dotnet arg: --version
2020-01-25T01:12:07.7523251Z ##[debug]exec tool: /usr/bin/dotnet
2020-01-25T01:12:07.7523631Z ##[debug]arguments:
2020-01-25T01:12:07.7524431Z ##[debug] --version
2020-01-25T01:12:07.7528296Z [command]/usr/bin/dotnet --version
2020-01-25T01:12:11.2588747Z 3.0.101
2020-01-25T01:12:11.2655417Z ##[warning]No test result files matching testresults/TEST-*.xml were found.
2020-01-25T01:12:11.2666650Z ##[debug]Processed: ##vso[task.issue type=warning;]No test result files matching testresults/TEST-*.xml were found.
2020-01-25T01:12:11.2666885Z ##[debug]task result: Succeeded
2020-01-25T01:12:11.2667398Z ##[debug]Processed: ##vso[task.complete result=Succeeded;]
2020-01-25T01:12:11.2667534Z ##[debug]Release.ReleaseUri=undefined
2020-01-25T01:12:11.2667651Z ##[debug]Release.ReleaseId=undefined
2020-01-25T01:12:11.2667757Z ##[debug]Build.BuildUri=vstfs:///Build/Build/80106
2020-01-25T01:12:11.2667875Z ##[debug]Build.Buildid=80106
2020-01-25T01:12:11.3132563Z ##[debug]Processed: ##vso[telemetry.publish area=TestExecution;feature=PublishTestResultsTask]{"builduri":"vstfs:///Build/Build/80106","buildid":"80106","osType":"Linux","testRunner":"JUnit","failTaskOnFailedTests":"true","mergeResultsUserPreference":"false","config":null,"platform":null,"testResultsFilesCount":0,"dotnetVersion":"3.0.101","noResultsFileFound":true,"subFeature":"publishTestResultsTaskConsolidatedCiEvent"}
2020-01-25T01:12:11.3134445Z ##[section]Finishing: PublishTestResults
Edit:
Tried jessehouwing's answer. This didn't help. These are the logs:
2020-01-25T15:45:20.0576358Z ##[debug]searchFolder=./acceptance-tests/OOM-exception/
2020-01-25T15:45:20.0576743Z ##[debug]testRunner: JUnit
2020-01-25T15:45:20.0577183Z ##[debug]testResultsFiles: TEST-*.xml
2020-01-25T15:45:20.0577305Z ##[debug]mergeResults: false
2020-01-25T15:45:20.0577462Z ##[debug]platform: null
2020-01-25T15:45:20.0577563Z ##[debug]config: null
2020-01-25T15:45:20.0577706Z ##[debug]testRunTitle: null
2020-01-25T15:45:20.0577851Z ##[debug]publishRunAttachments: true
2020-01-25T15:45:20.0577958Z ##[debug]failTaskOnFailedTests: true
2020-01-25T15:45:20.0583685Z ##[debug]defaultRoot: './acceptance-tests/OOM-exception/'
2020-01-25T15:45:20.0584023Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'true'
2020-01-25T15:45:20.0586845Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2020-01-25T15:45:20.0587255Z ##[debug]findOptions.followSymbolicLinks: 'true'
2020-01-25T15:45:20.0587596Z ##[debug]matchOptions.debug: 'false'
2020-01-25T15:45:20.0587832Z ##[debug]matchOptions.nobrace: 'true'
2020-01-25T15:45:20.0588932Z ##[debug]matchOptions.noglobstar: 'false'
2020-01-25T15:45:20.0589501Z ##[debug]matchOptions.dot: 'true'
2020-01-25T15:45:20.0589789Z ##[debug]matchOptions.noext: 'false'
2020-01-25T15:45:20.0590176Z ##[debug]matchOptions.nocase: 'false'
2020-01-25T15:45:20.0590421Z ##[debug]matchOptions.nonull: 'false'
2020-01-25T15:45:20.0590685Z ##[debug]matchOptions.matchBase: 'false'
2020-01-25T15:45:20.0590905Z ##[debug]matchOptions.nocomment: 'false'
2020-01-25T15:45:20.0591171Z ##[debug]matchOptions.nonegate: 'false'
2020-01-25T15:45:20.0591432Z ##[debug]matchOptions.flipNegate: 'false'
2020-01-25T15:45:20.0591690Z ##[debug]pattern: 'TEST-*.xml'
2020-01-25T15:45:20.0631976Z ##[debug]findPath: './acceptance-tests/OOM-exception'
2020-01-25T15:45:20.0632431Z ##[debug]statOnly: 'false'
2020-01-25T15:45:20.0632752Z ##[debug]findPath: 'acceptance-tests/OOM-exception'
2020-01-25T15:45:20.0633054Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'true'
2020-01-25T15:45:20.0633332Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2020-01-25T15:45:20.0634538Z ##[debug]findOptions.followSymbolicLinks: 'true'
2020-01-25T15:45:20.0634974Z ##[debug] acceptance-tests/OOM-exception (directory)
2020-01-25T15:45:20.0646126Z ##[debug] acceptance-tests/OOM-exception/.dockerignore (file)
2020-01-25T15:45:20.0646726Z ##[debug] acceptance-tests/OOM-exception/.vscode (directory)
2020-01-25T15:45:20.0654441Z ##[debug] acceptance-tests/OOM-exception/.vscode/settings.json (file)
2020-01-25T15:45:20.0655814Z ##[debug] acceptance-tests/OOM-exception/CI (directory)
2020-01-25T15:45:20.0656184Z ##[debug] acceptance-tests/OOM-exception/CI/azure-test-OOM-exception-pipeline.yml (file)
2020-01-25T15:45:20.0657679Z ##[debug] acceptance-tests/OOM-exception/CI/config-ubuntu1804.sh (file)
2020-01-25T15:45:20.0661849Z ##[debug] acceptance-tests/OOM-exception/CI/config-windowsserver2019.ps1 (file)
2020-01-25T15:45:20.0662326Z ##[debug] acceptance-tests/OOM-exception/CI/test-VM-ARM-template-param.json (file)
2020-01-25T15:45:20.0662984Z ##[debug] acceptance-tests/OOM-exception/CI/test-VM-ARM-template.json (file)
2020-01-25T15:45:20.0665752Z ##[debug] acceptance-tests/OOM-exception/__pycache__ (directory)
2020-01-25T15:45:20.0666188Z ##[debug] acceptance-tests/OOM-exception/__pycache__/test_OOM_exceptions.cpython-38.pyc (file)
2020-01-25T15:45:20.0666991Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent (directory)
2020-01-25T15:45:20.0667347Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent/.vscode (directory)
2020-01-25T15:45:20.0667600Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent/.vscode/settings.json (file)
2020-01-25T15:45:20.0668189Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent/acceptance-test-agent.py (file)
2020-01-25T15:45:20.0668538Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent/command_json_schema.json (file)
2020-01-25T15:45:20.0668786Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent/requirements.txt (file)
2020-01-25T15:45:20.0669073Z ##[debug] acceptance-tests/OOM-exception/dc-authenticatieservice.Dockerfile (file)
2020-01-25T15:45:20.0669375Z ##[debug] acceptance-tests/OOM-exception/dc-dsbestellingbeheer.Dockerfile (file)
2020-01-25T15:45:20.0669614Z ##[debug] acceptance-tests/OOM-exception/dc-dsklantbeheer.Dockerfile (file)
2020-01-25T15:45:20.0669916Z ##[debug] acceptance-tests/OOM-exception/dc-frontend.Dockerfile (file)
2020-01-25T15:45:20.0670189Z ##[debug] acceptance-tests/OOM-exception/dc-spa.Dockerfile (file)
2020-01-25T15:45:20.0670429Z ##[debug] acceptance-tests/OOM-exception/docker-compose.override-images.yml (file)
2020-01-25T15:45:20.0670712Z ##[debug] acceptance-tests/OOM-exception/docker-compose.yml (file)
2020-01-25T15:45:20.0670990Z ##[debug] acceptance-tests/OOM-exception/docker_entry_point_sql-datacycle.sh (file)
2020-01-25T15:45:20.0671379Z ##[debug] acceptance-tests/OOM-exception/kantilever-datacycle-eventbus.Dockerfile (file)
2020-01-25T15:45:20.0671646Z ##[debug] acceptance-tests/OOM-exception/requirements.txt (file)
2020-01-25T15:45:20.0672447Z ##[debug] acceptance-tests/OOM-exception/runTest.sh (file)
2020-01-25T15:45:20.0672689Z ##[debug] acceptance-tests/OOM-exception/sql-datacycle.Dockerfile (file)
2020-01-25T15:45:20.0673143Z ##[debug] acceptance-tests/OOM-exception/test_OOM_exceptions.py (file)
2020-01-25T15:45:20.0673465Z ##[debug] acceptance-tests/OOM-exception/testresults (directory)
2020-01-25T15:45:20.0673717Z ##[debug] acceptance-tests/OOM-exception/testresults/TEST-test_OOM_exceptions.OOM_exceptions-20200125154519.xml (file)
2020-01-25T15:45:20.0673883Z ##[debug]33 results
2020-01-25T15:45:20.0674025Z ##[debug]found 33 paths
2020-01-25T15:45:20.0674129Z ##[debug]applying include pattern
2020-01-25T15:45:20.0674514Z ##[debug]adjustedPattern: './acceptance-tests/OOM-exception/TEST-*.xml'
2020-01-25T15:45:20.0678453Z ##[debug]0 matches
2020-01-25T15:45:20.0686188Z ##[debug]0 final results
2020-01-25T15:45:20.0687625Z ##[debug]Detected 0 test result files
I tested with xmlrunner and published the test result with publish test result task. It worked fine.
The above error says No test result files matching testresults/TEST-*.xml were found. The $(testFilesFolder) variable defined in your yaml pipeline probably is wrong. You can have try using the predefined variables (eg. $(system.defaultworkingdirectory)/acceptance-tests/OOM-exception) to point to the locations on the agent.
Below is my test project structure:
Below is my yaml pipeline:
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion#0
inputs:
versionSpec: '3.8'
displayName: 'Use Python 3.8'
- script: |
python3 -m pip install --upgrade pip
pip install -r requirements.txt
displayName: 'Install dependencies'
- script: |
python3 -m xmlrunner discover --output testresults
continueOnError: true
workingDirectory: '$(system.defaultworkingdirectory)/acceptancetest/testfolder'
displayName: 'pytest'
- task: PublishTestResults#2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: 'testresults/TEST-*.xml'
searchFolder: '$(system.defaultworkingdirectory)/acceptancetest/testfolder'
failTaskOnFailedTests: true

Does `File.info(string)/File::Info.new(string)` resolve symbolic links?

I'm using Crystal 0.25.0 and File.info(string).symlink? returns false when it should return true in the following sample:
`mkdir -p /tmp/delete`
Dir.cd "/tmp/delete"
`rm -f b`
`touch a`
`ln -s a b`
puts File.info("b").symlink?.inspect # false
puts File.info("b").type # File
puts Process.run("test", "-L b".split).success? # true
puts Process.run("test", "-L a".split).success? # false
It seems to resolve the link. Is this the expected behaviour?
Yes, File.info follows symlinks by default. This is the expected behavior, but you can disable it by passing follow_symlinks: false to the method:
File.info("b", follow_symlinks: false).symlink? # => true
This behavior is documented under File.info in the API docs.
If you don't need the File::Info instance for anything else, you can just use File.symlink? which essentially calls info(path, follow_symlinks: false).symlink?.

Clang Format Issue with multiline function declaration parameters

Clang Format is consistently doing this:
bool importSomethingIn( const boost::property_tree::ptree& inBoostTree,
int inSomeIndex,
std::shared_ptr<Something>
inSomething,
int x,
int y );
When I want it to do this:
bool importSomethingIn( const boost::property_tree::ptree& inBoostTree,
int inSomeIndex,
std::shared_ptr<Something> inSomething,
int x,
int y );
Note that it is adding a newline and indent before the symbol inSomething. It seems to always be the templated types that cause this behaviour.
How can I stop it from doing this?
Here is my current .clang-format:
BasedOnStyle: LLVM
Language: Cpp
AccessModifierOffset: -4
AlignEscapedNewlinesLeft: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: true
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackParameters: false
BreakBeforeBinaryOperators: false
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 120
CommentPragmas: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DerivePointerBinding: false
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
IndentFunctionDeclarationAfterType: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
PointerBindsToType: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: true
Standard: Cpp11
TabWidth: 8
UseTab: Never
Edit: I am using the clang format Xcode plugin which I obtained here on github July 2016 (first installed Alcatraz then clang format plugin with Aclatraz). I'm not entirely sure where the clang-format binary is, thus haven't seen the version number for the one that came with the plugin.
However, based on the suggestions below I installed clang-format using Homebrew which gave me version 3.9.0. I then set the Xcode plugin to "use system clang-format" and I got the desired result, so I guess it must have been a bug.
Your case seems fine to me on ubuntu 16.04 with clang-format 3.8
Install clang-format-3.8
sudo apt-get install clang-format-3.8
In ~/.vimrc
map <F3> :pyf /usr/share/vim/addons/syntax/clang-format-3.8.py<cr>
imap <F3> <C-o>:pyf /usr/share/vim/addons/syntax/clang-format-3.8.py<cr>
Use #OP's .clang-format and source code
mkdir ~/test
vim ~/test/.clang-format
vim ~/test/test.cpp
Format test.cpp in vim (using F3), then the result:
bool importSomethingIn( const boost::property_tree::ptree& inBoostTree,
int inSomeIndex,
std::shared_ptr<Something> inSomething,
int x,
int y );
I think it is caused by ColumnLimit. I think it's a bug...I had this problem ones and I solved it by changing this variable. Try to set:
ColumnLimit: 0
Reason
The length of bool importSomethingIn( const boost::property_tree::ptree& inBoostTree, int inSomeIndex, std::shared_ptr<Something>" has 117+-3 chars in dependence of computing invisible chars. is 117+-3 in dependence of computing invisible characters. ColumnLimit: 120 has been set and it is one of possible reasons, I think, it has been cut.