From 6160b2177604700c07a10f4200fdf41e84bb088d Mon Sep 17 00:00:00 2001
From: Francois-Rene Rideau <tunes@google.com>
Date: Thu, 6 Mar 2014 00:10:00 -0500
Subject: [PATCH] Found the bugs triggered by using load-fasl-op on ECL. But
 one bug remains with test-xach-update-bug.script, so leaving it commented out
 until I get feedback from the ECL team.

---
 bundle.lisp                                   | 7 ++++---
 test/test-inline-methods.script               | 8 +++++---
 test/test-system-pathnames.script             | 2 +-
 test/test-xach-update-bug.script              | 7 ++++++-
 test/test2.script                             | 9 +++++----
 test/xach-foo-2/a.lisp                        | 3 ---
 test/xach-foo-2/test-asdf-location-change.asd | 2 +-
 7 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/bundle.lisp b/bundle.lisp
index 4e3106d3..68d7bd05 100644
--- a/bundle.lisp
+++ b/bundle.lisp
@@ -244,7 +244,7 @@ itself.")) ;; operation on a system and its dependencies
                (loop :for f :in (funcall key sub-o sub-c)
                      :when (funcall test f) :do (collect f))))))
 
-  (defmethod input-files ((o bundle-op) (c system))
+  (defmethod input-files ((o gather-op) (c system))
     (unless (eq (bundle-type o) :no-output-file)
       (direct-dependency-files o c :test 'bundlable-file-p :key 'output-files)))
 
@@ -454,8 +454,9 @@ itself.")) ;; operation on a system and its dependencies
 
 #+ecl
 (with-upgradability ()
-  ;; I think that Juanjo intended for this to be,
-  ;; but it breaks 4 tests in what looks like to be a compiler bug, so I'll punt for now.
+  ;; I think that Juanjo intended for this to be.
+  ;; But it might break systems with missing dependencies,
+  ;; and there is a weird bug in test-xach-update-bug.script
   ;;(unless (use-ecl-byte-compiler-p)
   ;;  (setf *load-system-operation* 'load-fasl-op))
 
diff --git a/test/test-inline-methods.script b/test/test-inline-methods.script
index 42e2003b..b1eaaabd 100644
--- a/test/test-inline-methods.script
+++ b/test/test-inline-methods.script
@@ -7,13 +7,15 @@
   ((:file "file1"
     :perform (load-op :before (o c)
                       (incf *a*)
-                      (format t "Method run before ~A~%" (action-description o c))))
+                      (format t "Method run before ~A - *a* = ~S~%~%" (action-description o c) *a*)))
    (:file "file2" :depends-on ("file1")
     :perform (load-op (o c)
                       (incf *a*)
-                      (format t "Method run for ~A~%" (action-description o c))
+                      (format t "Method run for ~A - *a* = ~S~%" (action-description o c) *a*)
                       (call-next-method)))))
 
-(load-system :foo)
+;;; Note: not calling load-system, because on ECL that would be a load-fasl-op,
+;;; and at most the file load-op happen, whereas the second .o is linked and never loaded.
+(operate 'load-op :foo)
 
 (assert-equal *a* 2)
diff --git a/test/test-system-pathnames.script b/test/test-system-pathnames.script
index dfd650fb..dd36484f 100644
--- a/test/test-system-pathnames.script
+++ b/test/test-system-pathnames.script
@@ -5,7 +5,7 @@
   :source-file nil
   :components
   ((:file "file1")
-   (:file "file2" :pathname "level2/file2")
+   (:file "file2" :pathname "level2/file2" :depends-on ("file1"))
    (:static-file "level2/static.file")
    (:static-file "test-tmp.cl")))
 
diff --git a/test/test-xach-update-bug.script b/test/test-xach-update-bug.script
index 74fdc5ed..76974b6b 100644
--- a/test/test-xach-update-bug.script
+++ b/test/test-xach-update-bug.script
@@ -40,6 +40,11 @@
  (subpathname *test-directory* "xach-foo-2/b.lisp")
  (component-pathname (find-component foo2 "b")))
 (DBG "load foo yet again. It should see the pathname has changed and load it anew")
-(load-system foo)
+;;; ECL bug: this fails if we use load-fasl-op instead of load-op:
+;;; the test-asdf-location-change.fasb is linked and loaded,
+;;; but that fails to create the :second-version package;
+;;; loading the same .fasb in another ecl works fine, and defined (second-version:wtf). WTF?
+;;; Test it by replacing load-op below by load-fasl-op, and trace load* and other functions.
+(operate 'load-op foo)
 (assert (symbol-value (find-symbol* :loaded :second-version)))
 (assert-equal 42 (symbol-call :second-version :wtf))
diff --git a/test/test2.script b/test/test2.script
index 24d66277..d92eb5bf 100644
--- a/test/test2.script
+++ b/test/test2.script
@@ -1,9 +1,10 @@
 ;;; -*- Lisp -*-
 
-
+;; We don't use load-system, because it can be load-fasl-op on ECL,
+;; and these systems define manual dependencies on compile-op.
 
 (DBG "test2: loading test2b1")
-(asdf:load-system 'test2b1)
+(operate 'load-op 'test2b1)
 
 (DBG "test2: file3 and file4 were compiled")
 (assert (and (probe-file (test-fasl "file3.lisp"))
@@ -12,7 +13,7 @@
 (DBG "test2: loading test2b2 should fail")
 
 (handler-case
-    (asdf:load-system 'test2b2)
+    (operate 'load-op 'test2b2)
   (asdf:missing-dependency (c)
     (format t "load failed as expected: - ~%~A~%" c))
   (:no-error (c)
@@ -22,7 +23,7 @@
 (DBG "test2: loading test2b3 should fail")
 
 (handler-case
-    (asdf:load-system 'test2b3)
+    (operate 'load-op 'test2b3)
   (asdf:missing-dependency (c)
     (format t "load failed as expected: - ~%~A~%" c))
   (:no-error (c)
diff --git a/test/xach-foo-2/a.lisp b/test/xach-foo-2/a.lisp
index d8dee0d7..ea2b5ac2 100644
--- a/test/xach-foo-2/a.lisp
+++ b/test/xach-foo-2/a.lisp
@@ -7,6 +7,3 @@
 (in-package :second-version)
 
 (defparameter loaded t)
-
-
-
diff --git a/test/xach-foo-2/test-asdf-location-change.asd b/test/xach-foo-2/test-asdf-location-change.asd
index 1471f4c5..e1290b8c 100644
--- a/test/xach-foo-2/test-asdf-location-change.asd
+++ b/test/xach-foo-2/test-asdf-location-change.asd
@@ -3,4 +3,4 @@
 (asdf:defsystem #:test-asdf-location-change
   :serial t
   :components ((:file "a")
-               (:file "b")))
+               (:file "b" :depends-on ("a"))))
-- 
GitLab