diff options
author | Mathieu Suen <mathieu.suen@sonarsource.com> | 2021-03-04 15:10:23 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-03-08 20:07:54 +0000 |
commit | 0d9ba430312caf9af1cab82a9cd1db01db89f4c3 (patch) | |
tree | fe5c88f6964241fa01a2c6e3c1d0e7f254f78380 /server | |
parent | 3ecff763a99c1bad6e317663b5733f8d2e7c7775 (diff) | |
download | sonarqube-0d9ba430312caf9af1cab82a9cd1db01db89f4c3.tar.gz sonarqube-0d9ba430312caf9af1cab82a9cd1db01db89f4c3.zip |
SONAR-14468, SONAR-14435 Improve C/C++/OjbC tutorial
Diffstat (limited to 'server')
12 files changed, 177 insertions, 39 deletions
diff --git a/server/sonar-docs/src/pages/analysis/azuredevops-integration.md b/server/sonar-docs/src/pages/analysis/azuredevops-integration.md index 644a235515d..249030dcb63 100644 --- a/server/sonar-docs/src/pages/analysis/azuredevops-integration.md +++ b/server/sonar-docs/src/pages/analysis/azuredevops-integration.md @@ -189,11 +189,13 @@ Select your build technology below to expand the instructions for configuring br [[collapse]] | ## Analyzing a C/C++/Obj-C project -|In your build pipeline, insert the following steps in the order they appear here. These steps can be interleaved with other steps of your build as long as the following order is followed. All steps have to be executed on the same agent. -| 1. Make **Build Wrapper** available on the build agent:\ -| Download and unzip the **Build Wrapper** on the build agent (see *Prerequisites* section of the [C/C++/Objective-C](/analysis/languages/cfamily/) page). The archive to download and decompress depends on the platform of the host.\ -| Please, note that: -| - For the Microsoft-hosted build agent you will need to do it every time (as part of build pipeline), e.g. you can add **PowerShell script** task doing that. This can be done by inserting a **Command Line** task.\ +| In your build pipeline, insert the following steps in the order they appear here. These steps can be interweaved with other steps of your build as long as the following order is followed. All steps have to be executed on the same agent. +| +| 1. Make the **Build Wrapper** available on the build agent: +| +| Download and unzip the **Build Wrapper** on the build agent (see the **Prerequisites** section of the [C/C++/Objective-C](/analysis/languages/cfamily/) page). The archive to download and decompress depends on the platform of the host. +| Please, note that: +| - For the Microsoft-hosted build agent, you will need to make the **Build Wrapper** available on the build agent every time (as part of the build pipeline). To accomplish this, you can add a **PowerShell script** task by inserting a **Command Line** task. | Example of PowerShell commands on a Windows host: | ``` | Invoke-WebRequest -Uri '<sonarqube_url>/static/cpp/build-wrapper-win-x86.zip' -OutFile 'build-wrapper.zip' @@ -210,15 +212,15 @@ Select your build technology below to expand the instructions for configuring br | unzip build-wrapper.zip | ``` | - For the self-hosted build agent you can either download it every time (using the same scripts) or only once (as part of manual setup of build agent). -| 2. Add a **Prepare analysis Configuration** task and configure it as follow:\ -| Click on the **Prepare analysis on SonarQube** task to configure it: +| 1. Add a **Prepare analysis Configuration** task and configure it as follow: +| Click on the **Prepare analysis on SonarQube** task to configure it: | * Select the **SonarQube Server** | * In *Choose the way to run the analysis*, select *standalone scanner* (even if you build with *Visual Studio*/*MSBuild*) | * In *Additional Properties* in the *Advanced* section, add the property `sonar.cfamily.build-wrapper-output` with, as its value, the output directory to which the Build Wrapper should write its results: `sonar.cfamily.build-wrapper-output=<output directory>` -| 3. Add a **Command Line** task to run your build.\ +| 1. Add a **Command Line** task to run your build. | For the analysis to happen, your build has to be run through a command line so that it can be wrapped-up by the build-wrapper. | To do so, -| * Run **Build Wrapper** executable. Pass in as the arguments (1) the output directory configured in the previous task and (2) the command that runs a clean build of your project (not an incremental build).\ +| * Run **Build Wrapper** executable. Pass in as the arguments (1) the output directory configured in the previous task and (2) the command that runs a clean build of your project (not an incremental build). | Example of PowerShell commands on a Windows host with an *MSBuild* build: | ``` | build-wrapper-win-x86/build-wrapper-win-x86-64.exe --out-dir <output directory> MSBuild.exe /t:Rebuild @@ -231,8 +233,50 @@ Select your build technology below to expand the instructions for configuring br | ``` | build-wrapper-macosx-x86/build-wrapper-macos-x86 --out-dir <output directory> xcodebuild -project myproject.xcodeproj -configuration Release clean build | ``` -| 4. Add a **Run Code Analysis** task to run the code analysis and make the results available to SonarQube. Consider running this task right after the previous one as the build environment should not be significantly altered before running the analysis. -| 5. Add a **Publish Quality Gate Result** task. +| 1. Add a **Run Code Analysis** task to run the code analysis and make the results available to SonarQube. Consider running this task right after the previous one as the build environment should not be significantly altered before running the analysis. +| 1. Add a **Publish Quality Gate Result** task. +| +| **.yml example**: +| ``` +| trigger: +| - master +| - feature/* +| +| steps: +| # Make Build Wrapper available +| - task: Bash@3 +| displayName: Download Build Wrapper +| inputs: +| targetType: inline +| script: > +| curl '<SONARQUBE_HOST>/static/cpp/build-wrapper-linux-x86.zip' --output build-wrapper.zip +| unzip build-wrapper.zip +| +| # Prepare Analysis Configuration task +| - task: SonarQubePrepare@4 +| inputs: +| SonarQube: 'YourSonarqubeServerEndpoint' +| scannerMode: 'CLI' +| configMode: 'manual' +| cliProjectKey: 'YourProjectKey' +| extraProperties: "sonar.cfamily.build-wrapper-output=bw_output" +| # Command Line task to run your build. +| - task: Bash@3 +| displayName: Bash Script +| inputs: +| targetType: inline +| script: > +| ./build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw_output <Your build command> +| +| # Run Code Analysis task +| - task: SonarQubeAnalyze@4 +| +| # Publish Quality Gate Result task +| - task: SonarQubePublish@4 +| inputs: +| pollingTimeoutSec: '300' +| ``` +| *Note: You need to choose your correct image and adapt the correct wrapper depending on the agent os. See above example to have the correct wrapper.* ### Running your pipeline Commit and push your code to trigger the pipeline execution and SonarQube analysis. New pushes on your branches (and pull requests if you set up pull request analysis) trigger a new analysis in SonarQube. diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/BranchAnalysisStepContent.tsx b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/BranchAnalysisStepContent.tsx index 1ec5a67b2c7..e8fd38050d4 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/BranchAnalysisStepContent.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/BranchAnalysisStepContent.tsx @@ -18,12 +18,15 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { connect } from 'react-redux'; import { translate } from 'sonar-ui-common/helpers/l10n'; +import { getLanguages, Store } from '../../../store/rootReducer'; import RenderOptions from '../components/RenderOptions'; import { BuildTools } from '../types'; import AnalysisCommand from './commands/AnalysisCommand'; export interface BranchesAnalysisStepProps { + languages: T.Languages; component: T.Component; onStepValidationChange: (isValid: boolean) => void; } @@ -36,11 +39,13 @@ const BUILD_TOOLS_ORDERED: Array<BuildTools> = [ BuildTools.Other ]; -export default function BranchAnalysisStepContent(props: BranchesAnalysisStepProps) { - const { component, onStepValidationChange } = props; +export function BranchAnalysisStepContent(props: BranchesAnalysisStepProps) { + const { component, onStepValidationChange, languages } = props; const [buildTechnology, setBuildTechnology] = React.useState<BuildTools | undefined>(); - + const buildToolsList = languages['c'] + ? BUILD_TOOLS_ORDERED + : BUILD_TOOLS_ORDERED.filter(t => t !== BuildTools.CFamily); return ( <> <span>{translate('onboarding.build')}</span> @@ -49,7 +54,7 @@ export default function BranchAnalysisStepContent(props: BranchesAnalysisStepPro name="buildTechnology" onCheck={value => setBuildTechnology(value as BuildTools)} optionLabelKey="onboarding.build" - options={BUILD_TOOLS_ORDERED} + options={buildToolsList} /> <AnalysisCommand onStepValidationChange={onStepValidationChange} @@ -59,3 +64,9 @@ export default function BranchAnalysisStepContent(props: BranchesAnalysisStepPro </> ); } + +const mapStateToProps = (state: Store) => ({ + languages: getLanguages(state) +}); + +export default connect(mapStateToProps)(BranchAnalysisStepContent); diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/BranchAnalysisStepContent-test.tsx b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/BranchAnalysisStepContent-test.tsx index a865469b760..ac649569b3b 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/BranchAnalysisStepContent-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/BranchAnalysisStepContent-test.tsx @@ -22,10 +22,11 @@ import * as React from 'react'; import { mockComponent } from '../../../../helpers/testMocks'; import RenderOptions from '../../components/RenderOptions'; import { BuildTools } from '../../types'; -import BranchAnalysisStepContent, { BranchesAnalysisStepProps } from '../BranchAnalysisStepContent'; +import { BranchAnalysisStepContent, BranchesAnalysisStepProps } from '../BranchAnalysisStepContent'; it('should render correctly', () => { expect(shallowRender()).toMatchSnapshot(); + expect(shallowRender({ languages: {} })).toMatchSnapshot('without C'); }); it.each([BuildTools.DotNet, BuildTools.Gradle, BuildTools.Maven, BuildTools.Other])( @@ -44,6 +45,7 @@ it.each([BuildTools.DotNet, BuildTools.Gradle, BuildTools.Maven, BuildTools.Othe function shallowRender(props: Partial<BranchesAnalysisStepProps> = {}) { return shallow( <BranchAnalysisStepContent + languages={{ c: { key: 'c', name: 'test' } }} component={mockComponent()} onStepValidationChange={jest.fn()} {...props} diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/BranchAnalysisStepContent-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/BranchAnalysisStepContent-test.tsx.snap index 3b1aacd4def..ab69a5c3830 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/BranchAnalysisStepContent-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/__tests__/__snapshots__/BranchAnalysisStepContent-test.tsx.snap @@ -137,3 +137,28 @@ exports[`should render correctly: other 1`] = ` /> </Fragment> `; + +exports[`should render correctly: without C 1`] = ` +<Fragment> + <span> + onboarding.build + </span> + <RenderOptions + name="buildTechnology" + onCheck={[Function]} + optionLabelKey="onboarding.build" + options={ + Array [ + "dotnet", + "maven", + "gradle", + "other", + ] + } + /> + <AnalysisCommand + onStepValidationChange={[MockFunction]} + projectKey="my-project" + /> +</Fragment> +`; diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/AnalysisCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/AnalysisCommand.tsx index d0506670b06..9c3ced3d9ef 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/AnalysisCommand.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/AnalysisCommand.tsx @@ -38,8 +38,6 @@ export default function AnalysisCommand(props: AnalysisCommandProps) { React.useEffect(() => { if (buildTool && buildTool !== BuildTools.CFamily) { props.onStepValidationChange(true); - } else { - props.onStepValidationChange(false); } }, [buildTool, props.onStepValidationChange]); diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/ClangGCC.tsx b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/ClangGCC.tsx index 59880e0c93f..1baf28d923c 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/ClangGCC.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/ClangGCC.tsx @@ -54,7 +54,7 @@ unzip build-wrapper.zip`, highlightScriptKey: 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.build_wrapper.ccpp.nix', scriptBuild: - './build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir <output directory> make clean all' + './build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output make clean all' }, [OSs.Windows]: { script: `Invoke-WebRequest -Uri '${host}/static/cpp/build-wrapper-win-x86.zip' -OutFile 'build-wrapper.zip' @@ -62,7 +62,7 @@ Expand-Archive -Path 'build-wrapper.zip' -DestinationPath '.'`, highlightScriptKey: 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.build_wrapper.ccpp.win', scriptBuild: - 'build-wrapper-win-x86/build-wrapper-win-x86-64.exe --out-dir <output directory> MSBuild.exe /t:Rebuild' + 'build-wrapper-win-x86/build-wrapper-win-x86-64.exe --out-dir bw-output MSBuild.exe /t:Rebuild' }, [OSs.MacOS]: { script: `curl '${host}/static/cpp/build-wrapper-macosx-x86.zip' --output build-wrapper.zip @@ -70,7 +70,7 @@ unzip build-wrapper.zip`, highlightScriptKey: 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.build_wrapper.ccpp.nix', scriptBuild: - './build-wrapper-macos-x86/build-wrapper-macos-x86 --out-dir <output directory> xcodebuild' + + './build-wrapper-macos-x86/build-wrapper-macos-x86 --out-dir bw-output xcodebuild' + ' -project myproject.xcodeproj -configuration Release clean build' } }; @@ -78,9 +78,15 @@ unzip build-wrapper.zip`, React.useEffect(() => { if (os) { props.onStepValidationChange(true); + } else { + props.onStepValidationChange(false); } }, [os, props.onStepValidationChange]); + const handlOsChange = (value: OSs) => { + setOs(value); + }; + return ( <> <span className="big-spacer-top display-block"> @@ -89,7 +95,7 @@ unzip build-wrapper.zip`, <RenderOptions checked={os} name="os" - onCheck={value => setOs(value as OSs)} + onCheck={handlOsChange} optionLabelKey="onboarding.build.other.os" options={Object.values(OSs)} /> @@ -110,7 +116,7 @@ unzip build-wrapper.zip`, <SentenceWithHighlights translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.build_wrapper.ccpp.script" highlightPrefixKeys={codeSnippetDownload[os].highlightScriptKey} - highlightKeys={['task']} + highlightKeys={['task', 'inline']} /> <CodeSnippet snippet={codeSnippetDownload[os].script} /> </li> diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/PrepareAnalysisCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/PrepareAnalysisCommand.tsx index 60bfbf86b15..744a22da66e 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/PrepareAnalysisCommand.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/PrepareAnalysisCommand.tsx @@ -41,7 +41,7 @@ export interface PrepareAnalysisCommandProps { export default function PrepareAnalysisCommand(props: PrepareAnalysisCommandProps) { const { buildTool, kind, projectKey } = props; - const ADDITIONAL_PROPERTY = 'sonar.cfamily.build-wrapper-output=<output directory>'; + const ADDITIONAL_PROPERTY = 'sonar.cfamily.build-wrapper-output=bw-output'; const MAVEN_GRADLE_PROPS_SNIPPET = `# Additional properties that will be passed to the scanner, # Put one key=value per line, example: diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/__tests__/__snapshots__/ClangGCC-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/__tests__/__snapshots__/ClangGCC-test.tsx.snap index e2cfc176ab3..24e43f76355 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/__tests__/__snapshots__/ClangGCC-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/__tests__/__snapshots__/ClangGCC-test.tsx.snap @@ -43,6 +43,7 @@ exports[`should render correctly for "linux" 1`] = ` highlightKeys={ Array [ "task", + "inline", ] } highlightPrefixKeys="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.build_wrapper.ccpp.nix" @@ -94,7 +95,7 @@ unzip build-wrapper.zip" translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.build_script.ccpp" /> <CodeSnippet - snippet="./build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir <output directory> make clean all" + snippet="./build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output make clean all" /> </li> </ul> @@ -158,6 +159,7 @@ exports[`should render correctly for "mac" 1`] = ` highlightKeys={ Array [ "task", + "inline", ] } highlightPrefixKeys="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.build_wrapper.ccpp.nix" @@ -209,7 +211,7 @@ unzip build-wrapper.zip" translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.build_script.ccpp" /> <CodeSnippet - snippet="./build-wrapper-macos-x86/build-wrapper-macos-x86 --out-dir <output directory> xcodebuild -project myproject.xcodeproj -configuration Release clean build" + snippet="./build-wrapper-macos-x86/build-wrapper-macos-x86 --out-dir bw-output xcodebuild -project myproject.xcodeproj -configuration Release clean build" /> </li> </ul> @@ -273,6 +275,7 @@ exports[`should render correctly for "win" 1`] = ` highlightKeys={ Array [ "task", + "inline", ] } highlightPrefixKeys="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.build_wrapper.ccpp.win" @@ -324,7 +327,7 @@ Expand-Archive -Path 'build-wrapper.zip' -DestinationPath '.'" translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.build_script.ccpp" /> <CodeSnippet - snippet="build-wrapper-win-x86/build-wrapper-win-x86-64.exe --out-dir <output directory> MSBuild.exe /t:Rebuild" + snippet="build-wrapper-win-x86/build-wrapper-win-x86-64.exe --out-dir bw-output MSBuild.exe /t:Rebuild" /> </li> </ul> diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/__tests__/__snapshots__/PrepareAnalysisCommand-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/__tests__/__snapshots__/PrepareAnalysisCommand-test.tsx.snap index 8085026aff0..170210c11f5 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/__tests__/__snapshots__/PrepareAnalysisCommand-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/__tests__/__snapshots__/PrepareAnalysisCommand-test.tsx.snap @@ -240,12 +240,12 @@ exports[`should render correctly 4`] = ` onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp.advanced </b>, "button": <ClipboardIconButton - copyValue="sonar.cfamily.build-wrapper-output=<output directory>" + copyValue="sonar.cfamily.build-wrapper-output=bw-output" />, "property": <code className="rule" > - sonar.cfamily.build-wrapper-output=<output directory> + sonar.cfamily.build-wrapper-output=bw-output </code>, } } diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/BuildToolForm.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/BuildToolForm.tsx index f9bb51a0a97..1da982e10e3 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/BuildToolForm.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/BuildToolForm.tsx @@ -18,12 +18,15 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { connect } from 'react-redux'; import RadioToggle from 'sonar-ui-common/components/controls/RadioToggle'; import { translate } from 'sonar-ui-common/helpers/l10n'; +import { getLanguages, Store } from '../../../store/rootReducer'; import RenderOptions from '../components/RenderOptions'; import { BuildTools, ManualTutorialConfig, OSs } from '../types'; interface Props { + languages: T.Languages; config?: ManualTutorialConfig; onDone: (config: ManualTutorialConfig) => void; } @@ -32,7 +35,7 @@ interface State { config: ManualTutorialConfig; } -export default class BuildToolForm extends React.PureComponent<Props, State> { +export class BuildToolForm extends React.PureComponent<Props, State> { constructor(props: Props) { super(props); this.state = { @@ -57,13 +60,12 @@ export default class BuildToolForm extends React.PureComponent<Props, State> { render() { const { config } = this.state; - const buildTools = [ - BuildTools.Maven, - BuildTools.Gradle, - BuildTools.DotNet, - BuildTools.CFamily, - BuildTools.Other - ]; + const { languages } = this.props; + const buildTools = [BuildTools.Maven, BuildTools.Gradle, BuildTools.DotNet]; + if (languages['c']) { + buildTools.push(BuildTools.CFamily); + } + buildTools.push(BuildTools.Other); return ( <> @@ -94,3 +96,9 @@ export default class BuildToolForm extends React.PureComponent<Props, State> { ); } } + +const mapStateToProps = (state: Store) => ({ + languages: getLanguages(state) +}); + +export default connect(mapStateToProps)(BuildToolForm); diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/BuildToolForm-test.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/BuildToolForm-test.tsx index cf789d91a2d..3cd4d25b405 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/BuildToolForm-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/BuildToolForm-test.tsx @@ -20,10 +20,11 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { BuildTools, OSs } from '../../types'; -import BuildToolForm from '../BuildToolForm'; +import { BuildToolForm } from '../BuildToolForm'; it('renders correctly', () => { expect(shallowRender()).toMatchSnapshot('default'); + expect(shallowRender({ languages: {} })).toMatchSnapshot('without C'); expect(shallowRender().setState({ config: { buildTool: BuildTools.Maven } })).toMatchSnapshot( 'with "maven" selected' ); @@ -47,5 +48,7 @@ it('correctly calls the onDone prop', () => { }); function shallowRender(props: Partial<BuildToolForm['props']> = {}) { - return shallow<BuildToolForm>(<BuildToolForm onDone={jest.fn()} {...props} />); + return shallow<BuildToolForm>( + <BuildToolForm onDone={jest.fn()} languages={{ c: { key: 'c', name: 'test' } }} {...props} /> + ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/__snapshots__/BuildToolForm-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/__snapshots__/BuildToolForm-test.tsx.snap index a478aa8017b..4f1c17201a7 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/__snapshots__/BuildToolForm-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/__snapshots__/BuildToolForm-test.tsx.snap @@ -138,3 +138,41 @@ exports[`renders correctly: with "other" selected 1`] = ` /> </Fragment> `; + +exports[`renders correctly: without C 1`] = ` +<Fragment> + <div> + <h4 + className="spacer-bottom" + > + onboarding.build + </h4> + <RadioToggle + disabled={false} + name="language" + onCheck={[Function]} + options={ + Array [ + Object { + "label": "onboarding.build.maven", + "value": "maven", + }, + Object { + "label": "onboarding.build.gradle", + "value": "gradle", + }, + Object { + "label": "onboarding.build.dotnet", + "value": "dotnet", + }, + Object { + "label": "onboarding.build.other", + "value": "other", + }, + ] + } + value={null} + /> + </div> +</Fragment> +`; |