1
1
import * as assert from 'assert'
2
- import * as utils from '../support/utils'
2
+ import * as shared_utils from '../../../shared /support/utils'
3
3
import { randomBytes } from 'crypto'
4
4
import { BundleServerWorld , User } from '../support/world'
5
5
import { Given , When , Then } from '@cucumber/cucumber'
@@ -14,36 +14,36 @@ Given('another user pushed {int} commits to {string}', async function (this: Bun
14
14
const clonedRepo = this . getRepoAtBranch ( User . Another , branch )
15
15
16
16
for ( let i = 0 ; i < commitNum ; i ++ ) {
17
- utils . assertStatus ( 0 , clonedRepo . runShell ( `echo ${ randomBytes ( 16 ) . toString ( 'hex' ) } >README.md` ) )
18
- utils . assertStatus ( 0 , clonedRepo . runGit ( "add" , "README.md" ) )
19
- utils . assertStatus ( 0 , clonedRepo . runGit ( "commit" , "-m" , `test ${ i + 1 } ` ) )
17
+ shared_utils . assertStatus ( 0 , clonedRepo . runShell ( `echo ${ randomBytes ( 16 ) . toString ( 'hex' ) } >README.md` ) )
18
+ shared_utils . assertStatus ( 0 , clonedRepo . runGit ( "add" , "README.md" ) )
19
+ shared_utils . assertStatus ( 0 , clonedRepo . runGit ( "commit" , "-m" , `test ${ i + 1 } ` ) )
20
20
}
21
- utils . assertStatus ( 0 , clonedRepo . runGit ( "push" , "origin" , branch ) )
21
+ shared_utils . assertStatus ( 0 , clonedRepo . runGit ( "push" , "origin" , branch ) )
22
22
} )
23
23
24
24
Given ( 'another user removed {int} commits and added {int} commits to {string}' ,
25
25
async function ( this : BundleServerWorld , removeCommits : number , addCommits : number , branch : string ) {
26
26
const clonedRepo = this . getRepoAtBranch ( User . Another , branch )
27
27
28
28
// First, reset
29
- utils . assertStatus ( 0 , clonedRepo . runGit ( "reset" , "--hard" , `HEAD~${ removeCommits } ` ) )
29
+ shared_utils . assertStatus ( 0 , clonedRepo . runGit ( "reset" , "--hard" , `HEAD~${ removeCommits } ` ) )
30
30
31
31
// Then, add new commits
32
32
for ( let i = 0 ; i < addCommits ; i ++ ) {
33
- utils . assertStatus ( 0 , clonedRepo . runShell ( `echo ${ randomBytes ( 16 ) . toString ( 'hex' ) } >README.md` ) )
34
- utils . assertStatus ( 0 , clonedRepo . runGit ( "add" , "README.md" ) )
35
- utils . assertStatus ( 0 , clonedRepo . runGit ( "commit" , "-m" , `test ${ i + 1 } ` ) )
33
+ shared_utils . assertStatus ( 0 , clonedRepo . runShell ( `echo ${ randomBytes ( 16 ) . toString ( 'hex' ) } >README.md` ) )
34
+ shared_utils . assertStatus ( 0 , clonedRepo . runGit ( "add" , "README.md" ) )
35
+ shared_utils . assertStatus ( 0 , clonedRepo . runGit ( "commit" , "-m" , `test ${ i + 1 } ` ) )
36
36
}
37
37
38
38
// Finally, force push
39
- utils . assertStatus ( 0 , clonedRepo . runGit ( "push" , "-f" , "origin" , branch ) )
39
+ shared_utils . assertStatus ( 0 , clonedRepo . runGit ( "push" , "-f" , "origin" , branch ) )
40
40
}
41
41
)
42
42
43
43
Given ( 'I cloned from the remote repo with a bundle URI' , async function ( this : BundleServerWorld ) {
44
44
const user = User . Me
45
45
this . cloneRepositoryFor ( user , this . bundleServer . bundleUri ( ) )
46
- utils . assertStatus ( 0 , this . getRepo ( user ) . cloneResult )
46
+ shared_utils . assertStatus ( 0 , this . getRepo ( user ) . cloneResult )
47
47
} )
48
48
49
49
When ( 'I clone from the remote repo with a bundle URI' , async function ( this : BundleServerWorld ) {
@@ -56,14 +56,14 @@ When('another developer clones from the remote repo without a bundle URI', async
56
56
57
57
When ( 'I fetch from the remote' , async function ( this : BundleServerWorld ) {
58
58
const clonedRepo = this . getRepo ( User . Me )
59
- utils . assertStatus ( 0 , clonedRepo . runGit ( "fetch" , "origin" ) )
59
+ shared_utils . assertStatus ( 0 , clonedRepo . runGit ( "fetch" , "origin" ) )
60
60
} )
61
61
62
62
Then ( 'bundles are downloaded and used' , async function ( this : BundleServerWorld ) {
63
63
const clonedRepo = this . getRepo ( User . Me )
64
64
65
65
// Verify the clone executed as-expected
66
- utils . assertStatus ( 0 , clonedRepo . cloneResult , "git clone failed" )
66
+ shared_utils . assertStatus ( 0 , clonedRepo . cloneResult , "git clone failed" )
67
67
68
68
// Ensure warning wasn't thrown
69
69
clonedRepo . cloneResult . stderr . toString ( ) . split ( "\n" ) . forEach ( function ( line ) {
@@ -74,12 +74,12 @@ Then('bundles are downloaded and used', async function (this: BundleServerWorld)
74
74
75
75
// Make sure the config is set up properly
76
76
let result = clonedRepo . runGit ( "config" , "--get" , "fetch.bundleURI" )
77
- utils . assertStatus ( 0 , result , "'fetch.bundleURI' is not set after clone" )
77
+ shared_utils . assertStatus ( 0 , result , "'fetch.bundleURI' is not set after clone" )
78
78
const actualURI = result . stdout . toString ( ) . trim ( )
79
79
assert . strictEqual ( actualURI , this . bundleServer . bundleUri ( ) )
80
80
81
81
result = clonedRepo . runGit ( "for-each-ref" , "--format=%(refname)" , "refs/bundles/*" )
82
- utils . assertStatus ( 0 , result , "git for-each-ref failed" )
82
+ shared_utils . assertStatus ( 0 , result , "git for-each-ref failed" )
83
83
84
84
const bundleRefs = result . stdout . toString ( ) . split ( "\n" ) . filter ( function ( line ) {
85
85
return line . trim ( ) != ""
@@ -90,7 +90,7 @@ Then('bundles are downloaded and used', async function (this: BundleServerWorld)
90
90
Then ( 'I am up-to-date with {string}' , async function ( this : BundleServerWorld , branch : string ) {
91
91
const clonedRepo = this . getRepo ( User . Me )
92
92
const result = clonedRepo . runGit ( "rev-parse" , `refs/remotes/origin/${ branch } ` )
93
- utils . assertStatus ( 0 , result )
93
+ shared_utils . assertStatus ( 0 , result )
94
94
const actualOid = result . stdout . toString ( ) . trim ( )
95
95
const expectedOid = this . remote ?. getBranchTipOid ( branch )
96
96
assert . strictEqual ( actualOid , expectedOid , `branch '${ branch } ' is not up-to-date` )
@@ -100,7 +100,7 @@ Then('my repo\'s bundles {boolean} up-to-date with {string}',
100
100
async function ( this : BundleServerWorld , expectedUpToDate : boolean , branch : string ) {
101
101
const clonedRepo = this . getRepo ( User . Me )
102
102
const result = clonedRepo . runGit ( "rev-parse" , `refs/bundles/${ branch } ` )
103
- utils . assertStatus ( 0 , result )
103
+ shared_utils . assertStatus ( 0 , result )
104
104
const actualOid = result . stdout . toString ( ) . trim ( )
105
105
const expectedOid = this . remote ?. getBranchTipOid ( branch )
106
106
@@ -117,8 +117,8 @@ Then('I compare the clone execution times', async function (this: BundleServerWo
117
117
const otherClone = this . getRepo ( User . Another )
118
118
119
119
// Verify the clones succeeded
120
- utils . assertStatus ( 0 , myClone . cloneResult )
121
- utils . assertStatus ( 0 , otherClone . cloneResult )
120
+ shared_utils . assertStatus ( 0 , myClone . cloneResult )
121
+ shared_utils . assertStatus ( 0 , otherClone . cloneResult )
122
122
123
123
console . log ( `\nClone execution time for ${ this . remote ! . remoteUri } : ${ ( myClone . cloneTimeMs / 1000 ) . toFixed ( 2 ) } s (bundle URI) vs. ${ ( otherClone . cloneTimeMs / 1000 ) . toFixed ( 2 ) } s (no bundle URI)` )
124
124
} )
0 commit comments