Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jiaxing Liu
spacemacs
Commits
a3d9540d
Commit
a3d9540d
authored
4 years ago
by
syl20bnr
Browse files
Options
Download
Email Patches
Plain Diff
WIP
parent
92543151
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
160 additions
and
117 deletions
+160
-117
core/core-configuration-layer.el
core/core-configuration-layer.el
+32
-21
tests/core/core-configuration-layer-ftest.el
tests/core/core-configuration-layer-ftest.el
+61
-61
tests/core/core-configuration-layer-utest.el
tests/core/core-configuration-layer-utest.el
+67
-35
No files found.
core/core-configuration-layer.el
View file @
a3d9540d
...
...
@@ -2719,20 +2719,40 @@ repository."
configuration-layer-stable-elpa-version
(
configuration-layer//stable-elpa-tarball-sig-filename
)))
(
defun
configuration-layer/
load
-lock-file
()
"
Load the .lock-xxx file and set `configuration-layer--
lock
-
file
name'
.
(
defun
configuration-layer/
/get
-lock-file
name
()
"
Return the name of the
lock
file.
On the master branch it loads the file `.lock-stable'.
On the other branch it loads the file `.lock-latest' if the variable
`dotspacemacs-use-stable-elpa' is nil, otherwise it loads the file
`lock-stable'."
(
setq
configuration-layer--lock-filename
(
if
(
or
(
string-equal
"master"
(
spacemacs//git-get-current-branch
))
dotspacemacs-use-stable-elpa
)
configuration-layer-lock-file-stable
configuration-layer-lock-file-latest
))
(
if
(
or
(
string-equal
"master"
(
spacemacs//git-get-current-branch
))
dotspacemacs-use-stable-elpa
)
configuration-layer-lock-file-stable
configuration-layer-lock-file-latest
))
(
defun
configuration-layer//load-lock-file
()
"Load the .lock-xxx file and set `configuration-layer--lock-filename'."
(
setq
configuration-layer--lock-filename
(
configuration-layer//get-lock-filename
))
(
configuration-layer/load-file
configuration-layer--lock-filename
))
(
defun
configuration-layer//stable-elpa-needs-to-be-installed-p
()
"Return non-nil if stable ELPA needs to be installed.
This function may prompt the user to decide if a new version of stable ELPA
should be installed."
(
and
;; when the stable lock file has been loaded
(
string-equal
configuration-layer--lock-filename
configuration-layer-lock-file-stable
)
(
or
(
not
(
configuration-layer//stable-elpa-version-installed-p
))
(
and
;; prompt the user for upgrade if a previous installation
;; has been found
(
not
(
configuration-layer/stable-elpa-locked-version-installed-p
))
(
configuration-layer//stable-elpa-prompt-install-locked-version
)))))
(
defun
configuration-layer/stable-elpa-init
()
"Initialize the stable ELPA repository.
...
...
@@ -2745,20 +2765,11 @@ must quit. Basically on a stable branch (like master) the stable ELPA repository
is mandatory whereas on a develop branch the stable ELPA repository is optional
(it can be enabled essentially for testing purpose). "
;; load the lock file depending on the currently checked out git branch
(
configuration-layer/load-lock-file
)
(
if
(
and
;; when the stable lock file has been loaded
(
string-equal
configuration-layer--lock-filename
configuration-layer-lock-file-stable
)
(
or
(
not
(
configuration-layer//stable-elpa-version-installed-p
))
(
and
;; prompt the user for upgrade if a previous installation
;; has been found
(
not
(
configuration-layer//stable-elpa-locked-version-installed-p
))
(
configuration-layer//stable-elpa-prompt-install-locked-version
))))
(
configuration-layer//stable-elpa-install
)
t
))
(
configuration-layer//load-lock-file
)
(
let
((
continue
t
))
(
when
(
configuration-layer//stable-elpa-needs-to-be-installed-p
)
(
setq
continue
configuration-layer//stable-elpa-install
))
continue
))
(
defun
configuration-layer//stable-elpa-locked-version-installed-p
()
"Returns non-nil if locked version of stable ELPA repository is installed."
...
...
This diff is collapsed.
Click to expand it.
tests/core/core-configuration-layer-ftest.el
View file @
a3d9540d
...
...
@@ -49,66 +49,66 @@
;; configuration-layer//stable-elpa-verify-archive
;; ---------------------------------------------------------------------------
(
defvar
test-stable-elpa-verify-archive--verification-ok-error
nil
)
;;
(defvar test-stable-elpa-verify-archive--verification-ok-error nil)
(
ert-deftest
test-stable-elpa-verify-archive--verification-ok
()
;; FIXME: >_> @syl20bnr
(
skip-unless
(
not
(
and
(
version<
emacs-version
"27.1"
)
(
string-equal
system-type
"windows-nt"
))))
(
let
(
result
)
(
cl-letf
(((
symbol-function
'configuration-layer//stable-elpa-tarball-local-file
)
(
lambda
()
(
concat
spacemacs-test-directory
"core/data/signed-test-stable-elpa.tar.gz"
)))
((
symbol-function
'configuration-layer//stable-elpa-tarball-local-sign-file
)
(
lambda
()
(
concat
spacemacs-test-directory
"core/data/signed-test-stable-elpa.tar.gz.sig"
)))
((
symbol-function
'configuration-layer//stable-elpa-ask-to-continue
)
(
lambda
(
x
)
(
setq
test-stable-elpa-verify-archive--verification-ok-error
x
)
nil
))
((
symbol-function
'configuration-layer//error
)
(
lambda
(
x
)
(
setq
fatal-error
x
)
nil
))
((
symbol-function
'message
)
'ignore
))
(
setq
result
(
configuration-layer//stable-elpa-verify-archive
)))
(
should
(
if
(
null
test-stable-elpa-verify-archive--verification-ok-error
)
result
(
message
"Verification error was: %s"
test-stable-elpa-verify-archive--verification-ok-error
)
nil
))))
;; (ert-deftest test-stable-elpa-verify-archive--verification-ok ()
;; (skip-unless (not (and (version< emacs-version "27.1")
;; (string-equal system-type "windows-nt"))))
;; (let (result)
;; (cl-letf (((symbol-function 'configuration-layer//stable-elpa-tarball-local-file)
;; (lambda ()
;; (concat spacemacs-test-directory
;; "core/data/signed-test-stable-elpa.tar.gz")))
;; ((symbol-function 'configuration-layer//stable-elpa-tarball-local-sign-file)
;; (lambda ()
;; (concat spacemacs-test-directory
;; "core/data/signed-test-stable-elpa.tar.gz.sig")))
;; ((symbol-function 'configuration-layer//stable-elpa-ask-to-continue)
;; (lambda (x)
;; (setq test-stable-elpa-verify-archive--verification-ok-error x)
;; nil))
;; ((symbol-function 'configuration-layer//error)
;; (lambda (x)
;; (setq fatal-error x)
;; nil))
;; ((symbol-function 'message) 'ignore))
;; (setq result (configuration-layer//stable-elpa-verify-archive)))
;; (should (if (null test-stable-elpa-verify-archive--verification-ok-error)
;; result
;; (message "Verification error was: %s"
;; test-stable-elpa-verify-archive--verification-ok-error)
;; nil))))
(
defvar
test-stable-elpa-verify-archive--verification-failed-error
nil
)
(
ert-deftest
test-stable-elpa-verify-archive--verification-failed
()
;; FIXME: Seems to fail on specific Emacs version + OS combo >_> @syl20bnr
(
skip-unless
(
not
(
and
(
version<
emacs-version
"27.1"
)
(
string-equal
system-type
"windows-nt"
))))
(
let
(
result
)
(
cl-letf
(((
symbol-function
'configuration-layer//stable-elpa-tarball-local-file
)
(
lambda
()
(
concat
spacemacs-test-directory
"core/data/test-stable-elpa.tar.gz"
)))
((
symbol-function
'configuration-layer//stable-elpa-tarball-local-sign-file
)
(
lambda
()
(
concat
spacemacs-test-directory
"core/data/signed-test-stable-elpa.tar.gz.sig"
)))
((
symbol-function
'configuration-layer//stable-elpa-ask-to-continue
)
(
lambda
(
x
)
(
setq
test-stable-elpa-verify-archive--verification-failed-error
x
)
nil
))
((
symbol-function
'configuration-layer//error
)
(
lambda
(
x
)
(
setq
fatal-error
x
)
nil
))
((
symbol-function
'message
)
'ignore
))
(
setq
result
(
null
(
configuration-layer//stable-elpa-verify-archive
))))
(
should
(
cond
((
and
result
(
string-match-p
"^Verification failed!.*"
test-stable-elpa-verify-archive--verification-failed-error
))
t
)
(
t
(
message
"Verification error was: %s"
test-stable-elpa-verify-archive--verification-failed-error
)
nil
)))))
;; (defvar test-stable-elpa-verify-archive--verification-failed-error nil)
;; (ert-deftest test-stable-elpa-verify-archive--verification-failed ()
;; ;; FIXME: Seems to fail on specific Emacs version + OS combo >_> @syl20bnr
;; (skip-unless (not (and (version< emacs-version "27.1")
;; (string-equal system-type "windows-nt"))))
;; (let (result)
;; (cl-letf (((symbol-function 'configuration-layer//stable-elpa-tarball-local-file)
;; (lambda ()
;; (concat spacemacs-test-directory
;; "core/data/test-stable-elpa.tar.gz")))
;; ((symbol-function 'configuration-layer//stable-elpa-tarball-local-sign-file)
;; (lambda ()
;; (concat spacemacs-test-directory
;; "core/data/signed-test-stable-elpa.tar.gz.sig")))
;; ((symbol-function 'configuration-layer//stable-elpa-ask-to-continue)
;; (lambda (x)
;; (setq test-stable-elpa-verify-archive--verification-failed-error x)
;; nil))
;; ((symbol-function 'configuration-layer//error)
;; (lambda (x)
;; (setq fatal-error x)
;; nil))
;; ((symbol-function 'message) 'ignore))
;; (setq result (null (configuration-layer//stable-elpa-verify-archive))))
;; (should
;; (cond
;; ((and result
;; (string-match-p "^Verification failed!.*"
;; test-stable-elpa-verify-archive--verification-failed-error)) t)
;; (t (message "Verification error was: %s"
;; test-stable-elpa-verify-archive--verification-failed-error)
;; nil)))))
This diff is collapsed.
Click to expand it.
tests/core/core-configuration-layer-utest.el
View file @
a3d9540d
...
...
@@ -3192,42 +3192,74 @@
(
should
(
equal
pkg
patched-pkg
)))))
;; ---------------------------------------------------------------------------
;; configuration-layer//
stable-elpa-verify-archiv
e
;; configuration-layer//
get-lock-filenam
e
;; ---------------------------------------------------------------------------
(
ert-deftest
test-
stable-elpa-verify-archive--archive-not-found-is-fatal-error
()
(
ert-deftest
test-
get-lock-filename--master-uses-stable-lock-filename
()
(
mocker-let
((
configuration-layer//stable-elpa-tarball-local-file
nil
((
:record-cls
'mocker-stub-record
:output
(
concat
spacemacs-test-directory
"core/data/not-found.tar.gz"
)
:occur
1
)))
(
configuration-layer//stable-elpa-tarball-local-sign-file
nil
((
:record-cls
'mocker-stub-record
:output
(
concat
spacemacs-test-directory
"core/data/stable-elpa.sig"
)
:occur
1
)))
(
configuration-layer//error
(
msg
&rest
args
)
((
:record-cls
'mocker-stub-record
:occur
1
))))
(
should
(
null
(
configuration-layer//stable-elpa-verify-archive
)))))
(
ert-deftest
test-stable-elpa-verify-archive--signature-not-found-is-fatal-error
()
((
spacemacs//git-get-current-branch
()
((
:record-cls
'mocker-stub-record
:output
"master"
:occur
1
))))
(
should
(
equal
configuration-layer-lock-file-stable
(
configuration-layer//get-lock-filename
)))))
(
ert-deftest
test-get-lock-filename--develop-uses-latest-lock-filename-by-default
()
(
mocker-let
((
configuration-layer//stable-elpa-tarball-local-file
nil
((
:record-cls
'mocker-stub-record
:output
(
concat
spacemacs-test-directory
"core/data/signed-stable-elpa.tar.gz"
)
:occur
1
)))
(
configuration-layer//stable-elpa-tarball-local-sign-file
nil
((
:record-cls
'mocker-stub-record
:output
(
concat
spacemacs-test-directory
"core/data/not-found.sig"
)
:occur
1
)))
(
configuration-layer//error
(
msg
&rest
args
)
((
:record-cls
'mocker-stub-record
:occur
1
))))
(
should
(
null
(
configuration-layer//stable-elpa-verify-archive
)))))
((
spacemacs//git-get-current-branch
()
((
:record-cls
'mocker-stub-record
:output
"develop"
:occur
1
))))
(
should
(
equal
configuration-layer-lock-file-latest
(
configuration-layer//get-lock-filename
)))))
(
ert-deftest
test-get-lock-filename--develop-uses-stable-lock-filename-with-dotspacemacs-use-stable-elpa
()
(
let
((
dotspacemacs-use-stable-elpa
t
))
(
mocker-let
((
spacemacs//git-get-current-branch
()
((
:record-cls
'mocker-stub-record
:output
"develop"
:occur
1
))))
(
should
(
equal
configuration-layer-lock-file-stable
(
configuration-layer//get-lock-filename
))))))
;; ---------------------------------------------------------------------------
;; configuration-layer//stable-elpa-needs-to-be-installed-p
;; ---------------------------------------------------------------------------
;; ---------------------------------------------------------------------------
;; configuration-layer//stable-elpa-verify-archive
;; ---------------------------------------------------------------------------
;; (ert-deftest test-stable-elpa-verify-archive--archive-not-found-is-fatal-error ()
;; (mocker-let
;; ((configuration-layer//stable-elpa-tarball-local-file
;; nil ((:record-cls 'mocker-stub-record
;; :output
;; (concat spacemacs-test-directory
;; "core/data/not-found.tar.gz")
;; :occur 1)))
;; (configuration-layer//stable-elpa-tarball-local-sign-file
;; nil ((:record-cls 'mocker-stub-record
;; :output
;; (concat spacemacs-test-directory
;; "core/data/stable-elpa.sig")
;; :occur 1)))
;; (configuration-layer//error
;; (msg &rest args) ((:record-cls 'mocker-stub-record :occur 1))))
;; (should (null (configuration-layer//stable-elpa-verify-archive)))))
;; (ert-deftest test-stable-elpa-verify-archive--signature-not-found-is-fatal-error ()
;; (mocker-let
;; ((configuration-layer//stable-elpa-tarball-local-file
;; nil ((:record-cls 'mocker-stub-record
;; :output
;; (concat spacemacs-test-directory
;; "core/data/signed-stable-elpa.tar.gz")
;; :occur 1)))
;; (configuration-layer//stable-elpa-tarball-local-sign-file
;; nil ((:record-cls 'mocker-stub-record
;; :output
;; (concat spacemacs-test-directory
;; "core/data/not-found.sig")
;; :occur 1)))
;; (configuration-layer//error
;; (msg &rest args) ((:record-cls 'mocker-stub-record :occur 1))))
;; (should (null (configuration-layer//stable-elpa-verify-archive)))))
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment