File tree Expand file tree Collapse file tree 3 files changed +65
-0
lines changed Expand file tree Collapse file tree 3 files changed +65
-0
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,8 @@ install:
140
140
script :
141
141
# fail fast
142
142
- set -e
143
+ # fail if the test files have changes
144
+ - bin/utils/detect_test_file_changes.rb bin/utils/test_file_list.yaml
143
145
# fail if templates/generators contain carriage return '\r'
144
146
- /bin/bash ./bin/utils/detect_carriage_return.sh
145
147
# fail if generators contain merge conflicts
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env ruby
2
+ # ruby script to detect changes in test-related files
3
+ require 'yaml'
4
+ require 'digest'
5
+
6
+ hash = Digest ::SHA256 . hexdigest ( "xyz" )
7
+
8
+ filename = ARGV [ 0 ]
9
+
10
+ if !filename
11
+ puts "Usage: #{ $0} filename"
12
+ exit 1
13
+ end
14
+
15
+ if !File . file? filename
16
+ warn "Error. #{ filename } doesn't exist."
17
+ exit 1
18
+ end
19
+
20
+ mismatch = 0
21
+ count = 0
22
+
23
+ test_files = YAML . load_file ( filename )
24
+ test_files . each do |test_file |
25
+ count = count + 1
26
+ # file still exists?
27
+ if !File . file? test_file [ 'filename' ]
28
+ warn "Error. Provided test file `#{ test_file [ 'filename' ] } ` doesn't exist."
29
+ mismatch = mismatch + 1
30
+ end
31
+
32
+ # check sha256 hash
33
+ sha256 = Digest ::SHA256 . hexdigest ( File . read ( test_file [ 'filename' ] ) )
34
+ if test_file [ 'sha256' ] != sha256
35
+ 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' ] } "
36
+ mismatch = mismatch + 1
37
+ else
38
+ # no change to the test file
39
+ end
40
+ end
41
+
42
+ if mismatch > 0
43
+ warn "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
44
+ warn "There are #{ mismatch } mismatch. Please review the test files to ensure it has not been deleted/regenerated."
45
+ warn "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
46
+ exit 1
47
+ else
48
+ puts "OK. All matched!"
49
+ end
50
+
51
+ if count == 0
52
+ warn "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
53
+ warn "Looks like the test file list in #{ filename } is empty! Please check!"
54
+ warn "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
55
+ exit 1
56
+ end
57
+
Original file line number Diff line number Diff line change
1
+ ---
2
+ # csharp-netcore test files and image for upload
3
+ - filename : " samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs"
4
+ sha256 : b74ef9eefa4b41fd3233e083fe2355babf25a77f9073d28e1aa81ae2e0a5f1d0
5
+ - filename : " samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/linux-logo.png"
6
+ sha256 : 0a67c32728197e942b13bdda064b73793f12f5c795f1e5cf35a3adf69c973230
You can’t perform that action at this time.
0 commit comments