-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
186 lines (162 loc) · 4.54 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package main
import (
"log"
"regexp"
"testing"
)
const (
testStr = `versionName "1.0start"
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}
android {
compileSdk 31
defaultConfig {
as12-."3
}
defaultConfig {
comment
applicationId "com.plcoding.cryptocurrencyappyt"
minSdk 21
targetSdk 31
versionCode 1
// versionName "1comment"
versionName "1aftercomment"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
defaultConfig {
versionCode 1
versionName "2before"
}
productFlavors {
demo {
...
versionName "1.1-demo"
}
full {
...
}
}
defaultConfig {
1 before 1 after
applicationId "com.plcoding.cryptocurrencyappyt"
minSdk 21
vectorDrawables {
useSupportLibrary true
vectorDrawables {
useSupportLibrary true
}
vectorDrawables {
useSupportLibrary true
vectorDrawables {
useSupportLibrary true
}
}
}
targetSdk 31
versionCode 1
// versionName "3-before and after"
versionName "1 before 1 after"
vectorDrawables {
useSupportLibrary true
vectorDrawables {
useSupportLibrary true
}
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
defaultConfig {
1 after
applicationId "com.plcoding.cryptocurrencyappyt"
minSdk 21
targetSdk 31
versionCode 1
versionName "1after"
// versionName "1after-comment"
vectorDrawables {
useSupportLibrary true
versionName "invector"
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
useIR = true
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion '1.5.21'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
// Compose dependencies
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha07"
implementation "androidx.navigation:navigation-compose:2.4.0-alpha08"
implementation "com.google.accompanist:accompanist-flowlayout:0.17.0"
// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1'
// Coroutine Lifecycle Scopes
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"
//Dagger - Hilt
implementation "com.google.dagger:hilt-android:2.38.1"
kapt "com.google.dagger:hilt-android-compiler:2.37"
implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03"
kapt "androidx.hilt:hilt-compiler:1.0.0"
implementation 'androidx.hilt:hilt-navigation-compose:1.0.0-alpha03'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.2"
implementation "com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2"
}`
)
func TestUnmarshalGradle(t *testing.T) {
regexStr := `defaultConfig {[^{}]*([^{}]*{[\s\S]*}[^{}]*)*[^{}]*\n[\t ]*versionName "(.+)"`
regex, err := regexp.Compile(regexStr)
if err != nil {
t.Error(err)
}
res := regex.FindAllStringSubmatch(testStr, -1)
if len(res) == 0 {
t.Error("regex err: ", res)
}
for r := range res {
log.Println(res[r][2])
}
}