diff --git a/.ci/inc/fetch_ci_scripts.bash b/.ci/inc/fetch_ci_scripts.bash index d608e40..835fe67 100644 --- a/.ci/inc/fetch_ci_scripts.bash +++ b/.ci/inc/fetch_ci_scripts.bash @@ -4,7 +4,7 @@ function fetch_ci_scripts() { local inc_dir local inc_url inc_dir="$(dirname "$0")/inc" - inc_url="${PMD_CI_SCRIPTS_URL:-https://raw.githubusercontent.com/pmd/build-tools/master/scripts}/inc" + inc_url="${PMD_CI_SCRIPTS_URL:-https://raw.githubusercontent.com/pmd/build-tools/main/scripts}/inc" mkdir -p "${inc_dir}" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c2aff95..6b985c8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - master tags: - '**' pull_request: @@ -40,7 +39,7 @@ jobs: run: | echo "LANG=en_US.UTF-8" >> $GITHUB_ENV echo "MAVEN_OPTS=-Dmaven.wagon.httpconnectionManager.ttlSeconds=180 -Dmaven.wagon.http.retryHandler.count=3" >> $GITHUB_ENV - echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/master/scripts" >> $GITHUB_ENV + echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/26/scripts" >> $GITHUB_ENV - name: Check Environment shell: bash run: | diff --git a/.github/workflows/manual-integration-tests.yml b/.github/workflows/manual-integration-tests.yml index c657cd6..7fa4a32 100644 --- a/.github/workflows/manual-integration-tests.yml +++ b/.github/workflows/manual-integration-tests.yml @@ -32,7 +32,7 @@ jobs: run: | echo "LANG=en_US.UTF-8" >> $GITHUB_ENV echo "MAVEN_OPTS=-Dmaven.wagon.httpconnectionManager.ttlSeconds=180 -Dmaven.wagon.http.retryHandler.count=3" >> $GITHUB_ENV - echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/master/scripts" >> $GITHUB_ENV + echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/main/scripts" >> $GITHUB_ENV - name: Check Environment shell: bash run: | diff --git a/History.md b/History.md index a93c95a..74d644f 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,17 @@ ## New and Noteworthy +#### New Git default branch - "main" + +We are joining the Git community and updating "master" to "main". Using the term "master" for the main +development branch can be offensive to some people. Existing versions of Git have been always capable of +working with any branch name and since 2.28.0 (July 2020) the default initial branch is configurable +(`init.defaultBranch`). Since October 2020, the default branch for new repositories on GitHub +is "main". Finally, PMD will also use this new name for the main branch in all our own repositories. + +Note: The regression tester will also use branch `main` by default now for fetching repositories from the list of +projects. You might need to add `master` for some projects. + ## Enhancements * [#123](https://github.com/pmd/pmd-regression-tester/pull/123): Support ruby 3.3.0 * [#125](https://github.com/pmd/pmd-regression-tester/pull/125): Update rubocop configuration diff --git a/README.rdoc b/README.rdoc index 7d2910a..11bffc2 100644 --- a/README.rdoc +++ b/README.rdoc @@ -4,7 +4,7 @@ home :: https://pmd.github.io code :: https://github.com/pmd/pmd-regression-tester bugs :: https://github.com/pmd/pmd-regression-tester/issues -build-status :: {Build Status}[https://github.com/pmd/pmd-regression-tester/actions?query=workflow%3Abuild] +build-status :: {Build Status}[https://github.com/pmd/pmd-regression-tester/actions?query=workflow%3Abuild] gem-version :: {Gem Version}[https://rubygems.org/gems/pmdtester] @@ -29,9 +29,9 @@ on a list of standard projects(Spring Framework, Hibernate, Solr, etc.) -l, --list-of-project path to the file which contains the list of standard projects -m, --mode the mode of the tool: 'local', 'online' or 'single' single: Set this option to 'single' if your patch branch contains changes - for any option that can't work on master/base branch + for any option that can't work on main/base branch online: Set this option to 'online' if you want to download - the PMD report of master/base branch rather than generating it locally + the PMD report of main/base branch rather than generating it locally local: Default option is 'local', PMD reports for the base and patch branches are generated locally. -t, --threads Sets the number of threads used by PMD. Set threads to 0 to disable multi-threading processing. @@ -49,7 +49,7 @@ on a list of standard projects(Spring Framework, Hibernate, Solr, etc.) ==== Run local mode - pmdtester -b master -p YOUR_DEVELOPMENT_BRANCH -r PATH_TO_LOCAL_PMD_REPO -a + pmdtester -b main -p YOUR_DEVELOPMENT_BRANCH -r PATH_TO_LOCAL_PMD_REPO -a ==== Run single mode @@ -57,7 +57,7 @@ on a list of standard projects(Spring Framework, Hibernate, Solr, etc.) ==== Run online mode - pmdtester -b master -p YOUR_DEVELOPMENT_BRANCH -r PATH_TO_LOCAL_PMD_REPO -m online -a + pmdtester -b main -p YOUR_DEVELOPMENT_BRANCH -r PATH_TO_LOCAL_PMD_REPO -m online -a === Output The tool creates the following folders: @@ -159,7 +159,7 @@ The tool creates the following folders: * Update History.md and lib/pmdtester.rb for the next development version, run again "bundle exec rake verify" * Commit ("Prepare next development version x.y.z-SNAPSHOT"). -* Push to master. +* Push to main. * Push the tag. Github Actions will build and publish the new gem * A github release is automatically created, verify it on https://github.com/pmd/pmd-regression-tester/releases * To make pmd's main CI use the new version (in [pmd/pmd](https://github.com/pmd/pmd/)), go to the root directory and run `bundle lock --update`. Commit these changes. diff --git a/lib/pmdtester/builders/pmd_report_builder.rb b/lib/pmdtester/builders/pmd_report_builder.rb index 04fa644..5b1e310 100644 --- a/lib/pmdtester/builders/pmd_report_builder.rb +++ b/lib/pmdtester/builders/pmd_report_builder.rb @@ -25,10 +25,13 @@ def initialize(projects, options, branch_config, branch_name) def get_pmd_binary_file logger.info "#{@pmd_branch_name}: Start packaging PMD" Dir.chdir(@local_git_repo) do - build_branch_sha = Cmd.execute_successfully("git rev-parse #{@pmd_branch_name}^{commit}") - checkout_build_branch # needs a clean working tree, otherwise fails + # first checkout the build branch - that might create a local branch from remote, if + # a local branch doesn't exist yet. The following "git rev-parse" command only works + # for local branches. + build_branch_sha = Cmd.execute_successfully("git rev-parse #{@pmd_branch_name}^{commit}") + raise "Wrong branch #{get_last_commit_sha}" unless build_branch_sha == get_last_commit_sha distro_path = saved_distro_path(build_branch_sha) diff --git a/lib/pmdtester/parsers/options.rb b/lib/pmdtester/parsers/options.rb index 7e928ea..7e116e3 100644 --- a/lib/pmdtester/parsers/options.rb +++ b/lib/pmdtester/parsers/options.rb @@ -75,9 +75,9 @@ def parse(argv) mode_message = <<-DOC the mode of the tool: 'local', 'online' or 'single' single: Set this option to 'single' if your patch branch contains changes - for any option that can't work on master/base branch + for any option that can't work on main/base branch online: Set this option to 'online' if you want to download - the PMD report of master/base branch rather than generating it locally + the PMD report of main/base branch rather than generating it locally local: Default option is 'local', PMD reports for the base and patch branches are generated locally. DOC diff --git a/lib/pmdtester/project.rb b/lib/pmdtester/project.rb index 530e987..503da63 100644 --- a/lib/pmdtester/project.rb +++ b/lib/pmdtester/project.rb @@ -28,7 +28,7 @@ def initialize(project) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/ @type = project.at_xpath('type').text @connection = project.at_xpath('connection').text - @tag = project.at_xpath('tag')&.text || 'master' + @tag = project.at_xpath('tag')&.text || 'main' webview_url_element = project.at_xpath('webview-url') @webview_url = default_webview_url diff --git a/test/integration_test_pmd_report_builder.rb b/test/integration_test_pmd_report_builder.rb index d6641df..03ca53d 100644 --- a/test/integration_test_pmd_report_builder.rb +++ b/test/integration_test_pmd_report_builder.rb @@ -10,17 +10,17 @@ def setup `rake clean` end - # Tests whether we can build successfully PMD from the sources of the master branch. - # The master branch should always be buildable by the regression tester. For older + # Tests whether we can build successfully PMD from the sources of the main branch. + # The main branch should always be buildable by the regression tester. For older # versions, we can rely on baselines. # # Note 1: Although a base branch is configured here, this is not used. Only the patch # branch is built. # Note 2: We use a limited set of projects and rules, to make the test faster. - def test_build_master_branch + def test_build_main_branch argv = ['-r', 'target/repositories/pmd', '-b', 'pmd_releases/6.55.0', - '-p', 'master', + '-p', 'main', '-c', 'test/resources/integration_test_pmd_report_builder/pmd7-config.xml', '-l', 'test/resources/integration_test_pmd_report_builder/project-test.xml', '--error-recovery', @@ -34,6 +34,6 @@ def test_build_master_branch builder.build assert_equal(0, $CHILD_STATUS.exitstatus) - assert_path_exist('target/reports/master/checkstyle/pmd_report.xml') + assert_path_exist('target/reports/main/checkstyle/pmd_report.xml') end end diff --git a/test/integration_test_runner.rb b/test/integration_test_runner.rb index 2999666..27b6021 100644 --- a/test/integration_test_runner.rb +++ b/test/integration_test_runner.rb @@ -10,14 +10,14 @@ def setup def test_local_mode argv = '-r target/repositories/pmd -b pmd_releases/6.41.0 -bc config/design.xml ' \ - '-p master -pc config/design.xml -l test/resources/integration_test_runner/project-test.xml ' \ + '-p main -pc config/design.xml -l test/resources/integration_test_runner/project-test.xml ' \ '--threads ' + Etc.nprocessors.to_s system("bundle exec bin/pmdtester #{argv}") assert_equal(0, $CHILD_STATUS.exitstatus) - assert_path_exist('target/reports/master/checkstyle/pmd_report.xml') - assert_path_exist('target/reports/master/pmd/pmd_report.xml') + assert_path_exist('target/reports/main/checkstyle/pmd_report.xml') + assert_path_exist('target/reports/main/pmd/pmd_report.xml') assert_path_exist('target/reports/pmd_releases_6.41.0/checkstyle/pmd_report.xml') assert_path_exist('target/reports/pmd_releases_6.41.0/checkstyle/config.xml') assert_path_exist('target/reports/pmd_releases_6.41.0/pmd/pmd_report.xml') diff --git a/test/manual_integration_tests.rb b/test/manual_integration_tests.rb index 82bd64a..e18d8a5 100644 --- a/test/manual_integration_tests.rb +++ b/test/manual_integration_tests.rb @@ -15,7 +15,7 @@ # pmd regression tester is always called in online mode, comparing the pull request against # the latest baseline. # -# Test case 5 is creating a new baseline from master. +# Test case 5 is creating a new baseline from main. # # The test file is deliberately called "manual_integration_tests" so that it is not picked # up by "bundle exec rake integration-test". It has to be run manually via @@ -182,7 +182,7 @@ def test_case_5_create_baseline checkout_pmd_branch argv = ['--mode', 'single', '--local-git-repo', PMD_REPO_PATH, - '--patch-branch', 'master', + '--patch-branch', 'main', '--patch-config', "#{PMD_REPO_PATH}/.ci/files/all-regression-rules.xml", '--list-of-project', "#{PMD_REPO_PATH}/.ci/files/project-list.xml", '--html-flag', @@ -197,12 +197,12 @@ def test_case_5_create_baseline print "#############################: test_case_5_create_baseline\n" assert_path_not_exist('target/reports/diff') - assert_master_baseline + assert_main_baseline end private - def run_pmd_tester(base_branch_name = 'master') + def run_pmd_tester(base_branch_name = 'main') argv = ['--local-git-repo', PMD_REPO_PATH, '--list-of-project', "#{PMD_REPO_PATH}/.ci/files/project-list.xml", '--base-branch', base_branch_name, @@ -224,7 +224,7 @@ def run_pmd_tester(base_branch_name = 'master') # # This is the same message as in - # https://github.com/pmd/pmd/blob/master/Dangerfile + # https://github.com/pmd/pmd/blob/main/Dangerfile # def create_summary_message 'This changeset ' \ @@ -237,7 +237,7 @@ def create_summary_message "#{@summary[:configerrors][:removed]} configuration errors." end - def checkout_pmd_branch(branch = 'master') + def checkout_pmd_branch(branch = 'main') system("git clone https://github.com/pmd/pmd #{PMD_REPO_PATH}") unless File.directory?(PMD_REPO_PATH) Dir.chdir(PMD_REPO_PATH) do system('git fetch --all') @@ -251,7 +251,7 @@ def checkout_pmd_branch(branch = 'master') end end - def prepare_patch_branch(patch_file, local_branch, base_branch = 'master') + def prepare_patch_branch(patch_file, local_branch, base_branch = 'main') absolute_patch_file = File.absolute_path("#{PATCHES_PATH}/#{patch_file}") assert_path_exist(absolute_patch_file) @@ -263,20 +263,20 @@ def prepare_patch_branch(patch_file, local_branch, base_branch = 'master') end end - def assert_master_baseline - assert_master_baseline_project('checkstyle', 40 * 1024 * 1024) - assert_master_baseline_project('openjdk-11', 80 * 1024 * 1024) - assert_master_baseline_project('spring-framework', 100 * 1024 * 1024) - assert_master_baseline_project('java-regression-tests', 100 * 1024) - assert_master_baseline_project('apex-link', 10 * 1024) - assert_master_baseline_project('fflib-apex-common', 400 * 1024) - assert_master_baseline_project('Schedul-o-matic-9000', 20 * 1024) + def assert_main_baseline + assert_main_baseline_project('checkstyle', 40 * 1024 * 1024) + assert_main_baseline_project('openjdk-11', 80 * 1024 * 1024) + assert_main_baseline_project('spring-framework', 100 * 1024 * 1024) + assert_main_baseline_project('java-regression-tests', 100 * 1024) + assert_main_baseline_project('apex-link', 10 * 1024) + assert_main_baseline_project('fflib-apex-common', 400 * 1024) + assert_main_baseline_project('Schedul-o-matic-9000', 20 * 1024) end - def assert_master_baseline_project(project_name, report_size_in_bytes) - assert_path_exist("target/reports/master/#{project_name}/config.xml") - assert_path_exist("target/reports/master/#{project_name}/report_info.json") - assert_path_exist("target/reports/master/#{project_name}/pmd_report.xml") - assert(File.size("target/reports/master/#{project_name}/pmd_report.xml") > report_size_in_bytes) + def assert_main_baseline_project(project_name, report_size_in_bytes) + assert_path_exist("target/reports/main/#{project_name}/config.xml") + assert_path_exist("target/reports/main/#{project_name}/report_info.json") + assert_path_exist("target/reports/main/#{project_name}/pmd_report.xml") + assert(File.size("target/reports/main/#{project_name}/pmd_report.xml") > report_size_in_bytes) end end diff --git a/test/resources/runner/main-baseline.zip b/test/resources/runner/main-baseline.zip new file mode 100644 index 0000000..88fbfa5 Binary files /dev/null and b/test/resources/runner/main-baseline.zip differ diff --git a/test/resources/runner/master-baseline.zip b/test/resources/runner/master-baseline.zip deleted file mode 100644 index 69d82c9..0000000 Binary files a/test/resources/runner/master-baseline.zip and /dev/null differ diff --git a/test/resources/runner/project-list.xml b/test/resources/runner/project-list.xml index 9489fa3..12bda99 100644 --- a/test/resources/runner/project-list.xml +++ b/test/resources/runner/project-list.xml @@ -8,6 +8,7 @@ xsi:noNamespaceSchemaLocation="projectlist_1_1_0.xsd"> checkstyle git https://github.com/checkstyle/checkstyle + master .*/target/test-classes/com/puppycrawl/tools/checkstyle/.* .*/target/generated-sources/.* .*/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/javaparser/InputJavaParserNoFreezeOnDeeplyNestedLambdas.java diff --git a/test/test_options.rb b/test/test_options.rb index 7aa1342..02b2376 100644 --- a/test/test_options.rb +++ b/test/test_options.rb @@ -7,12 +7,12 @@ class TestOptions < Test::Unit::TestCase include PmdTester def test_short_option command_line = - %w[-r /path/to/repo -b pmd_releases/6.2.0 -p master + %w[-r /path/to/repo -b pmd_releases/6.2.0 -p main -c config/all-java.xml -l config/project_list.txt -t 4] opts = Options.new(command_line) assert_equal('/path/to/repo', opts.local_git_repo) assert_equal('pmd_releases/6.2.0', opts.base_branch) - assert_equal('master', opts.patch_branch) + assert_equal('main', opts.patch_branch) assert_equal('config/all-java.xml', opts.config) assert_equal('config/project_list.txt', opts.project_list) assert_equal(4, opts.threads) @@ -21,19 +21,19 @@ def test_short_option def test_long_option command_line = %w[--local-git-repo /path/to/repo --base-branch pmd_releases/6.2.0 - --patch-branch master --config config/all-java.xml + --patch-branch main --config config/all-java.xml --list-of-project config/project_list.txt --threads 4] opts = Options.new(command_line) assert_equal('/path/to/repo', opts.local_git_repo) assert_equal('pmd_releases/6.2.0', opts.base_branch) - assert_equal('master', opts.patch_branch) + assert_equal('main', opts.patch_branch) assert_equal('config/all-java.xml', opts.config) assert_equal('config/project_list.txt', opts.project_list) assert_equal(4, opts.threads) end def test_default_value - command_line = %w[-r /path/to/repo -b pmd_releases/6.2.0 -p master] + command_line = %w[-r /path/to/repo -b pmd_releases/6.2.0 -p main] opts = Options.new(command_line) assert_equal(Options::DEFAULT_CONFIG_PATH, opts.base_config) assert_equal(Options::DEFAULT_CONFIG_PATH, opts.patch_config) @@ -43,33 +43,33 @@ def test_default_value end def test_download_url_with_trailing_slash - command_line = %w[-r /path/to/repo -b pmd_releases/6.2.0 -p master --baseline-download-url https://example.com/] + command_line = %w[-r /path/to/repo -b pmd_releases/6.2.0 -p main --baseline-download-url https://example.com/] opts = Options.new(command_line) assert_equal('https://example.com/', opts.baseline_download_url_prefix) end def test_download_url_without_trailing_slash - command_line = %w[-r /path/to/repo -b pmd_releases/6.2.0 -p master --baseline-download-url https://example.com] + command_line = %w[-r /path/to/repo -b pmd_releases/6.2.0 -p main --baseline-download-url https://example.com] opts = Options.new(command_line) assert_equal('https://example.com/', opts.baseline_download_url_prefix) end def test_enable_error_recovery - command_line = %w[-r /path/to/repo -b pmd_releases/6.2.0 -p master --error-recovery] + command_line = %w[-r /path/to/repo -b pmd_releases/6.2.0 -p main --error-recovery] opts = Options.new(command_line) assert_true(opts.error_recovery) end def test_single_mode command_line = - %w[-r /path/to/repo -p master -pc config.xml -l list.xml -f -m single] + %w[-r /path/to/repo -p main -pc config.xml -l list.xml -f -m single] opts = Options.new(command_line) assert_equal(true, opts.html_flag) end def test_invalid_mode argv = - %w[-r /path/to/repo -b pmd_releases/6.2.0 -p master + %w[-r /path/to/repo -b pmd_releases/6.2.0 -p main -c config/all-java.xml -l config/project_list.txt -m invalid_mode] begin Options.new(argv) diff --git a/test/test_pmd_report_builder.rb b/test/test_pmd_report_builder.rb index 00c069c..7f8689c 100644 --- a/test/test_pmd_report_builder.rb +++ b/test/test_pmd_report_builder.rb @@ -10,7 +10,7 @@ def setup # create a empty pmd repo directory FileUtils.mkdir_p 'target/repositories/pmd' # remove any cached distro_patch - FileUtils.rm_rf "target/pmd-bin-#{@pmd_version}-master-sha1abc" + FileUtils.rm_rf "target/pmd-bin-#{@pmd_version}-main-sha1abc" end def teardown @@ -30,7 +30,7 @@ def teardown def test_build_skip projects = [] - argv = %w[-r target/repositories/pmd -b master -p pmd_releases/6.1.0 + argv = %w[-r target/repositories/pmd -b main -p pmd_releases/6.1.0 -c config/design.xml -l test/resources/pmd_report_builder/project-test.xml] options = PmdTester::Options.new(argv) @@ -43,12 +43,12 @@ def test_build_skip end # In CI, there is no previous existing distro that can be reused, - # that means target/pmd-bin-6.10.0-SNAPSHOT-master-sha1abc does not + # that means target/pmd-bin-6.10.0-SNAPSHOT-main-sha1abc does not # exist. However, pmd-dist/target/pmd-bin-6.10.0-SNAPSHOT.zip exists # from a previous build and should be reused. def test_build_skip_ci projects = [] - argv = %w[-r target/repositories/pmd -b master -p pmd_releases/6.1.0 + argv = %w[-r target/repositories/pmd -b main -p pmd_releases/6.1.0 -c config/design.xml -l test/resources/pmd_report_builder/project-test.xml] options = PmdTester::Options.new(argv) @@ -62,7 +62,7 @@ def test_build_skip_ci ).once PmdTester::Cmd.stubs(:execute_successfully).with( "mv pmd-dist/target/exploded/pmd-bin-#{@pmd_version} " \ - "#{Dir.getwd}/target/pmd-bin-#{@pmd_version}-master-sha1abc" + "#{Dir.getwd}/target/pmd-bin-#{@pmd_version}-main-sha1abc" ).once record_expectations_after_build @@ -74,7 +74,7 @@ def test_build_skip_ci # with PMD7, the dist bin file is called pmd-dist/target/pmd-dist-7.0.0-bin-SNAPSHOT.zip def test_build_skip_ci_pmd7 projects = [] - argv = %w[-r target/repositories/pmd -b master -p pmd_releases/6.55.0 + argv = %w[-r target/repositories/pmd -b main -p pmd_releases/6.55.0 -c config/design.xml -l test/resources/pmd_report_builder/project-test.xml -d] options = PmdTester::Options.new(argv) @@ -88,7 +88,7 @@ def test_build_skip_ci_pmd7 ).once PmdTester::Cmd.stubs(:execute_successfully).with( "mv pmd-dist/target/exploded/pmd-bin-#{@pmd_version} " \ - "#{Dir.getwd}/target/pmd-bin-#{@pmd_version}-master-sha1abc" + "#{Dir.getwd}/target/pmd-bin-#{@pmd_version}-main-sha1abc" ).once record_expectations_after_build @@ -99,7 +99,7 @@ def test_build_skip_ci_pmd7 def test_build_normal projects = [] - argv = %w[-r target/repositories/pmd -b master -p pmd_releases/6.1.0 + argv = %w[-r target/repositories/pmd -b main -p pmd_releases/6.1.0 -c config/design.xml -l test/resources/pmd_report_builder/project-test.xml] options = PmdTester::Options.new(argv) @@ -112,7 +112,7 @@ def test_build_normal ).once PmdTester::Cmd.stubs(:execute_successfully).with( "mv pmd-dist/target/exploded/pmd-bin-#{@pmd_version} " \ - "#{Dir.getwd}/target/pmd-bin-#{@pmd_version}-master-sha1abc" + "#{Dir.getwd}/target/pmd-bin-#{@pmd_version}-main-sha1abc" ).once record_expectations_after_build @@ -123,7 +123,7 @@ def test_build_normal def test_build_normal_pmd7 projects = [] - argv = %w[-r target/repositories/pmd -b master -p pmd_releases/6.1.0 + argv = %w[-r target/repositories/pmd -b main -p pmd_releases/6.1.0 -c config/design.xml -l test/resources/pmd_report_builder/project-test.xml] options = PmdTester::Options.new(argv) @@ -136,7 +136,7 @@ def test_build_normal_pmd7 ).once PmdTester::Cmd.stubs(:execute_successfully).with( "mv pmd-dist/target/exploded/pmd-bin-#{@pmd_version} " \ - "#{Dir.getwd}/target/pmd-bin-#{@pmd_version}-master-sha1abc" + "#{Dir.getwd}/target/pmd-bin-#{@pmd_version}-main-sha1abc" ).once record_expectations_after_build @@ -149,7 +149,7 @@ def test_build_with_projects project_list = 'test/resources/pmd_report_builder/project-list.xml' projects = PmdTester::ProjectsParser.new.parse(project_list) assert_equal(1, projects.size) - argv = %w[-r target/repositories/pmd -b master -p pmd_releases/6.1.0 + argv = %w[-r target/repositories/pmd -b main -p pmd_releases/6.1.0 -c config/design.xml --debug -l] argv.push project_list options = PmdTester::Options.new(argv) @@ -164,7 +164,7 @@ def test_build_with_projects .build expected = File.read('test/resources/pmd_report_builder/expected-config.xml') - actual = File.read('target/reports/master/checkstyle/config.xml') + actual = File.read('target/reports/main/checkstyle/config.xml') assert_equal(expected, actual) end @@ -172,7 +172,7 @@ def test_build_error_recovery project_list = 'test/resources/pmd_report_builder/project-list.xml' projects = PmdTester::ProjectsParser.new.parse(project_list) assert_equal(1, projects.size) - argv = %w[-r target/repositories/pmd -b master -p pmd_releases/6.1.0 + argv = %w[-r target/repositories/pmd -b main -p pmd_releases/6.1.0 -c config/design.xml --debug --error-recovery -l] argv.push project_list options = PmdTester::Options.new(argv) @@ -192,7 +192,7 @@ def test_build_long_cli_options project_list = 'test/resources/pmd_report_builder/project-list.xml' projects = PmdTester::ProjectsParser.new.parse(project_list) assert_equal(1, projects.size) - argv = %w[-r target/repositories/pmd -b master -p pmd_releases/6.1.0 + argv = %w[-r target/repositories/pmd -b main -p pmd_releases/6.1.0 -c config/design.xml --debug --error-recovery -l] argv.push project_list options = PmdTester::Options.new(argv) @@ -213,7 +213,7 @@ def test_build_pmd7 project_list = 'test/resources/pmd_report_builder/project-list.xml' projects = PmdTester::ProjectsParser.new.parse(project_list) assert_equal(1, projects.size) - argv = %w[-r target/repositories/pmd -b master -p pmd_releases/6.1.0 + argv = %w[-r target/repositories/pmd -b main -p pmd_releases/6.1.0 -c config/design.xml --debug --error-recovery -l] argv.push project_list options = PmdTester::Options.new(argv) @@ -242,7 +242,7 @@ def test_build_failing project_list = 'test/resources/pmd_report_builder/project-list.xml' projects = PmdTester::ProjectsParser.new.parse(project_list) assert_equal(1, projects.size) - argv = %w[-r target/repositories/pmd -b master -p pmd_releases/6.1.0 + argv = %w[-r target/repositories/pmd -b main -p pmd_releases/6.1.0 -c config/design.xml --debug --error-recovery -l] argv.push project_list options = PmdTester::Options.new(argv) @@ -281,28 +281,28 @@ def record_expectations_project_build(sha1:, error: false, long_cli_options: fal PmdTester::SimpleProgressLogger.any_instance.stubs(:start).once PmdTester::SimpleProgressLogger.any_instance.stubs(:stop).once error_prefix = error ? 'PMD_JAVA_OPTS="-Dpmd.error_recovery -ea" ' : '' - distro_path = "#{Dir.getwd}/target/pmd-bin-#{@pmd_version}-master-#{sha1}" + distro_path = "#{Dir.getwd}/target/pmd-bin-#{@pmd_version}-main-#{sha1}" process_status = mock process_status.expects(:exitstatus).returns(exit_status).once PmdTester::Cmd.stubs(:execute) .with("#{error_prefix}" \ "#{distro_path}/bin/#{base_cmd} " \ '-d target/repositories/checkstyle -f xml ' \ - '-R target/reports/master/checkstyle/config.xml ' \ - '-r target/reports/master/checkstyle/pmd_report.xml ' \ + '-R target/reports/main/checkstyle/config.xml ' \ + '-r target/reports/main/checkstyle/pmd_report.xml ' \ "#{fail_on_violation} -t 1 #{auxclasspath_option}" \ "#{no_progress_bar ? ' --no-progress' : ''}", - 'target/reports/master/checkstyle').once + 'target/reports/main/checkstyle').once .returns(process_status) .once PmdTester::PmdReportDetail.stubs(:create).once.with { |params| params[:exit_code] == exit_status } end def record_expectations(sha1_head:, sha1_base:, zip_file_exists:) - PmdTester::Cmd.stubs(:execute_successfully).with('git rev-parse master^{commit}').returns(sha1_base).once + PmdTester::Cmd.stubs(:execute_successfully).with('git rev-parse main^{commit}').returns(sha1_base).once # inside checkout_build_branch - PmdTester::Cmd.stubs(:execute_successfully).with('git checkout master') - .returns('checked out branch master').once + PmdTester::Cmd.stubs(:execute_successfully).with('git checkout main') + .returns('checked out branch main').once PmdTester::Cmd.stubs(:execute_successfully).with( './mvnw -q -Dexec.executable="echo" ' \ "-Dexec.args='${project.version}' " \ @@ -313,7 +313,7 @@ def record_expectations(sha1_head:, sha1_base:, zip_file_exists:) # back into get_pmd_binary_file PmdTester::Cmd.stubs(:execute_successfully).with('git rev-parse HEAD^{commit}').returns(sha1_head).once # PMD binary might not exist yet... - distro_path = "target/pmd-bin-#{@pmd_version}-master-#{sha1_base}" + distro_path = "target/pmd-bin-#{@pmd_version}-main-#{sha1_base}" if zip_file_exists FileUtils.mkdir_p(distro_path) else @@ -324,13 +324,13 @@ def record_expectations(sha1_head:, sha1_base:, zip_file_exists:) def record_expectations_after_build PmdTester::Cmd.stubs(:execute_successfully).with('git log -1 --pretty=%B').returns('the commit message').once PmdTester::PmdBranchDetail.any_instance.stubs(:save).once - FileUtils.stubs(:cp).with('config/design.xml', 'target/reports/master/config.xml').once + FileUtils.stubs(:cp).with('config/design.xml', 'target/reports/main/config.xml').once end # Creates a fake pmd script file as .../bin/pmd. # This is used in the new PMD 7 CLI interface def prepare_pmd_dist_dir(version:, sha1:) - pmd_cli_cmd = "#{Dir.getwd}/target/pmd-bin-#{version}-master-#{sha1}/bin" + pmd_cli_cmd = "#{Dir.getwd}/target/pmd-bin-#{version}-main-#{sha1}/bin" FileUtils.mkdir_p(pmd_cli_cmd) File.new("#{pmd_cli_cmd}/pmd", 'w') pmd_cli_cmd diff --git a/test/test_runner.rb b/test/test_runner.rb index 12a3dd9..8fac6cf 100644 --- a/test/test_runner.rb +++ b/test/test_runner.rb @@ -72,7 +72,7 @@ def test_local_mode Project.any_instance.stubs(:compute_report_diff).twice SummaryReportBuilder.any_instance.stubs(:write_all_projects).once - argv = %w[-r target/repositories/pmd -b master -bc config/design.xml -p pmd_releases/6.1.0 + argv = %w[-r target/repositories/pmd -b main -bc config/design.xml -p pmd_releases/6.1.0 -pc config/design.xml -l test/resources/runner/project-test.xml] summarized_results = run_runner(argv) assert_summarized_diffs(summarized_results) @@ -90,7 +90,7 @@ def test_local_mode_multithreading Project.any_instance.stubs(:compute_report_diff).twice SummaryReportBuilder.any_instance.stubs(:write_all_projects).once - argv = %w[-r target/repositories/pmd -b master -bc config/design.xml -p pmd_releases/6.1.0 + argv = %w[-r target/repositories/pmd -b main -bc config/design.xml -p pmd_releases/6.1.0 -pc config/design.xml -l test/resources/runner/project-test.xml -t 5] summarized_results = run_runner(argv) assert_summarized_diffs(summarized_results) @@ -104,15 +104,15 @@ def test_online_mode File.stubs(:new).with('target/reports/diff/index.html', anything).returns.once Dir.stubs(:chdir).with('target/reports').yields.once - Cmd.stubs(:execute_successfully).with('wget --no-verbose --timestamping https://sourceforge.net/projects/pmd/files/pmd-regression-tester/master-baseline.zip').once - Cmd.stubs(:execute_successfully).with('unzip -qo master-baseline.zip').once + Cmd.stubs(:execute_successfully).with('wget --no-verbose --timestamping https://sourceforge.net/projects/pmd/files/pmd-regression-tester/main-baseline.zip').once + Cmd.stubs(:execute_successfully).with('unzip -qo main-baseline.zip').once ProjectsParser.any_instance.stubs(:parse) - .with('target/reports/master/project-list.xml') + .with('target/reports/main/project-list.xml') .returns([]).once PmdReportBuilder.any_instance.stubs(:build).returns(PmdBranchDetail.new('test_branch')).once - argv = %w[-r target/repositories/pmd -m online -b master -p pmd_releases/6.7.0] + argv = %w[-r target/repositories/pmd -m online -b main -p pmd_releases/6.7.0] summarized_results = run_runner(argv) assert_summarized_diffs(summarized_results) end @@ -122,7 +122,7 @@ def test_online_mode_multithreading Dir.stubs(:chdir).with('target/reports').yields.once Cmd.stubs(:execute_successfully).twice ProjectsParser.any_instance.stubs(:parse) - .with('target/reports/master/project-list.xml') + .with('target/reports/main/project-list.xml') .returns([]).once report_builder_mock = mock @@ -135,7 +135,7 @@ def test_online_mode_multithreading report_builder_mock.stubs(:build).returns(PmdBranchDetail.new('some_branch')).once SummaryReportBuilder.any_instance.stubs(:write_all_projects).once - argv = %w[-r target/repositories/pmd -m online -b master -p pmd_releases/6.7.0 -t 3] + argv = %w[-r target/repositories/pmd -m online -b main -p pmd_releases/6.7.0 -t 3] summarized_results = run_runner(argv) assert_summarized_diffs(summarized_results) end @@ -143,7 +143,7 @@ def test_online_mode_multithreading def test_online_mode_keep_reports_second_run_filtering FileUtils.mkdir_p 'target/reports/pmd_releases_6.7.0/checkstyle' # placing the baseline zip here avoid downloading it during test run - and we can craft it for the test - FileUtils.cp 'test/resources/runner/master-baseline.zip', 'target/reports' + FileUtils.cp 'test/resources/runner/main-baseline.zip', 'target/reports' # placing the report here avoids running PMD again - and we can craft it for the test FileUtils.cp 'test/resources/runner/pmd_report.xml', 'target/reports/pmd_releases_6.7.0/checkstyle/pmd_report.xml' @@ -152,7 +152,7 @@ def test_online_mode_keep_reports_second_run_filtering FileUtils.mkdir_p fake_pmd_bin begin - argv = %w[-r target/repositories/pmd -m online -b master -p pmd_releases/6.7.0 + argv = %w[-r target/repositories/pmd -m online -b main -p pmd_releases/6.7.0 --list-of-project test/resources/runner/project-list.xml --keep-reports --filter-with-patch-config --patch-config test/resources/runner/patch-config.xml]