File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7474 with :
7575 path-to-lcov : coverage/lcov.info
7676 parallel : true
77- flag-name : ${{ matrix.os }}
77+ flag-name : ${{ matrix.os }}-unit
7878
7979 coverage-integration :
8080 needs : fmt
9191 RUSTFLAGS="-C instrument-coverage" cargo build
9292 echo "$PWD/target/debug" >> $GITHUB_PATH
9393
94+ # testing for installing multiple of the same thing at once is ok
95+ - run : pkgx +gnome.org/libxml2 & pkgx +gnome.org/libxml2 & pkgx +gnome.org/libxml2
96+ # ^^ KEEP FIRST, IT MUST INSTALL
97+
9498 - run : pkgx --help
9599 - run : pkgx --version
96100 - run : pkgx +git
@@ -114,6 +118,15 @@ jobs:
114118 # testing we correctly handle +pkg syntax for pkgs with no env
115119 - run : pkgx +curl.se/ca-certs
116120
121+ # create a fork bomb, but since it’s via pkgx we prevent it
122+ - run : |
123+ echo '#!/bin/sh' > foo
124+ echo 'pkgx -- /bin/sh "$0"' >> foo
125+ chmod u+x foo
126+ if ./foo; then
127+ exit 1
128+ fi
129+
117130 - name : generate coverage
118131 run : |
119132 cargo install rustfilt
@@ -130,10 +143,10 @@ jobs:
130143 with :
131144 path-to-lcov : lcov.info
132145 parallel : true
133- flag-name : ${{ matrix.os }}
146+ flag-name : ${{ matrix.os }}-integration
134147
135148 upload-coverage :
136- needs : [coverage-unit, coverage-integration, test ]
149+ needs : [coverage-unit, coverage-integration]
137150 runs-on : ubuntu-latest
138151 steps :
139152 - uses : coverallsapp/github-action@v2
Original file line number Diff line number Diff line change @@ -39,18 +39,30 @@ where
3939 fs:: create_dir_all ( & shelf) ?;
4040 let shelf = OpenOptions :: new ( )
4141 . read ( true ) // Open the directory in read-only mode
42- . open ( shelf) ?;
42+ . open ( shelf. clone ( ) ) ?;
4343
4444 task:: spawn_blocking ( {
4545 let shelf = shelf. try_clone ( ) ?;
4646 move || {
4747 shelf
4848 . lock_exclusive ( )
49- . expect ( "couldn’t obtain lock, is another pkgx instance running? " ) ;
49+ . expect ( "unexpected error: install locking failed " ) ;
5050 }
5151 } )
5252 . await ?;
5353
54+ let dst_path = cellar:: dst ( pkg, config) ;
55+
56+ // did another instance of pkx install us while we waited for the lock?
57+ // if so, we’re good: eject
58+ if fs:: exists ( dst_path. clone ( ) ) ? {
59+ FileExt :: unlock ( & shelf) ?;
60+ return Ok ( Installation {
61+ path : dst_path,
62+ pkg : pkg. clone ( ) ,
63+ } ) ;
64+ }
65+
5466 let url = inventory:: get_url ( pkg, config) ;
5567 let client = Client :: new ( ) ;
5668 let rsp = client. get ( url) . send ( ) . await ?. error_for_status ( ) ?;
8698 archive. unpack ( & config. pkgx_dir ) . await ?;
8799
88100 let installation = Installation {
89- path : cellar :: dst ( pkg , config ) ,
101+ path : dst_path ,
90102 pkg : pkg. clone ( ) ,
91103 } ;
92104
You can’t perform that action at this time.
0 commit comments