Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !8020

Add a script to detect changes in test files

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged William Cheng requested to merge show_test_warning into master 4 years ago
  • Overview 0
  • Commits 3
  • Pipelines 0
  • Changes 3

Add a script to detect changes in test files to avoid deleted test files or regenerated test files with no actual test case.

cc @OpenAPITools/generator-core-team

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.
Compare
  • master (base)

and
  • latest version
    8375f607
    3 commits, 2 years ago

3 files
+ 65
- 0

    Preferences

    File browser
    Compare changes
bin/‎utils‎
detect_test_f‎ile_changes.rb‎ +57 -0
test_file‎_list.yaml‎ +6 -0
.trav‎is.yml‎ +2 -0
bin/utils/detect_test_file_changes.rb 0 → 100755
+ 57
- 0
  • View file @ 8375f607

  • Edit in single-file editor

  • Open in Web IDE

#!/usr/bin/env ruby
# ruby script to detect changes in test-related files
require 'yaml'
require 'digest'
hash = Digest::SHA256.hexdigest("xyz")
filename= ARGV[0]
if !filename
puts "Usage: #{$0} filename"
exit 1
end
if !File.file? filename
warn "Error. #{filename} doesn't exist."
exit 1
end
mismatch = 0
count = 0
test_files = YAML.load_file(filename)
test_files.each do |test_file|
count = count + 1
# file still exists?
if !File.file? test_file['filename']
warn "Error. Provided test file `#{test_file['filename']}` doesn't exist."
mismatch = mismatch + 1
end
# check sha256 hash
sha256 = Digest::SHA256.hexdigest(File.read(test_file['filename']))
if test_file['sha256'] != sha256
warn "Looks like #{test_file['filename']} has been modified as its SHA256 `#{sha256}` is not the same as the one in the record: #{test_file['sha256']}"
mismatch = mismatch + 1
else
# no change to the test file
end
end
if mismatch > 0
warn "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
warn "There are #{mismatch} mismatch. Please review the test files to ensure it has not been deleted/regenerated."
warn "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit 1
else
puts "OK. All matched!"
end
if count == 0
warn "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
warn "Looks like the test file list in #{filename} is empty! Please check!"
warn "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit 1
end
bin/utils/test_file_list.yaml 0 → 100644
+ 6
- 0
  • View file @ 8375f607

  • Edit in single-file editor

  • Open in Web IDE

---
# csharp-netcore test files and image for upload
- filename: "samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs"
sha256: b74ef9eefa4b41fd3233e083fe2355babf25a77f9073d28e1aa81ae2e0a5f1d0
- filename: "samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/linux-logo.png"
sha256: 0a67c32728197e942b13bdda064b73793f12f5c795f1e5cf35a3adf69c973230
.travis.yml
+ 2
- 0
  • View file @ 8375f607

  • Edit in single-file editor

  • Open in Web IDE


@@ -140,6 +140,8 @@ install:
script:
# fail fast
- set -e
# fail if the test files have changes
- bin/utils/detect_test_file_changes.rb bin/utils/test_file_list.yaml
# fail if templates/generators contain carriage return '\r'
- /bin/bash ./bin/utils/detect_carriage_return.sh
# fail if generators contain merge conflicts
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
1
Enhancement: CI/Test
1
Enhancement: CI/Test
    Assign labels
  • Manage project labels

Milestone
5.0.0
5.0.0 (expired)
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
1
1 participant
William Cheng
Reference: OpenAPITools/openapi-generator!8020
Source branch: show_test_warning

Menu

Explore Projects Groups Snippets